89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using InfallibleCode;
|
|
|
|
public class HideManager : MonoBehaviour
|
|
{
|
|
[Header("Closet Hide")]
|
|
public bool InCloset;
|
|
public bool OutOfCloset = true;
|
|
public bool CanPressKey = true; //We have to see if we want different delays
|
|
public NewLightSwitch currentClosetLightSwitch;
|
|
public bool lightSwitchTimerIsRunning;
|
|
|
|
//Maya added this
|
|
[Header("Bed Hide")]
|
|
public bool UnderBed;
|
|
public bool NextToBed = true;
|
|
public bool isInBedRightSide;
|
|
|
|
[Header("Table Hide")]
|
|
public bool UnderTable;
|
|
public bool NextToTable = true;
|
|
|
|
private Coroutine _playerHideTimer;
|
|
|
|
private static HideManager _instance;
|
|
public static HideManager GetInstance() { return _instance; }
|
|
|
|
void Awake()
|
|
{
|
|
if (!_instance)
|
|
{
|
|
_instance = this;
|
|
}
|
|
}
|
|
|
|
public void StartClosetCoroutineTimer()
|
|
{
|
|
StartCoroutine(ClosetLightSwitchTimer());
|
|
}
|
|
|
|
IEnumerator ClosetLightSwitchTimer()
|
|
{
|
|
print("Started light switch closet timer!");
|
|
float waitTime = 5f;
|
|
yield return new WaitForSeconds(waitTime);
|
|
if (currentClosetLightSwitch.lightIsOn)
|
|
{
|
|
//Updates the spot for the enemy to go to:
|
|
PatrolManager.GetInstance().SetNearbyRoomsPatrolPoints();
|
|
PatrolManager.GetInstance().UpdateTakeOutPlayerSpot();
|
|
//Goes to the spot:
|
|
PatrolManager.GetInstance().content = PatrolManager.Rute.GoesToTakeOutPlayerFromHiddingSpotPath;
|
|
MedeaDemonicEnemyBehaviour.GetInstance().state = MedeaDemonicEnemyBehaviour.medeaState.TakingOutPlayerFromHiddingSpot;
|
|
print("Light switch is ON so Medea is coming for you gurl <3!");
|
|
}
|
|
}
|
|
|
|
IEnumerator PlayerHideTimer()
|
|
{
|
|
float waitTime = 180f;
|
|
yield return new WaitForSeconds(waitTime/*180f*/);
|
|
|
|
Debug.Log("player is hidden for too long in the same spot");
|
|
print("Waited for: " + waitTime);
|
|
PatrolManager.GetInstance().UpdateTakeOutPlayerSpot();
|
|
PatrolManager.GetInstance().content = PatrolManager.Rute.GoesToTakeOutPlayerFromHiddingSpotPath;
|
|
MedeaDemonicEnemyBehaviour.GetInstance().state = MedeaDemonicEnemyBehaviour.medeaState.TakingOutPlayerFromHiddingSpot;
|
|
}
|
|
|
|
public void StartPlayerHideTimer()
|
|
{
|
|
if (PatrolManager.GetInstance() != null && MedeaDemonicEnemyBehaviour.GetInstance() != null)
|
|
{
|
|
_playerHideTimer = StartCoroutine(PlayerHideTimer());
|
|
}
|
|
}
|
|
|
|
public void StopPlayerHideTimer()
|
|
{
|
|
if (_playerHideTimer != null)
|
|
{
|
|
StopCoroutine(_playerHideTimer);
|
|
print("Stopped player Hide Timer");
|
|
}
|
|
}
|
|
}
|