Esempio n. 1
0
    void Update()
    {
        switch (currentState)
        {
        case State.INITIAL:
            //make sure game ready to start go asking state
            IK.gameObject.SetActive(true);
            gameOverPannel.SetActive(false);
            PLAYER.StartPlayer(PLAYER.getSelectedDifficulty());
            ZoneObjects = CreateObjectList(PLAYER.getSelectedZone());
            UpdateRemainLife();
            Invoke("PlayZoneMusic", 0.2f);
            currentState = State.ASKING;
            break;

        case State.ASKING:
            //get object from pool and call newGuess function and go guessing state
            Invoke("pushNewGuess", 0.8f);
            currentState = State.GUESSING;
            break;

        case State.GUESSING:
            if (IK.isPressedAnyKey())
            {
                Guesster.SearchLetter(IK.GetPressedKey());
                UpdateRemainLife();
            }
            if (Guesster.succesfulGuess)
            {
                Guesster.succesfulGuess = false;
                //TODO check for is it working
                ZoneObjects.Remove(Guesster.GetLastGivenGameObject());
                currentState = State.NEXT_WORD;
                break;
            }

            //check life count and if die go game over pannel if guess succes go next word state
            if (PLAYER.AmIDead())
            {
                currentState = State.GAME_OVER;
            }

            break;

        case State.NEXT_WORD:
            //make sure is there object in pool and if it go ask if go game over state
            if (ZoneObjects.Any())
            {
                currentState = State.ASKING;
            }
            else
            {
                currentState = State.GAME_OVER;
            }
            break;

        case State.GAME_OVER:
            IK.gameObject.SetActive(false);
            gameOverPannel.SetActive(true);
            if (PLAYER.GetRemainingLife() > 0)
            {
                gameOverTxt.text = "YOU WIN \n total word guessed : " +
                                   PLAYER.GetSuccesfulGueesCount() +
                                   " \n wrong gues :" + PLAYER.GetWrongGuessCount();
            }
            else
            {
                gameOverTxt.text = "YOU LOSE \n total word guessed : " +
                                   PLAYER.GetSuccesfulGueesCount() +
                                   " \n wrong gues :" + PLAYER.GetWrongGuessCount();
            }
            break;
        }
    }