Ejemplo n.º 1
0
    void Damage()
    {
        Collider2D[] enemyColList = new Collider2D[5];
        int          enemyNum     = attackTrigger.OverlapCollider(enemyFilter, enemyColList);

        if (enemyNum > 0)
        {
            for (int i = 0; i < enemyNum; i++)
            {
                if (enemyColList[i].GetComponent <Enemy_Dead>().isDead == true)
                {
                    continue;
                }

                Enemy_base enemy_Base = enemyColList[i].GetComponent <Enemy_base>();
                enemy_Base.TakeDamage(1);
                enemy_Base.KnockBack(PlayerControl.facingRight ? Vector3.right : Vector3.left, 100f);
            }
        }

        Collider2D[] atkObjColList = new Collider2D[5];
        int          ObjCount      = attackTrigger.OverlapCollider(canAtkObjFilter, atkObjColList);

        if (ObjCount > 0)
        {
            for (int i = 0; i < ObjCount; i++)
            {
                atkObjColList[i].GetComponent <CanAtkObj>().TakeDamage(1);
            }
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 public void Awake()
 {
     animator   = transform.GetComponentInParent <Animator>();
     enemy_base = transform.GetComponentInParent <Enemy_base>();
 }