예제 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        int           who = 1;
        StrikeControl obj = collision.GetComponent <StrikeControl>();

        if (obj != null)
        {
            who = obj.who;
        }
        if (who == 1)
        {
            if (lives > 0)
            {
                lives--;
                gControl.LiveControl(lives);
                Destroy(collision.gameObject);
            }
            else
            {
                gControl.GameOver();
                Destroy(this.gameObject);
                Destroy(collision.gameObject);
            }
        }
    }
예제 #2
0
    private void ClearGameZone()
    {
        shipSpeedVector = new Vector3(0, 0, 0);

        if (spaceShip != null)
        {
            Destroy(spaceShip.gameObject);
        }

        foreach (Transform t in sceneObjects.GetComponentInChildren <Transform>())
        {
            Asteroid aster = t.gameObject.GetComponent <Asteroid>();
            if (aster != null)
            {
                Destroy(aster.gameObject);
            }
            else
            {
                StrikeControl sControl = t.gameObject.GetComponent <StrikeControl>();
                if (sControl != null)
                {
                    Destroy(sControl.gameObject);
                }
                else
                {
                    Alien alien = t.gameObject.GetComponent <Alien>();
                    if (alien != null)
                    {
                        Destroy(alien.gameObject);
                    }
                }
            }
        }
    }