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
MarcoHampel f8590432ba Assemblies Made and Refactored Code Folders
Created assemblies for the new design code. Relocated legacy scripts into a legacy folder and made a "new_design" folder for new design.
2023-09-11 19:39:27 -04:00

67 lines
1.8 KiB
C#

using FishNet.Object;
using FishNet.Connection;
using UnityEngine;
namespace Player
{
public class NoiseVisibilitySettingsManager : NetworkBehaviour
{
[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;
}
[ServerRpc]
public void ShotFired()
{
timeSinceLastShot = shootNoiseDuration;
}
public void SetRunning(bool isRunning)
{
this.isRunning = isRunning;
}
public void SetSneaking(bool isSneaking)
{
this.isSneaking = isSneaking;
}
}
}