This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs

65 lines
1.7 KiB
C#

using UnityEngine;
namespace Player
{
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;
}
}
}