示例#1
0
    private void SetDamages(int p_Damages)
    {
        Collider[] l_HitCollider = Physics.OverlapSphere(transform.position, m_Radius, m_Layer);
        foreach (var item in l_HitCollider)
        {
            if (item.GetComponent <Enemy>() != null)
            {
                m_Enemy = item.GetComponent <Enemy>();
                m_Enemy.TakeDamages(p_Damages);
                Destroy(gameObject);
            }

            if (item.GetComponent <HealthPlayer>() != null)
            {
                m_PlayerLife = item.GetComponent <HealthPlayer>();
                m_PlayerLife.TakesDamages(p_Damages);
                Destroy(gameObject);
            }

            Debug.Log("j'ai touché : " + item.gameObject.name);
        }
    }