Добавлен индикатор стамины и переделаны дороги
This commit is contained in:
@ -1,23 +1,17 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CarManagerScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private int _MaxSpeed;
|
||||
[SerializeField] private int _MaxSpeed;
|
||||
|
||||
private int _Speed;
|
||||
|
||||
[SerializeField]
|
||||
private List<GameObject> _CarPrefs;
|
||||
[SerializeField] private List<GameObject> _CarPrefs;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject[] _Points = new GameObject[2];
|
||||
[SerializeField] private GameObject[] _Points = new GameObject[2];
|
||||
|
||||
[SerializeField]
|
||||
bool _LeftToRight;
|
||||
[SerializeField] bool _LeftToRight;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -34,7 +28,7 @@ public class CarManagerScript : MonoBehaviour
|
||||
|
||||
//Debug.Log($"Speed - {_Speed}");
|
||||
|
||||
_LeftToRight = GetRandomObject<bool>(new List<bool> { true, false });
|
||||
//_LeftToRight = GetRandomObject<bool>(new List<bool> { true, false });
|
||||
|
||||
float time = GetRandomObject<float>(new List<float> { 0f, 1f, 2f, 3f, 4f, 5f });
|
||||
|
||||
@ -62,7 +56,7 @@ public class CarManagerScript : MonoBehaviour
|
||||
{
|
||||
DeleteCar();
|
||||
}
|
||||
else if (_Car.transform.position.x <= _Points[0].transform.position.x && !_LeftToRight)
|
||||
else if (_Car.transform.position.x <= _Points[0].transform.position.x && !_LeftToRight)
|
||||
{
|
||||
DeleteCar();
|
||||
}
|
||||
@ -103,7 +97,7 @@ public class CarManagerScript : MonoBehaviour
|
||||
|
||||
public void DeleteCar()
|
||||
{
|
||||
Destroy( _Car );
|
||||
Destroy(_Car);
|
||||
StartMove();
|
||||
}
|
||||
|
||||
|
@ -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