Добавлен индикатор стамины и переделаны дороги
This commit is contained in:
@ -27,9 +27,19 @@ public class SwingingArmMotionScript : MonoBehaviour
|
||||
private float SmoothedSpeed;
|
||||
[SerializeField] private float SpeedSmoothingFactor;
|
||||
|
||||
// Stamina (выносливость)
|
||||
[SerializeField] private float MaxStamina; // Максимальная выносливость
|
||||
[SerializeField] private float Stamina; // Текущая выносливость
|
||||
// _Stamina (выносливость)
|
||||
[SerializeField] private float _MaxStamina; // Максимальная выносливость
|
||||
public float MaxStamina
|
||||
{
|
||||
get { return _MaxStamina; }
|
||||
}
|
||||
|
||||
[SerializeField] private float _Stamina; // Текущая выносливость
|
||||
public float Stamina
|
||||
{
|
||||
get { return _Stamina; }
|
||||
set { _Stamina = value; }
|
||||
}
|
||||
[SerializeField] private float StaminaDrainRate; // Скорость расхода выносливости (единиц/сек)
|
||||
[SerializeField] private float StaminaRecoveryRate; // Скорость восстановления (единиц/сек)
|
||||
[SerializeField] private float LowStaminaMultiplier; // Снижение скорости при низкой выносливости
|
||||
@ -37,7 +47,12 @@ public class SwingingArmMotionScript : MonoBehaviour
|
||||
|
||||
[SerializeField] private bool IsRecovering = false; // Флаг для ожидания восстановления
|
||||
[SerializeField] private float RecoveryTimer; // Таймер восстановления
|
||||
[SerializeField] private bool IsPreRecovery = false;
|
||||
|
||||
[SerializeField] private bool _IsPreRecovery = false;
|
||||
public bool IsPreRecovery
|
||||
{
|
||||
get { return _IsPreRecovery; }
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
@ -48,8 +63,7 @@ public class SwingingArmMotionScript : MonoBehaviour
|
||||
CurrentSpeed = BaseSpeed; // Initialize to base speed
|
||||
SmoothedSpeed = BaseSpeed;
|
||||
|
||||
Stamina = MaxStamina; // Инициализация выносливости
|
||||
|
||||
_Stamina = _MaxStamina; // Инициализация выносливости
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -86,26 +100,26 @@ public class SwingingArmMotionScript : MonoBehaviour
|
||||
}
|
||||
if (!IsRecovering)
|
||||
{
|
||||
Stamina += StaminaRecoveryRate * Time.deltaTime; // Восстанавливаем стамину
|
||||
Stamina = Mathf.Clamp(Stamina, 0, MaxStamina);
|
||||
_Stamina += StaminaRecoveryRate * Time.deltaTime; // Восстанавливаем стамину
|
||||
_Stamina = Mathf.Clamp(_Stamina, 0, _MaxStamina);
|
||||
|
||||
if (IsPreRecovery)
|
||||
if (_IsPreRecovery)
|
||||
{
|
||||
if (Stamina >= 0.5*MaxStamina)
|
||||
if (_Stamina >= 0.5 * _MaxStamina)
|
||||
{
|
||||
IsPreRecovery = false;
|
||||
_IsPreRecovery = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (HandSpeed > HandSpeedThreshold)
|
||||
{
|
||||
Stamina -= StaminaDrainRate * Time.deltaTime; // Уменьшаем стамину
|
||||
Stamina = Mathf.Clamp(Stamina, 0, MaxStamina);
|
||||
if (!IsPreRecovery)
|
||||
_Stamina -= StaminaDrainRate * Time.deltaTime; // Уменьшаем стамину
|
||||
_Stamina = Mathf.Clamp(_Stamina, 0, _MaxStamina);
|
||||
if (!_IsPreRecovery)
|
||||
{
|
||||
CurrentSpeed = BaseSpeed * SprintSpeedMultiplier; // Замедляем, если стамина истощена
|
||||
}
|
||||
else if (IsPreRecovery)
|
||||
else if (_IsPreRecovery)
|
||||
{
|
||||
CurrentSpeed = BaseSpeed;
|
||||
}
|
||||
@ -115,10 +129,10 @@ public class SwingingArmMotionScript : MonoBehaviour
|
||||
CurrentSpeed = BaseSpeed;
|
||||
}
|
||||
}
|
||||
if (Stamina <= 0)
|
||||
if (_Stamina <= 0)
|
||||
{
|
||||
IsRecovering = true;
|
||||
IsPreRecovery = true;
|
||||
_IsPreRecovery = true;
|
||||
}
|
||||
|
||||
SmoothedSpeed = Mathf.Lerp(SmoothedSpeed, CurrentSpeed, SpeedSmoothingFactor);
|
||||
|
Reference in New Issue
Block a user