Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            Destroy(other.gameObject);
            Destroy(this.gameObject);
        }

        if (other.CompareTag("MKOneTurret"))
        {
            MKOneTurret mkOneTurret = other.GetComponent <MKOneTurret>();

            if (mkOneTurret != null)
            {
                mkOneTurret.Damage(20);
            }
            Destroy(this.gameObject);
        }

        if (other.CompareTag("MKFourTurret"))
        {
            MKFourTurret mkFourTurret = other.GetComponent <MKFourTurret>();

            if (mkFourTurret != null)
            {
                mkFourTurret.Damage(15);
            }
            Destroy(this.gameObject);
        }

        if (other.CompareTag("MainGunTurret"))
        {
            MainGunTurret mainGunTurret = other.GetComponent <MainGunTurret>();

            if (mainGunTurret != null)
            {
                mainGunTurret.Damage(10);
            }
            Destroy(this.gameObject);
        }
    }
Beispiel #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player" && _isEnemyLaser == true)
        {
            Player player = other.GetComponent <Player>();

            if (player != null)
            {
                player.Damage();
            }

            Destroy(this.gameObject);
        }

        if (other.CompareTag("Enemy") && _isEnemyLaser == false)
        {
            Enemy enemy = other.GetComponent <Enemy>();

            if (enemy != null)
            {
                enemy.Damage();
            }

            Destroy(gameObject);
        }

        if (other.tag == "Powerup" && _isEnemyLaser == true)
        {
            Destroy(this.gameObject);
            Destroy(other.gameObject);
        }

        if (other.CompareTag("MKOneTurret"))
        {
            MKOneTurret mkOneTurret = other.GetComponent <MKOneTurret>();

            if (mkOneTurret != null)
            {
                mkOneTurret.Damage(5);
            }

            Destroy(this.gameObject);
        }

        if (other.CompareTag("MKFourTurret"))
        {
            MKFourTurret mkFourTurret = other.GetComponent <MKFourTurret>();

            if (mkFourTurret != null)
            {
                mkFourTurret.Damage(3);
            }

            Destroy(this.gameObject);
        }

        if (other.CompareTag("MainGunTurret"))
        {
            MainGunTurret mainGunTurret = other.GetComponent <MainGunTurret>();

            if (mainGunTurret != null)
            {
                mainGunTurret.Damage(2);
            }

            Destroy(this.gameObject);
        }

        if (other.CompareTag("BossShipMainFrame"))
        {
            MainFrame mainFrame = other.GetComponent <MainFrame>();

            if (mainFrame != null)
            {
                mainFrame.Damage(5);
            }

            Destroy(this.gameObject);
        }
    }