Added unlock mechanic with testing if player has all items in inventory.
This commit is contained in:
@@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user