示例#1
0
 // Method that checks currentHP
 private void OnCheckStatus(CurrentHPArgs e)
 {
     if (e.currentHp <= (this.maxHp / 4.0f))
     {
         HPCheck += HPValueWarning;
     }
     HPCheck?.Invoke(this, e);
 }
 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));
 }
示例#4
0
    /// <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));
    }
示例#5
0
 /// <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));
 }