StationObscurum/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs
2023-06-01 08:03:48 -07:00

62 lines
1.5 KiB
C#

using UnityEngine;
public class NoiseVisibilitySettingsManager : MonoBehaviour
{
[SerializeField] private float sneakNoiseDistance = 5f;
[SerializeField] private float runNoiseDistance = 10f;
[SerializeField] private float shootNoiseDistance = 30f;
[SerializeField] private float standNoiseDistance;
[SerializeField] private float shootNoiseDuration = 2f;
private bool isRunning;
private bool isSneaking;
private float timeSinceLastShot;
public float SneakNoiseDistance => sneakNoiseDistance;
public float RunNoiseDistance => runNoiseDistance;
public float ShootNoiseDistance => shootNoiseDistance;
public float StandNoiseDistance => standNoiseDistance;
public float NoiseDistance { get; private set; }
// Start is called before the first frame update
private void Start()
{
}
// Update is called once per frame
private void Update()
{
if (timeSinceLastShot > 0)
NoiseDistance = shootNoiseDistance;
else if (isRunning)
NoiseDistance = runNoiseDistance;
else if (isSneaking)
NoiseDistance = sneakNoiseDistance;
else
NoiseDistance = standNoiseDistance;
timeSinceLastShot -= Time.deltaTime;
}
public void ShotFired()
{
timeSinceLastShot = shootNoiseDuration;
}
public void SetRunning(bool isRunning)
{
this.isRunning = isRunning;
}
public void SetSneaking(bool isSneaking)
{
this.isSneaking = isSneaking;
}
}