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

73 lines
1.9 KiB
C#
Raw Normal View History

2023-04-21 09:30:43 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class NoiseVisibilitySettingsManager : MonoBehaviour
{
[SerializeField]
private float sneakNoiseDistance = 5f;
[SerializeField]
private float runNoiseDistance = 10f;
[SerializeField]
private float shootNoiseDistance = 30f;
[SerializeField]
private float standNoiseDistance = 0f;
private float noiseDistance = 0f;
public float SneakNoiseDistance { get { return sneakNoiseDistance; } }
public float RunNoiseDistance { get { return runNoiseDistance; } }
public float ShootNoiseDistance { get { return shootNoiseDistance; } }
public float StandNoiseDistance { get { return standNoiseDistance; } }
public float NoiseDistance { get { return this.noiseDistance; } }
private float timeSinceLastShot = 0f;
[SerializeField]
private float shootNoiseDuration = 2f;
private bool isSneaking = false;
private bool isRunning = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (timeSinceLastShot>0)
{
this.noiseDistance = this.shootNoiseDistance;
}
else if (isRunning)
{
this.noiseDistance = this.runNoiseDistance;
}else if (isSneaking)
{
this.noiseDistance = this.sneakNoiseDistance;
}
else
{
this.noiseDistance = standNoiseDistance;
}
timeSinceLastShot -= Time.deltaTime;
}
public void ShotFired()
{
this.timeSinceLastShot = this.shootNoiseDuration;
}
public void SetRunning(bool isRunning)
{
this.isRunning = isRunning;
}
public void SetSneaking(bool isSneaking)
{
this.isSneaking= isSneaking;
}
}