31 lines
708 B
C#
31 lines
708 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class TurnSystem : MonoBehaviour {
|
|
private int turnNumber = 1;
|
|
public static TurnSystem Instance { get; private set; }
|
|
|
|
public int TurnNumber {
|
|
get => turnNumber;
|
|
private set {
|
|
turnNumber = value;
|
|
OnTurnChanged?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
|
|
private void Awake() {
|
|
if (Instance is not null) {
|
|
Debug.LogError($"There is more than one TurnSystem! {transform} - {Instance}");
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
}
|
|
|
|
public event EventHandler OnTurnChanged;
|
|
|
|
public void NextTurn() {
|
|
TurnNumber++;
|
|
}
|
|
} |