public void DealDamage(int damageAmount) { //If unit has no health do nothing if (currentHealth == 0) { return; } //Reduce health by damage amount currentHealth -= damageAmount; //if the health drops below 0, set it to 0 if (currentHealth < 0) { currentHealth = 0; } //If unit is not dead, stop here if (currentHealth != 0) { return; } //TODO ServerOnDie?.Invoke(); }
public void ServerDealDamage(int damageAmount) { if (currentHealth == 0) { return; } SetHealth(Mathf.Max(currentHealth - damageAmount, 0)); /*if(healthBar != null) * { * HealthBar updatedBar = healthBar.GetComponent<HealthBar>(); * updatedBar.SetHealth(currentHealth); * } * else * { * Debug.Log("healthBar is null"); * } */ if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); }
public void DealDamage(int damageAmount) { //If We Already Dead Return if (currentHealth == 0) { return; } //If The Health After You Have Taken Off The Damage, Lower Than Zero Then Stop Get Negative Number It Set to The Zero currentHealth = Mathf.Max(currentHealth - damageAmount, 0); /* It is Same As The Upper Code Segment * * currentHealth -= damageAmount; * * if(currentHealth < 0) * { * currentHealth = 0; * } */ if (currentHealth != 0) { return; } //If health == 0 We Died ServerOnDie?.Invoke(); }
public void Die() { if (!isAlive) { return; } isAlive = false; currentHealth = 0; ServerOnDie?.Invoke(); }
public void Damage(float damage) { if (curHealth == 0) { return; } curHealth = Mathf.Max(curHealth - damage, 0); if (curHealth > 0) { return; } ServerOnDie?.Invoke(); }
public void DealDamage(int damageAmount) { if (currentHealth == 0) { return; } // removes the damage amount from currentHealth but if it is less than 0, it returns 0 currentHealth = Mathf.Max(currentHealth - damageAmount, 0); if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); Debug.Log($"we ded"); }
public void DealDamage(int damageAmount) { if (currentHealth <= 0) { return; } currentHealth = Mathf.Max(currentHealth - damageAmount, 0); if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); }
public void DealDamage(int damageToDeal) { if (currentHealth == 0) { return; } currentHealth = Mathf.Max(currentHealth - damageToDeal, 0); Debug.Log($"Health Now: {currentHealth}"); if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); Debug.Log("Player Died"); }
public void DealDamage(int damageAmount) { if (_currentHealth == 0) { return; } _currentHealth = Mathf.Max(_currentHealth - damageAmount, 0); if (_currentHealth != 0) { return; } // dead Debug.Log("Dead"); ServerOnDie?.Invoke(); }
public void DealDamage(int damageAmount) { if (currentHealth == 0) { return; } currentHealth = Mathf.Max(currentHealth - damageAmount, 0); // make sure health can never go below 0 if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); Debug.Log("We Died!"); }
public void DealDamage(int damageAmount) { if (currentHealth == 0) { return; } // only die once! currentHealth = Mathf.Max(currentHealth - damageAmount, 0); // keeps it from going negative and saves a bunch of code if (currentHealth != 0) { return; } ServerOnDie?.Invoke(); // this raises an event that can be listened to elsewhere so each object can have a different death Debug.Log("We died."); }
public void DealDamage(int damage) { if (currentHealth == 0) { return; } currentHealth = Mathf.Max(currentHealth - damage, 0); if (currentHealth != 0) { return; } // TOD disabling OBJ to be targetable after its health reaches 0 ServerOnDie?.Invoke();//event called on server when health of OBJ reaches 0 }
public void DealDamage(int damageAmount) { if (currentHealth == 0) { return; } currentHealth = Mathf.Max(0, currentHealth - damageAmount); //Below here is death only. if (currentHealth != 0) { return; } //invoke the action above to allow all our different units and stuff to do their death handling. ServerOnDie?.Invoke(); Debug.Log("We died!"); }
public void DealDamage(int damageAmount) { if (currentHealth <= 0) { return; } currentHealth -= damageAmount; if (currentHealth < 0) { currentHealth = 0; } if (currentHealth == 0) { //dead Debug.Log(this.name + " Died"); ServerOnDie?.Invoke(); } }