diff --git a/Scripts/UI/Common/UIHandler.cs b/Scripts/UI/Common/UIHandler.cs index 85ea2e3..b620f82 100644 --- a/Scripts/UI/Common/UIHandler.cs +++ b/Scripts/UI/Common/UIHandler.cs @@ -169,19 +169,23 @@ 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() { - foreach (Ingredient ingredient in GameData.map[GameData.lowestLayer].gateIngredients) + if (GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1)) { - GD.Print($"{ingredient.Item} ({ingredient.Amount})"); - } - GD.Print("------------------------"); - GameData.lowestLayer++; - if (GameData.lowestLayer == GameData.ruinSize) - { - GD.Print("GAME WON!"); + foreach (Ingredient ingredient in GameData.map[GameData.lowestLayer].gateIngredients) + { + GameData.inventory.RemoveItem(ingredient.Item, ingredient.Amount); + } + GameData.lowestLayer++; + if (GameData.lowestLayer == GameData.ruinSize) + { + GD.Print("GAME WON!"); + } } } } diff --git a/Scripts/World/Layer.cs b/Scripts/World/Layer.cs index 691c5c9..95ee1c5 100644 --- a/Scripts/World/Layer.cs +++ b/Scripts/World/Layer.cs @@ -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; + } }