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