Added unlock mechanic with testing if player has all items in inventory.
This commit is contained in:
@@ -169,15 +169,18 @@ public partial class UIHandler : Control
|
||||
{
|
||||
currentLayer.Text = $"Current layer: {GameData.currentLayer}/{GameData.ruinSize}";
|
||||
deepestLayer.Text = $"Deepest layer: {GameData.lowestLayer}";
|
||||
unlockLayer.TooltipText = "Needed items: \r" + GameData.map[GameData.lowestLayer].DisplayGateIngredients();
|
||||
unlockLayer.Disabled = !GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1);
|
||||
}
|
||||
|
||||
public void UnlockLayer()
|
||||
{
|
||||
if (GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1))
|
||||
{
|
||||
foreach (Ingredient ingredient in GameData.map[GameData.lowestLayer].gateIngredients)
|
||||
{
|
||||
GD.Print($"{ingredient.Item} ({ingredient.Amount})");
|
||||
GameData.inventory.RemoveItem(ingredient.Item, ingredient.Amount);
|
||||
}
|
||||
GD.Print("------------------------");
|
||||
GameData.lowestLayer++;
|
||||
if (GameData.lowestLayer == GameData.ruinSize)
|
||||
{
|
||||
@@ -185,3 +188,4 @@ public partial class UIHandler : Control
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,4 +264,14 @@ public partial class Layer : Node3D
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public string DisplayGateIngredients()
|
||||
{
|
||||
string result = "";
|
||||
foreach (Ingredient ingredient in gateIngredients)
|
||||
{
|
||||
result += $"{ItemData.GetReadableName(ingredient.Item)} ({ingredient.Amount})\r";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user