Files
HauntedBloodlines/Assets/Scripts/AlternateUniverse/AlternateUniverseManager.cs
2025-05-29 22:31:40 +03:00

53 lines
1.5 KiB
C#

using System.Collections;
using UnityEngine;
using UnityEngine.Events;
public class AlternateUniverseManager : MonoBehaviour
{
public event UnityAction OnGhostUniverse;
public event UnityAction OnAliveUniverse;
public bool IsInGhostUniverse;
public bool CanTearFabricOfReality;
Coroutine ghostUniverseTimerCoroutine;
private static AlternateUniverseManager _instance;
public static AlternateUniverseManager GetInstance() { return _instance; }
private void Awake()
{
if (!_instance)
{
_instance = this;
}
}
public void InvokeOnGhostUniverse()
{
OnGhostUniverse?.Invoke();
Sanity.GetInstance().sanityDropSpeedValue = Sanity.GetInstance().sanityDropSpeedInGhostUniverseValue;
if (ghostUniverseTimerCoroutine == null)
{
ghostUniverseTimerCoroutine = StartCoroutine(GhostUniverseTimer());
print("Start Ghost Universe Timer");
}
}
public void InvokeOnAliveUniverse()
{
OnAliveUniverse?.Invoke();
Sanity.GetInstance().sanityDropSpeedValue = Sanity.GetInstance().sanityDropSpeedDefaultValue;
if (ghostUniverseTimerCoroutine != null)
{
StopCoroutine(ghostUniverseTimerCoroutine);
ghostUniverseTimerCoroutine = null;
}
}
IEnumerator GhostUniverseTimer()
{
yield return new WaitForSeconds(60f);
AlternateUniversePlayerController.GetInstance().PhaseOutOfGhostUniverse();
}
}