73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
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;
|
|
}
|
|
}
|