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/Legacy/Player/NoiseVisibilitySettingsManager.cs

67 lines
1.8 KiB
C#
Raw Normal View History

2023-06-15 19:03:27 +02:00
using FishNet.Object;
2023-06-15 19:06:08 +02:00
using FishNet.Connection;
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-15 19:06:08 +02:00
public class NoiseVisibilitySettingsManager : NetworkBehaviour
2023-06-01 20:25:46 +02:00
{
[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
}