Esempio n. 1
0
    /// <summary>
    /// Functon that is called via SendMessage by the proyectiles when they hit you
    /// </summary>
    /// <param name="damage">The amount of damage deal by the attack</param>
    void OnHit(int damage)
    {
        lifePoint = Mathf.Clamp(LifePoints - damage, 0, startingLife);
        //Debug.Log("Damage recieved, Life:" + lifePoint);
        if (lifePoint == 0)
        {
            onLethalDamage();
        }

        //Report damage to the UI
        SendMessage("UpdateHpValue", lifePoint);


        if (CurrentState != PlayerStates.usingChip && CurrentState != PlayerStates.takingDamage && CurrentState != PlayerStates.dead)
        {
            //Chip use and Damage are unstapable animation
            animationController.PlayDamageAnimation();
            //and tell it to play the corresponding animation
        }
    }