Finished upgrade menu
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Fruitomation.Game.Items;
|
||||
using Fruitomation.Game;
|
||||
using Fruitomation.Global;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -16,9 +18,15 @@ namespace Fruitomation.UI
|
||||
[SerializeField] private GameObject BuildingDisplay;
|
||||
[SerializeField] private GameObject LeftArrow;
|
||||
[SerializeField] private GameObject SpawnerText;
|
||||
[SerializeField] private Button UnlockButton;
|
||||
[SerializeField] private GameObject UnlockedText;
|
||||
[SerializeField] private GameObject PoorPeopleText;
|
||||
|
||||
private readonly Dictionary<AutomationBuildingType, GameObject> BuildingRegistry = new();
|
||||
private readonly List<GameObject> ChildrenToKill = new();
|
||||
|
||||
private BasicUpgrade CurrentUpgrade;
|
||||
private double CurrentCost;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -35,6 +43,12 @@ namespace Fruitomation.UI
|
||||
BuildingRegistry.Add(info.Type, info.Prefab);
|
||||
}
|
||||
}
|
||||
|
||||
UnlockButton.onClick.AddListener(() =>
|
||||
{
|
||||
MoneyController.CanBuy(CurrentCost);
|
||||
UpgradeManager.Unlock(CurrentUpgrade);
|
||||
});
|
||||
}
|
||||
|
||||
public void Enable
|
||||
@@ -47,7 +61,11 @@ namespace Fruitomation.UI
|
||||
)
|
||||
// Wow, those function params are horrible
|
||||
{
|
||||
CurrentUpgrade = upgrade;
|
||||
CurrentCost = cost;
|
||||
|
||||
BoardGO.SetActive(true);
|
||||
|
||||
foreach (ItemType input in inputs)
|
||||
{
|
||||
ItemInfo info = ItemInfoRegistry.Get(input);
|
||||
@@ -92,6 +110,34 @@ namespace Fruitomation.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (UpgradeManager.Is(CurrentUpgrade))
|
||||
{
|
||||
UnlockedText.SetActive(true);
|
||||
|
||||
UnlockButton.gameObject.SetActive(false);
|
||||
PoorPeopleText.SetActive(false);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
UnlockedText.SetActive(false);
|
||||
|
||||
if (MoneyController.CouldBuy(CurrentCost))
|
||||
{
|
||||
UnlockButton.gameObject.SetActive(true);
|
||||
PoorPeopleText.SetActive(false);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
UnlockButton.gameObject.SetActive(false);
|
||||
PoorPeopleText.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Disable()
|
||||
{
|
||||
BoardGO.SetActive(false);
|
||||
|
||||
Reference in New Issue
Block a user