Ejemplo n.º 1
0
    void Update()
    {
        switch (switchMenu)
        {
        case 1:
            _hasStarted = false;
            _hasEnded   = true;
            _firstGo    = false;
            switch (currentLevel)
            {
            case 1:
                _level1.LateDestroy();
                break;

            case 2:
                _level2.LateDestroy();
                break;

            case 3:
                _level3.LateDestroy();
                break;
            }
            _instructions.LateDestroy();
            _hud.LateDestroy();
            showGameOver();
            break;

        case 2:
            showMenu();
            _gameOver.LateDestroy();
            _menuBack.Play();
            _hasEnded  = false;
            switchMenu = 0;
            playerID   = 0;
            break;

        case 3:
            if (_firstGo)
            {
                AddChild(_instructions);

                if (Input.GetMouseButtonUp(0))
                {
                    if (_instructions.HitTestPoint(Input.mouseX, Input.mouseY))
                    {
                        _hasStarted = true;
                        startLevel1();
                        if (_hasEnded == true)
                        {
                            _gameOver.LateDestroy();
                            _hasEnded = false;
                        }
                    }
                }
            }
            else
            {
                _hasStarted = true;
                startLevel1();
                if (_hasEnded == true)
                {
                    _gameOver.LateDestroy();
                    _hasEnded = false;
                }
            }
            break;


        case 4:
            _hasStarted = true;
            startLevel2();
            if (_hasEnded == true)
            {
                _gameOver.LateDestroy();
                _hasEnded = false;
            }
            break;

        case 5:
            _hasStarted = true;
            startLevel3();
            if (_hasEnded == true)
            {
                _gameOver.LateDestroy();
                _hasEnded = false;
            }
            break;
        }

        //-------------------------------------------------
        //              Button press check
        //--------------------------------------------------

        if (Input.GetMouseButtonUp(0))
        {
            if (_startButton.HitTestPoint(Input.mouseX, Input.mouseY))
            {
                switchMenu = 3;
            }

            if (_exitButton.HitTestPoint(Input.mouseX, Input.mouseY))
            {
                exitGame();
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
        }
    }