예제 #1
0
    /// <summary>
    /// Decrease the unit's current health.
    /// </summary>
    /// <param name="decrease"> The amount to decrease the unit's health by. </param>
    public void DecreaseCurrentHealth()
    {
        ParticlesManager.m_Instance.RemoveUnitFromTarget();

        int damage = (int)m_DealingDamage + m_TakeExtraDamage;


        m_Healthbar.m_KeepFocus = false;
        SetCurrentHealth(m_CurrentHealth - damage);
        m_TakeExtraDamage = 0;

        if (m_PassiveSkill != null)
        {
            if (m_PassiveSkill.CheckPrecondition(TriggerType.OnTakeDamage, this))
            {
                if (m_PassiveSkill.GetAffectSelf() == true)
                {
                    m_PassiveSkill.TakeEffect(this);
                }
                else
                {
                    m_PassiveSkill.TakeEffect();
                }
            }
            if (m_PassiveSkill.CheckPrecondition(TriggerType.OnTakeDamage))
            {
                if (m_PassiveSkill.GetAffectSelf() == true)
                {
                    m_PassiveSkill.TakeEffect(this);
                }
                else
                {
                    m_PassiveSkill.TakeEffect();
                }
            }
        }

        foreach (InflictableStatus status in m_StatusEffects)
        {
            if (status.CheckPrecondition(TriggerType.OnTakeDamage) == true)
            {
                status.TakeEffect(this);
            }
        }

        if (m_Healthbar != null)
        {
            m_Healthbar.m_HealthChangeIndicator.text = "-" + damage;
            m_HealthChangeIndicatorScript.HealthDecrease();
        }
    }