Example #1
0
    void Damage3(Transform enemy3)
    {
        Enemy3 e = enemy3.GetComponent <Enemy3>();

        if (e != null)
        {
            e.TakeDamage(BulletDamage);
        }
    }
Example #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);
        }
    }
Example #3
0
    void Shoot()
    {
        muzzleFlash.Play();


        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            Enemy  enemy  = hit.transform.GetComponent <Enemy>();
            Enemy2 enemy2 = hit.transform.GetComponent <Enemy2>();
            Enemy3 enemy3 = hit.transform.GetComponent <Enemy3>();

            if (enemy != null)
            {
                enemy.TakeDamage(damage);
                GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(impactGO, 1f);
            }

            if (enemy2 != null)
            {
                enemy2.TakeDamage(damage);
                GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(impactGO, 1f);
            }

            if (enemy3 != null)
            {
                enemy3.TakeDamage(damage2);
                GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
                Destroy(impactGO, 1f);
            }

            GameObject impactGO2 = Instantiate(impactEffect2, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO2, 0.1f);
        }
    }
Example #4
0
    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.GetComponent <AreaCamera>() == null &&
            collider.CompareTag("Water") == false) // Não é uma câmera nem água
        {
            Debug.Log("Bullet hit " + collider.name);

            Enemy1 enemy1 = collider.GetComponent <Enemy1>();
            Enemy2 enemy2 = collider.GetComponent <Enemy2>();
            Enemy3 enemy3 = collider.GetComponent <Enemy3>();
            Boss   boss   = collider.GetComponent <Boss>();
            Player player = collider.GetComponent <Player>();
            if (enemy1 != null) // É um inimigo
            {
                enemy1.TakeDamage(bulletDamage);
            }
            else if (enemy2 != null)
            {
                enemy2.TakeDamage(bulletDamage);
            }
            else if (boss != null)
            {
                boss.TakeDamage(bulletDamage);
            }
            else if (enemy3 != null)
            {
                enemy3.TakeDamage(bulletDamage);
            }
            else if (player != null)
            {
                player.TakeDamage(bulletDamage);
            }

            Destroy(gameObject);

            Instantiate(impactEffect, transform.position, transform.rotation);
        }
    }
Example #5
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);
        }
    }