예제 #1
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.GetComponent <EntityStats>())
        {
            if (col.gameObject.GetComponent <EntityStats>() != m_Stats)
            {
                //Can only deal damage to non-friendly entities
                if (m_Stats.gameObject.tag != col.gameObject.tag)
                {
                    //Deal damage
                    col.gameObject.GetComponent <EntityStats>().ChangeHealth(-m_Stats.GetDamage());

                    //Apply knockback
                    if (col.gameObject.GetComponent <EntityStats>().GetCanBeKnockedback())
                    {
                        Vector3 force = (col.gameObject.transform.position - m_Stats.gameObject.transform.position).normalized * m_Stats.GetKnockbackForce();
                        col.gameObject.GetComponent <Rigidbody>().AddForce(force, ForceMode.Impulse);
                    }
                }
            }
        }
    }
예제 #2
0
 public int GetBonusDamage()
 {
     return((int)((m_Stats.GetDamage() + m_CarrotBonusDMG) * m_CarrotBonusMulti));
 }