示例#1
0
    void Update()
    {
        if (Time.frameCount % 30 == 0)
        {
            WadeUtils.CheckForController();
        }

        if (gameState != prevState)
        {
            StartCoroutine(UpdateState());
        }
        else
        {
            modeTime += Time.deltaTime;
        }

        if (gameState == GameState.Menu)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }

            if (Input.anyKeyDown)
            {
                ChangeGameState(GameState.CharacterSelect);
            }
        }
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel(Application.loadedLevel);
        }

        if (gameState == GameState.CharacterSelect)
        {
            if (modeTime > 3f)
            {
                for (int i = 0; i < 8; i++)
                {
                    if (characterSelect.playerInfos[i].joined && characterSelect.IsReadyToPlay() &&
                        characterSelect.playerInfos[i].inputTimer > characterSelect.inputTime &&
                        Input.GetButtonDown("Start" + WadeUtils.platformName))
                    {
                        StartGame();
                    }
                }
            }
        }

        if (gameState == GameState.EndGame)
        {
            if (Input.anyKeyDown)
            {
                ChangeGameState(GameState.Menu);
            }
        }
    }