Ejemplo n.º 1
0
 public void ChangeHealth(int amount)
 {
     health += amount;
     OnChangeHealth?.Invoke(health);
     if (health > 0)
     {
         return;
     }
     OnObjectDestroy?.Invoke();
     Destroy(gameObject);
 }
Ejemplo n.º 2
0
 public void Hurt(float damage)
 {
     _currentHealthValue -= damage;
     OnChangeHealth?.Invoke(_currentHealthValue);
     if (_currentHealthValue <= 0)
     {
         OnDie?.Invoke();
         if (!gameObject.CompareTag("Player"))
         {
             Destroy(gameObject);
         }
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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();
             */
        }
    }
Ejemplo n.º 5
0
 public static void RaiseOnChangeHealthEvent(int currentHealth)
 {
     OnChangeHealth?.Invoke(currentHealth);
 }
Ejemplo n.º 6
0
 private void ChangeHealth(float currentHealth)
 {
     OnChangeHealth?.Invoke(ID, currentHealth);
 }
Ejemplo n.º 7
0
 public void IncreaseHealthPoint()
 {
     health++;
     OnChangeHealth?.Invoke(health);
 }