Added unlock mechanic with testing if player has all items in inventory.

This commit is contained in:
2026-05-09 15:06:46 +02:00
parent 213d0aed97
commit 5eab205a9c
2 changed files with 22 additions and 8 deletions
+6 -2
View File
@@ -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
}
}
}
}
+10
View File
@@ -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;
}
}