private void OnCheckStatus(CurrentHPArgs e) { if (e.currentHp < maxHp / 4f) { HPCheck += HPValueWarning; } HPCheck?.Invoke(this, e); HPCheck -= HPValueWarning; }
private void OnCheckStatus(CurrentHPArgs e) { if (e.currentHp <= this.maxHp / 4) { HPCheck += HPValueWarning; } else { HPCheck -= HPValueWarning; } HPCheck.Invoke(this, e); }
/// <summary> /// ValidateHP method /// </summary> public void ValidateHP(float newHp) { if (newHp <= 0) { this.hp = 0; } else if (newHp >= this.maxHp) { this.hp = this.maxHp; } else { this.hp = newHp; } HPCheck.Invoke(this, new CurrentHPArgs(hp)); }
/// <summary> /// Validates "newHp" and updates "hp" /// </summary> /// <param name="newHp">amount to modify "hp" by pre-validation</param> public void ValidateHP(float newHp) { if (newHp < 0) { hp = 0f; } else if (newHp > maxHp) { hp = maxHp; } else { hp = newHp; } HPCheck?.Invoke(this, new CurrentHPArgs(hp)); }
/// <summary> /// Set the players health /// </summary> public void ValidateHP(float newHp) { this.hp = (newHp < 0 ? 0 : (newHp > maxHp ? maxHp : newHp)); HPCheck?.Invoke(this, new CurrentHPArgs(hp)); }