2023-06-15 19:03:27 +02:00
|
|
|
using FishNet.Object;
|
2023-04-21 09:30:43 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
namespace Player
|
2023-04-21 09:30:43 +02:00
|
|
|
{
|
2023-06-01 20:25:46 +02:00
|
|
|
public class NoiseVisibilitySettingsManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private float sneakNoiseDistance = 5f;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
[SerializeField] private float runNoiseDistance = 10f;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
[SerializeField] private float shootNoiseDistance = 30f;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
[SerializeField] private float standNoiseDistance;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
[SerializeField] private float shootNoiseDuration = 2f;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
private bool isRunning;
|
|
|
|
private bool isSneaking;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
private float timeSinceLastShot;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
public float SneakNoiseDistance => sneakNoiseDistance;
|
|
|
|
public float RunNoiseDistance => runNoiseDistance;
|
|
|
|
public float ShootNoiseDistance => shootNoiseDistance;
|
|
|
|
public float StandNoiseDistance => standNoiseDistance;
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
public float NoiseDistance { get; private set; }
|
2023-04-21 09:30:43 +02:00
|
|
|
|
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
// Start is called before the first frame update
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
}
|
2023-04-21 09:30:43 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
// 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;
|
2023-04-21 09:30:43 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
timeSinceLastShot -= Time.deltaTime;
|
|
|
|
}
|
2023-06-15 19:03:27 +02:00
|
|
|
[ServerRpc]
|
2023-06-01 20:25:46 +02:00
|
|
|
public void ShotFired()
|
|
|
|
{
|
|
|
|
timeSinceLastShot = shootNoiseDuration;
|
|
|
|
}
|
2023-06-01 17:03:48 +02:00
|
|
|
|
2023-06-01 20:25:46 +02:00
|
|
|
public void SetRunning(bool isRunning)
|
|
|
|
{
|
|
|
|
this.isRunning = isRunning;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetSneaking(bool isSneaking)
|
|
|
|
{
|
|
|
|
this.isSneaking = isSneaking;
|
|
|
|
}
|
2023-04-21 09:30:43 +02:00
|
|
|
}
|
2023-06-01 17:03:48 +02:00
|
|
|
}
|