3DTD/Assets/Scripts/Manager/MoneyManager.cs

37 lines
895 B
C#
Raw Normal View History

2024-04-20 23:26:44 +02:00
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Assertions;
public class MoneyManager : MonoBehaviour
{
public GameObject[] ShopButtons;
public TMP_Text[] MoneyTexts;
private void OnEnable()
{
for (int i = 0; i < ShopButtons.Length; i++)
{
var eventScript = ShopButtons[i].GetComponentInChildren<UITooltips>();
eventScript.ButtonIndex = i;
eventScript.OnClick += OnShopButtonClicked;
}
}
private void OnShopButtonClicked(int index)
{
Assert.AreNotEqual(index, -1, "Shop button not init-ed with index");
print("Button clicked: " + index);
}
}
[CreateAssetMenu(fileName = "New TowerCollection", menuName = "Tower Defense/Tower Collection")]
public class TowerCollection : ScriptableObject
{
public Tower[] Towers;
}