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, IFighterCallback
public static RoundController instance { get; private set; }
public List<IRoundCallback> roundCallbacks = new List<IRoundCallback>();
public bool roundRunning { get; private set; }
[SerializeField, Tooltip("After the AntiHero died, how many seconds to wait until ending the current round")]
float delayAfterAntiHeroDeath = 1.75f;
BaseCameraController cameraController;
roundCallbacks.ForEach(c => c.OnRoundStart());
// Fighters clear their callbacks every round end
GameObject.FindGameObjectWithTag("AntiPlayer").GetComponent<Fighter>().callbacks.Add(this);
}
public void StopRound()
{
if (!roundRunning)
roundCallbacks.ForEach(c => c.OnRoundEnd());
if (roundRunning)
{
StopRound();
}
else
{
StartRound();
}
public void SetGameSpeed(float multiplier)
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
cameraController = Camera.main.GetComponent<BaseCameraController>();
public void OnFighterDeath(Fighter fighter)
{
// The AntiHero has died
SetGameSpeed(0.5f);
cameraController.AnimateToPosition(fighter.transform.position + new Vector3(0f, 0.75f), 1.5f, 0.05f);
Invoke(nameof(StopRound), delayAfterAntiHeroDeath);