コード例 #1
0
        public void Tire(float effortCost)
        {
            if (!photonView.IsMine)
            {
                return;
            }

            // Update stamina value
            Stamina -= effortCost;

            // Clamp value if over the range
            if (Stamina < 0)
            {
                Stamina = Mathf.Clamp(Stamina, 0, MaxStamina);
            }

            // Notify listeners
            OnStaminaValueChanged?.Invoke(Stamina);

            // Update IsAfterActivity flag
            if (IsAfterActivity)
            {
                StopCoroutine(_restTimerCoroutine);
                _restTimerCoroutine = RestTimer();
            }
            else
            {
                IsAfterActivity = true;
            }
            StartCoroutine(_restTimerCoroutine);
        }
コード例 #2
0
 public void StaminaRegeneration()
 {
     Stamina += StaminaRegenerationPerSecond * Time.deltaTime;
     if (Stamina > MaxStamina)
     {
         Stamina = Mathf.Clamp(Stamina, 0, MaxStamina);
     }
     OnStaminaValueChanged?.Invoke(Stamina);
 }
コード例 #3
0
        public void RespawnInitialization()
        {
            Health          = MaxHealth;
            Stamina         = MaxStamina;
            IsAfterActivity = false;
            IsTarget        = false;

            _restTimerCoroutine = RestTimer();
            _safeTimerCoroutine = SafeTimer();
            _isDying            = false;

            OnHealthValueChanged?.Invoke(Health);
            OnStaminaValueChanged?.Invoke(Stamina);
        }