Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public interface IRoundCallback
{
void OnRoundStart();
void OnRoundEnd();
}
public class RoundController : MonoBehaviour
{
public static RoundController instance { get; private set; }
public List<IRoundCallback> roundCallbacks = new List<IRoundCallback>();
public bool roundRunning { get; private set; }
roundRunning = true;
roundCallbacks.ForEach(c => c.OnRoundStart());
}
public void StopRound()
{
if (!roundRunning)
roundRunning = false;
roundCallbacks.ForEach(c => c.OnRoundEnd());
if (roundRunning)
{
StopRound();
}
else
{
StartRound();
}
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);