Exemple #1
0
    void Damage4(Transform enemy3)
    {
        Enemy4 e = enemy3.GetComponent <Enemy4>();

        if (e != null)
        {
            e.TakeDamage(BulletDamage);
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy enemy = hitInfo.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy2 enemy2 = hitInfo.GetComponent <Enemy2>();

        if (enemy2 != null)
        {
            enemy2.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy3 enemy3 = hitInfo.GetComponent <Enemy3>();

        if (enemy3 != null)
        {
            enemy3.TakeDamage(damage);
            Destroy(gameObject);
        }

        Enemy4 enemy4 = hitInfo.GetComponent <Enemy4>();

        if (enemy4 != null)
        {
            enemy4.TakeDamage(damage);
            Destroy(gameObject);
        }

        Boss1 boss1 = hitInfo.GetComponent <Boss1>();

        if (boss1 != null)
        {
            boss1.TakeDamage(damage);
            Destroy(gameObject);
        }

        Boss2 boss2 = hitInfo.GetComponent <Boss2>();

        if (boss2 != null)
        {
            boss2.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.GetComponent <AreaCamera>() == null &&
            collider.GetComponent <Player>() == null) // Não é uma câmera nem o Player
        {
            Enemy1 enemy1 = collider.GetComponent <Enemy1>();
            Enemy2 enemy2 = collider.GetComponent <Enemy2>();
            Enemy3 enemy3 = collider.GetComponent <Enemy3>();
            Enemy4 enemy4 = collider.GetComponent <Enemy4>();
            Boss   boss   = collider.GetComponent <Boss>();
            if (enemy1 != null) // É um inimigo
            {
                enemy1.TakeDamage(bulletDamage);
            }
            else if (enemy2 != null)
            {
                enemy2.TakeDamage(bulletDamage);
            }
            else if (enemy3 != null)
            {
                enemy3.TakeDamage(bulletDamage);
            }
            else if (enemy4 != null)
            {
                enemy4.TakeDamage(bulletDamage);
            }
            else if (boss != null)
            {
                boss.TakeDamage(bulletDamage);
            }

            Destroy(gameObject);

            Instantiate(impactEffect, transform.position, transform.rotation);
        }
    }