Example #1
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Barrier")
        {
            Destroy(gameObject);
        }

        if (col.gameObject.tag == "Rock")
        {
            Rock _rock = col.gameObject.GetComponent <Rock>();
            if (_rock != null)
            {
                _rock.TakeDamage();
                Destroy(gameObject);
            }
        }

        if (col.gameObject.tag == "Alien")
        {
            AlienController _alienController = col.gameObject.GetComponent <AlienController>();
            if (_alienController != null)
            {
                _alienController.Die();
                IncreaseScore(10);
                Destroy(gameObject);
            }
        }

        if (col.gameObject.tag == "Boss")
        {
            BossController _bossController = col.gameObject.GetComponent <BossController>();
            if (_bossController != null)
            {
                _bossController.TakeDamage();
                IncreaseScore(5);
                Destroy(gameObject);
            }
        }

        if (col.gameObject.tag == "Ship")
        {
            MotherShip _motherShip = col.gameObject.GetComponent <MotherShip>();
            if (_motherShip != null)
            {
                _motherShip.Die();
                AudioManager.audioManager.PlaySound("Ship Hit");

                ShipSpawnStart _shipSpawner = GameObject.FindObjectOfType <ShipSpawnStart>();
                _shipSpawner.canWeSpawn = true;
                _shipSpawner.CreateNewSpawnRate();

                IncreaseScore(50);
                Destroy(gameObject);
            }
        }
    }
Example #2
0
    private void GameOver()
    {
        motherShip.Die();

        FindObjectOfType <PlayerMove>().enabled  = false;
        FindObjectOfType <PlayerShoot>().enabled = false;

        UIManager.instance.ShowGameOver("Score: " + _totalscore.ToString("000000000"));

        Asteroid[] astros = GameObject.FindObjectsOfType <Asteroid>();
        foreach (Asteroid a in astros)
        {
            a.Die();
        }

        _GameState = state.end;
    }