示例#1
0
 public void ChangeHealth(int amount)
 {
     health += amount;
     OnChangeHealth?.Invoke(health);
     if (health > 0)
     {
         return;
     }
     OnObjectDestroy?.Invoke();
     Destroy(gameObject);
 }
示例#2
0
 public void Hurt(float damage)
 {
     _currentHealthValue -= damage;
     OnChangeHealth?.Invoke(_currentHealthValue);
     if (_currentHealthValue <= 0)
     {
         OnDie?.Invoke();
         if (!gameObject.CompareTag("Player"))
         {
             Destroy(gameObject);
         }
     }
 }
示例#3
0
 protected void ChangeHealth(float amount)
 {
     HealthPoints += amount;
     // Rounding to min and max
     HealthPoints = Mathf.Clamp(HealthPoints, 0, MaxHealthPoints);
     OnChangeHealth?.Invoke(HealthPoints);
     if (HealthPoints != 0)
     {
         return;
     }
     OnDead?.Invoke();
     // Check for availability death animation
     if (_animator != null)
     {
         StartCoroutine(AnimationDeath());
     }
 }
示例#4
0
    public void Hurt(float damage)
    {
        damage    *= immortalDamageMultiplier;
        hitpoints -= Mathf.RoundToInt(damage);
        hud.SetHp(hitpoints);

        OnChangeHealth?.Invoke(handle, Mathf.RoundToInt(damage));

        if (hitpoints <= 0 && isAlive)
        {
            isAlive = false;
            OnDie?.Invoke(handle);
            StartCoroutine(RespawnRoutine());

            /*
             * Spawn(mySpawnPoint, mySpawnRot);
             * ResetPlayer();
             *          ragdoll.hasControl = false;
             *          ragdoll.ControlRightHand = false;
             *          ragdoll.ControlLeftHand = false;
             *          ragdoll.Stop();
             */
        }
    }
示例#5
0
 public static void RaiseOnChangeHealthEvent(int currentHealth)
 {
     OnChangeHealth?.Invoke(currentHealth);
 }
示例#6
0
 private void ChangeHealth(float currentHealth)
 {
     OnChangeHealth?.Invoke(ID, currentHealth);
 }
示例#7
0
 public void IncreaseHealthPoint()
 {
     health++;
     OnChangeHealth?.Invoke(health);
 }