Пример #1
0
    public void SetGameState(string state)
    {
        switch (state)
        {
        case "demo":     //Demo Code
            Cursor.visible      = true;
            Cursor.lockState    = CursorLockMode.Confined;
            gameMode            = "demo";
            inGame              = true;
            isVSAI              = true;
            isHighscoreEditMode = false;
            for (int i = 0; i < players.Count; i++)
            {
                players[i].aI = true;
                players[i].UpdatePlayerType();
            }
            disc.GetComponent <Disc>().ResetDisc(false);
            player1ScoreUI.gameObject.SetActive(true);
            player2ScoreUI.gameObject.SetActive(true);
            timerUI.gameObject.SetActive(true);
            disablePausing = false;
            ToggleCamera("Demo Camera");
            gameTimer.ResetTimer(true, matchTime);
            gameTimer.SetClockState(true);
            break;

        case "sp":     //Single Player Code
            Cursor.visible      = false;
            Cursor.lockState    = CursorLockMode.Locked;
            gameMode            = "sp";
            inGame              = true;
            isVSAI              = true;
            isHighscoreEditMode = true;
            players[0].aI       = false;
            players[0].UpdatePlayerType();
            players[1].aI = true;
            players[1].UpdatePlayerType();
            disc.GetComponent <Disc>().ResetDisc(true);
            player1ScoreUI.gameObject.SetActive(true);
            player2ScoreUI.gameObject.SetActive(true);
            timerUI.gameObject.SetActive(true);
            disablePausing = false;
            ToggleCamera("SP Camera");
            gameTimer.ResetTimer(true, matchTime);
            gameTimer.SetClockState(true);
            break;

        case "mp":     //Multiplayer Code
            Cursor.visible      = false;
            Cursor.lockState    = CursorLockMode.Locked;
            gameMode            = "mp";
            inGame              = true;
            isVSAI              = false;
            isHighscoreEditMode = true;
            for (int i = 0; i < players.Count; i++)
            {
                players[i].aI = false;
                players[i].UpdatePlayerType();
            }
            disc.GetComponent <Disc>().ResetDisc(true);
            player1ScoreUI.gameObject.SetActive(true);
            player2ScoreUI.gameObject.SetActive(true);
            timerUI.gameObject.SetActive(true);
            disablePausing = false;
            ToggleCamera("MP Camera");
            gameTimer.ResetTimer(true, matchTime);
            gameTimer.SetClockState(true);
            break;

        case "menu":
            Cursor.visible      = true;
            Cursor.lockState    = CursorLockMode.Confined;
            gameMode            = "menu";
            inGame              = false;
            isVSAI              = false;
            isHighscoreEditMode = false;
            gameTimer.ResetTimer(false, 0.0f);
            replayController.ResetReplayState();
            disc.GetComponent <Disc>().ResetDisc(false);
            player1ScoreUI.gameObject.SetActive(false);
            player2ScoreUI.gameObject.SetActive(false);
            timerUI.gameObject.SetActive(false);
            for (int i = 0; i < players.Count; i++)
            {
                players[i].aI         = true;
                players[i].aiResponse = Random.Range(0.50f, 0.85f);
                players[i].UpdatePlayerType();
            }
            disablePausing = true;
            ToggleCamera("Demo Camera");
            gameTimer.SetClockState(true);
            if (noticeShown)
            {
                mainMenu.SetActive(true);
            }
            else
            {
                EnableMenu(noticeMenu);
                noticeShown = true;
            }
            break;

        case "highscorePrompt":
            if (gameMode != "demo")
            {
                Cursor.visible   = true;
                Cursor.lockState = CursorLockMode.Confined;
                gameMode         = "menu";
                inGame           = false;
                replayController.ResetReplayState();
                player1ScoreUI.gameObject.SetActive(false);
                player2ScoreUI.gameObject.SetActive(false);
                timerUI.gameObject.SetActive(false);
                PauseGame(true, false, false);
                disablePausing = true;
                EnableMenu(highscorePrompt.gameObject);
            }
            else
            {
                SetGameState("menu");
            }
            break;

        case "results":
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.Confined;
            gameMode         = "menu";
            inGame           = false;
            replayController.ResetReplayState();
            player1ScoreUI.gameObject.SetActive(false);
            player2ScoreUI.gameObject.SetActive(false);
            timerUI.gameObject.SetActive(false);
            PauseGame(true, false, false);
            disablePausing = true;
            EnableMenu(resultsScreen);
            break;

        default:
            Debug.LogError("Incorrect usage! Use \"demo\" for demo mode; \"sp\" for single player mode;  \"mp\" for multiplayer mode; and \"menu\" for Menu Mode.");
            break;
        }
    }