Esempio n. 1
0
    void Blast()
    {
        anim.SetTrigger("Blast");
        LayerMask layerMask = LayerMask.GetMask("Player", "Enemy");

        Collider2D[] objectInRadius = Physics2D.OverlapCircleAll(transform.position, blastRadius, layerMask);


        foreach (Collider2D objectI in objectInRadius)
        {
            if (objectI.gameObject == gameObject)
            {
                continue; //пойдет на следующую итерацию цикла
            }

            Zombie zombie = objectI.GetComponent <Zombie>();
            if (zombie != null)
            {
                zombie.DoDamage(blastDamage);
                continue;
            }

            Enemy enemy = objectI.GetComponent <Enemy>();
            if (enemy != null)
            {
                enemy.DoDamage(blastDamage);
                continue;
            }

            Barrel barrel = objectI.GetComponent <Barrel>();
            if (barrel != null)
            {
                barrel.DoDamage(blastDamage);
                continue;
            }

            Player player = objectI.GetComponent <Player>();

            if (player != null)
            {
                player.DoDamage(blastDamage);
            }
        }
    }