48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SanityEvent : MonoBehaviour
|
|
{
|
|
[Tooltip("Sanity drop target is how low you want the player's sanity to go.")]
|
|
public float sanityDropTarget;
|
|
|
|
public void DropPlayerSanity(float dropSpeed)
|
|
{
|
|
if (Sanity.GetInstance().currentSanity > sanityDropTarget) // Only drop sanity if player's sanity is larger than the target.
|
|
{
|
|
StartCoroutine(SanityDropUpdater(dropSpeed));
|
|
RumbleManager.GetInstance().StartHeartBeatRumble(sanityDropTarget);
|
|
}
|
|
}
|
|
|
|
IEnumerator SanityDropUpdater(float dropSpeed)
|
|
{
|
|
while (Sanity.GetInstance().currentSanity >= sanityDropTarget)
|
|
{
|
|
//RumbleManager.GetInstance().StartRumble(0.2f, 0.2f);
|
|
|
|
if (Time.timeScale != 0)
|
|
{
|
|
Sanity.GetInstance().SetSanity(Sanity.GetInstance().currentSanity - dropSpeed);
|
|
|
|
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
}
|
|
Sanity.GetInstance().SetSanity(sanityDropTarget);
|
|
RumbleManager.GetInstance().StopRumble();
|
|
}
|
|
|
|
public void SanityDropSpeedChangeValue(float sanityDropSpeed)
|
|
{
|
|
Sanity.GetInstance().sanityDropSpeedValue = sanityDropSpeed;
|
|
}
|
|
|
|
public void SanityDropSpeedOriginalValue()
|
|
{
|
|
Sanity.GetInstance().sanityDropSpeedValue = Sanity.GetInstance().sanityDropSpeedDefaultValue;
|
|
}
|
|
}
|