Esempio n. 1
0
    void GameFSM()
    {
        switch (gameState)
        {
        case GAMESTATES.INIT:
            if (callOnce)
            {
                //
                callOnce = false;
            }
            // -- Put codes that are needed to be called only once -- //
            //Do the setup for the game here.
            b_gameover = false;
            gameScore  = 0;
            UpdateScore(gameScore);
            player.transform.position = restPos;
            hopperState = HOPPERSTATES.IDLE;

            ChangeGameState(GAMESTATES.INGAME);

            //change gamestate after running init once
            break;

        case GAMESTATES.INGAME:
            if (callOnce)
            {
                // -- Put codes that are needed to be called only once -- //
                //
                callOnce = false;
            }
            //Game Loop
            Game();
            break;

        case GAMESTATES.PAUSED:
            if (callOnce)
            {
                // -- Put codes that are needed to be called only once -- //

                EventsManager.OnGamePaused.Invoke();

                //
                callOnce = false;
            }

            break;

        case GAMESTATES.GAMEOVER:
            if (callOnce)
            {
                // -- Put codes that are needed to be called only once -- //
                b_gameover = true;
                Debug.Log("GAME OVER");
                StartCoroutine(GameOver());
                //
                callOnce = false;
            }
            break;
        }
    }
Esempio n. 2
0
 public void ChangeHopperState(HOPPERSTATES state)
 {
     callOnce2   = true;
     hopperState = state;
 }