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

50 lines
1.1 KiB
C#

using System;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public float Balance = 0;
public static GameManager Instance;
public bool IsBuildMode = false;
private Tower selectedTower;
public Tower SelectedTower { get { return selectedTower; } set {
if (selectedTower != null)
selectedTower.TowerSelected(false);
selectedTower = value;
if (selectedTower != null)
selectedTower.TowerSelected(true);
}}
private void Awake()
{
if (Instance != this)
Destroy(Instance);
Instance = this;
}
private void OnEnable()
{
MoneyManager.OnShopSelected += m_OnTowerShopSelected;
TowerPlacementManager.OnTowerPlaced += m_finishBuildmode;
}
private void OnDisable()
{
MoneyManager.OnShopSelected -= m_OnTowerShopSelected;
TowerPlacementManager.OnTowerPlaced -= m_finishBuildmode;
}
private void m_OnTowerShopSelected(TowerInfo info)
{
IsBuildMode = true;
}
private void m_finishBuildmode(TowerInfo info)
{
IsBuildMode = false;
}
}