示例#1
0
    // Stuff done once if you enter a state
    void OnStateEntering()
    {
        switch (GameState ()) {
        case State.Intro:
            player.CmdKillAllBalls();
            introBackground.SetActive(true);
            this._introTimePassed = 0.0f;
            if (useOVR)
            {
                this.ovrCam.transform.position = introOVRCamPosition;
            }
            else
            {
                SwitchCamera(this.introCam);
            }
            if (startFading == true)
                startFading = false;
            if (fadeOutStarted == true)
                fadeOutStarted = false;
            if (introAlmostDone == true)
                introAlmostDone = false;
            if (introIsDone == true)
                introIsDone = false;

            //if (introText) {
            //	introText.SetActive (true);
            //	MovingText text = introText.GetComponent<MovingText> ();
            //	text.Reset ();
            //}
            //Debug.Log("EnterIntro");

            break;

        case State.Fight:

            var playerObj = GameObject.FindWithTag ("Player");
            this.player = playerObj.GetComponent<PlayerManager> ();
            if (!hasSpawnedObjects) {
                player.CmdSpawnObjects ();
                hasSpawnedObjects = true;
            } /*else {
                player.CmdSpawnBalls();
            }*/
            player.CmdKillAllBalls();
            ballsSpawned = 0;
            player.CmdSpawnBalls();
            ballsSpawned = 1;
            if (useOVR) {
                this.ovrCam.transform.position = fightOVRCamPosition;
            }
            this.score = 0;
            this.timeRemaining = 60.0f;

            this.scoreText.text = "Score: 0";
            this.timeText.text = "Time left: 10";
            this.highScoreText.text = "HighScore: " + this.highScore;
            if (useOVR) {
                SwitchCamera (this.ovrCam);
            } else {
                SwitchCamera (this.mainCam);
            }

            break;

        case State.Win:
            player.CmdKillAllBalls();
            this.winText.SetActive (true);
            break;

        case State.Loose:

            // What todo if the player looses.

            break;

        case State.NetworkSetup:
            this._networkSetupTimePassed = 0.0f;
            Debug.Log ("Press H to start Host, press C (or wait) to start Client.");
            break;
        case State.Spectating:
            freeLookCameraRig.SetActive (true);
            SwitchCamera (this.specCam);
            break;
        }
    }