SceneController.Update C# (CSharp) Méthode

Update() public méthode

public Update ( ) : void
Résultat void
    void Update()
    {
        if (!fading) {
            //false = fading in, true = fading out
            if (score1.color.a > 0) {
                SetTransparency(score1.color.a - Time.deltaTime);
            } else {
                if (score1.color.a != 0) SetTransparency(0);
            }
        } else {
            if (score1.color.a < 1) {
                SetTransparency(score1.color.a + Time.deltaTime);
            } else {
                if (score1.color.a != 1) SetTransparency(1);
            }
        }
        if (readyToStart && !countDown && startTimer <= 0) {

            startTimer = timeBeforeRoundStart;
            countDown = true;

            cameraThing.SendMessage("SetTracking",false);
        }
        if (countDown) {
            if (startTimer > 0) {
                startTimer -= Time.deltaTime;
                if (startTimer < 0) startTimer = 0;
                string newText = "" + (startTimer+1);
                if (newText.Length >= 4) newText = newText.Substring(0, 1);
                countDownText.text = newText;
                countDownBackground.gameObject.SetActive(true);
                if (startTimer > timeBeforeRoundStart/2)
                {
                    fading = false;
                    //hide scoreboard fade out
                }
                else if (startTimer > (3*timeBeforeRoundStart) / 4) {
                    //not tracking, get a glimpse of the map here
                    cameraThing.SendMessage("SetTracking",false);

                } else {
                    cameraThing.SendMessage("SetTracking",true);
                }
            } else {
                //Begin!!!
                countDownText.text = "";
                countDownBackground.gameObject.SetActive(false);

                for (int i = 0; i < playerCount; i++) {
                    players[i].SendMessage("EnablePlayers");
                }
                GameObject.Find("MouseInput").SendMessage("EnablePlayers");
                countDown = false;
                transitioning = false;
                readyToStart = false;
            }

        }
        if (IsRoundOver()) {
            if (!endScene && !transitioning) {
                endScene = true;
                endTimer = timeBeforeRoundEnd;
            }
            endTimer -= Time.deltaTime;
            //print("done here");
            if (endTimer < timeBeforeRoundEnd-timeForPointsAwarded && !transitioning && !pointYet) {
                foreach (GameObject g in players) {
                    player ps = g.GetComponent<player>();
                    if (!ps.death) {
                        AkSoundEngine.PostEvent("Victory", gameObject);
                        print("Counting one point for Player " + ps.playerid);
                        playerScores[ps.playerid - 1] += 1;
                        /*if (ps.playerid == 1) {
                            score1.text = "Score: " + playerScores[ps.playerid - 1];
                        }
                        else if (ps.playerid == 2) {
                            score2.text = "Score: " + playerScores[ps.playerid - 1];
                        }
                        else if (ps.playerid == 3) {
                            score3.text = "Score: " + playerScores[ps.playerid - 1];
                        }
                        else if (ps.playerid == 4) {
                            score4.text = "Score: " + playerScores[ps.playerid - 1];
                        }*/
                    }
                }
                //print("Counting one point for Player ");
                pointYet = true;
            }
            if (endTimer < (timeBeforeRoundEnd-timeForPointsAwarded)/2 && !transitioning)
            {
                //show scoreboard fade in
            }
            if (endTimer <= 0 && !transitioning) {
                //print();
                pointYet = false;
                transitioning = true;
                endScene = false;
                endTimer = 0;
                int newIndex = Random.Range(0, 7);
                if (newIndex >= currentMapIndex) newIndex++; // so we don't go to the same place as currently
                StartCoroutine(StartNewScene());
                currentMapIndex = newIndex;

                score1.text = "Score: " + playerScores[0];
                score2.text = "Score: " + playerScores[1];
                score3.text = "Score: " + playerScores[2];
                score4.text = "Score: " + playerScores[3];

                return;

            }
        }
        if (Input.GetKeyDown(KeyCode.Backspace) && gameover)  RestartNewGame();
    }

Usage Example

Exemple #1
0
        static void Main()
        {
            DX.ChangeWindowMode( DX.TRUE );
            DX.SetGraphMode(1600, 900, 32);

            if ( DX.DxLib_Init() == -1 )
            {
                return;
            }

            DX.SetDrawScreen(DX.DX_SCREEN_BACK);

            Scene scene = new TestScene();

            SceneController sc = new SceneController(scene);

            while (DX.ProcessMessage() == 0 && DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 0)
            {
                DX.ClearDrawScreen();

                sc.Update();

                DX.ScreenFlip();
            }

            DX.DxLib_End();

            return;
        }
All Usage Examples Of SceneController::Update