Esempio n. 1
0
    void Update()
    {
        //Debug.Log(currentState);
        int keyNum = -1;

        switch (currentState)
        {
        case GameState.TutorialScreen:
            objectSpawner.pauseGame();
            FirstRow.text  = "Tutorial";
            SecondRow.text = "Press any button to continue";
            if (Input.anyKeyDown)
            {
                setupNextScenario(0f);
            }
            break;

        case GameState.TutorialRunning:
            keyNum = checkKeyPressed();
            if (keyNum > 0)
            {
                highlightInputUI(keyNum);
                if (tutorials [tutorialCounter] [keyNum - 1].isMostDangerous)
                {
                    tutorialCounter++;
                    if (tutorialCounter >= tutorialNum)
                    {
                        currentState = GameState.RadarSceen;
                        switchRadar();
                    }
                    else
                    {
                        currentState = GameState.TransitionScreen;
                        switchRadar(true);
                    }
                }
                else
                {
                    currentState = GameState.TryAgain;
                }
            }
            break;

        case GameState.RadarSceen:
            showGUI();
            objectSpawner.pauseGame();
            FirstRow.text  = "Radar " + (radarCounter + 1);
            SecondRow.text = "Press any button to continue";
            if (Input.anyKeyDown)
            {
                if (!loadingScenario)
                {
                    setupNextScenario(0f);
                }
            }
            break;

        case GameState.ScenarioRunning:
            keyNum = checkKeyPressed();
            if (keyNum > 0)
            {
                highlightInputUI(keyNum);
                objectSpawner.pauseGame();
                currentScenarioData.radar        = currentRadar;
                currentScenarioData.scenario     = indexMap[scenarioCounter];
                currentScenarioData.reactionTime = objectSpawner.getReactionTime();
                currentScenarioData.jetPicked    = keyNum;
                if (scenarios[scenarioCounter][keyNum - 1].isMostDangerous)
                {
                    currentScenarioData.isCorrect = true;
                }
                else
                {
                    currentScenarioData.isCorrect = false;
                }
                saveData();
                scenarioCounter++;
                currentState = GameState.TransitionScreen;
            }
            break;

        case GameState.TransitionScreen:
            if (scenarioCounter >= scenarioNum)
            {
                scenarioCounter = 0;
                radarCounter++;
                if (radarCounter >= radarNum)
                {
                    currentState = GameState.Finished;
                }
                else
                {
                    switchRadar();
                    currentState = GameState.RadarSceen;
                }
            }
            else
            {
                showGUI();
                objectSpawner.pauseGame();
                FirstRow.text  = "Good job!";
                SecondRow.text = "Next Scenario Loading";
                if (!loadingScenario)
                {
                    setupNextScenario(transitionTime);
                }
            }
            break;

        case GameState.TryAgain:
            showGUI();
            objectSpawner.pauseGame();
            FirstRow.text  = "Sorry wrong answer";
            SecondRow.text = "Try Again";
            if (!loadingScenario)
            {
                setupNextScenario(transitionTime);
            }
            break;

        case GameState.Finished:
            showGUI();
            objectSpawner.pauseGame();
            FirstRow.text  = "Finished";
            SecondRow.text = "Thank you!";
            if (Input.GetKeyDown(KeyCode.Return))
            {
                resetGame();
            }
            break;
        }
    }