コード例 #1
0
 void Damage()
 {
     --health;
     onPlayerDamageEvent?.Raise();
     GameplayScript.SetHpUI(health < 0 ? 0 : health);
     if (health <= 0)
     {
         OnPlayerDeath();
     }
     else
     {
         coroutine = StartCoroutine(TemporaryImmunity());
     }
 }
コード例 #2
0
    /// <summary>
    /// Damages the player.
    /// </summary>
    /// <param name="hp">[not needed] Hit points</param>
    public void Damage(float hp = 1)
    {
        //if it has temp immunity, do nothing
        if (isTempImmune)
        {
            return;
        }

        --health;

        //activates the event (sounds) and updates hud
        onPlayerDamageEvent?.Raise();
        GameplayScript.SetHpUI(health < 0 ? 0 : health);

        if (health <= 0)
        {
            OnPlayerDeath();
        }
        else
        {
            //if it has health left, call the temp immunity
            coroutine = StartCoroutine(TemporaryImmunity());
        }
    }
コード例 #3
0
 void Start()
 {
     a_Verifier.Init(m_Rigidbody2D, chosenAbility);
     GameplayScript.SetHpUI(health);
 }
コード例 #4
0
 /// <summary>
 /// Adds player a hit point.
 /// </summary>
 public void AddHP()
 {
     ++health;
     GameplayScript.SetHpUI(health);
 }