Skip to content
Snippets Groups Projects
RoundController.cs 1.32 KiB
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; }
    public void StartRound()
        if (roundRunning)
        roundRunning = true;
        roundCallbacks.ForEach(c => c.OnRoundStart());
    }

    public void StopRound()
    {
        if (!roundRunning)
        roundRunning = false;
        roundCallbacks.ForEach(c => c.OnRoundEnd());
    public void ToggleRound()
        if (roundRunning)
        {
            StopRound();
        }
        else
        {
            StartRound();
        }
Moritz Meyerhof's avatar
Moritz Meyerhof committed
    public void ChangeGameSpeed(float multiplier)
    {
        Debug.Log(multiplier);
        Time.timeScale = multiplier;
    }

        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);