Update() private method

private Update ( ) : void
return void
Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            if (MediaPlayer.State == MediaState.Stopped)
            {
                MediaPlayer.Play(song);
            }

            if (collisionDetectionSystem.CollisionOccured)
            {
                if (count <= 0)
                {
                    ResetGame();
                    count = 5;
                }
                count -= gameTime.ElapsedGameTime.TotalSeconds;
            }
            else
            {
                // TODO: Add your update logic here
                collisionDetectionSystem.Update(gameTime);
                physicsSystem.Update(gameTime);
                spawnSystem.Update(gameTime);
                inputSystem.Update(gameTime);
                scoreSystem.Update(gameTime);
            }


            base.Update(gameTime);
        }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (initialBlanks != null && startPoint == null && pgInstance.blankCount <= initialBlanks)
        {
            startPoint    = pgInstance.LoadedPrefabs.Last.Value.obj;
            initialBlanks = null;
        }
        else if (startPoint != null)
        {
            GlobalScript.WorldSpeed = bmInstance.maxSpeed;
        }
        else if (initialBlanks == null && introInitiated == false)
        {
            if (deceleratioThreshold == null)
            {
                deceleratioThreshold = Time.time + timeToDecelerate;
            }

            GlobalScript.WorldSpeed = Mathf.Lerp(bmInstance.maxSpeed, GlobalScript.DefaultWorldSpeed, Time.time / (float)deceleratioThreshold);

            if (GlobalScript.WorldSpeed <= GlobalScript.DefaultWorldSpeed)
            {
                introInitiated = true;
            }
        }
        else if (introInitiated == true)
        {
            scoreSys.Update();
        }


        for (int i = 0; i < 10; ++i)
        {
            if (scoreSys.Score > highScores[i])
            {
                if (i <= 0)
                {
                    nextHS.text = "New record for Santa Kind!: " + (int)scoreSys.Score + " KM";
                }
                else
                {
                    nextHS.text = highScores[i - 1] + " KM";
                }

                break;
            }
            else
            {
                nextHS.text = highScores[9] + " KM";
            }
        }
    }