f8590432ba
Created assemblies for the new design code. Relocated legacy scripts into a legacy folder and made a "new_design" folder for new design.
67 lines
1.8 KiB
C#
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;
|
|
}
|
|
}
|
|
} |