Update() приватный Метод

private Update ( ) : void
Результат void
Пример #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 || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            timesincelastTick += gameTime.ElapsedGameTime.Milliseconds;

            if (timesincelastTick > MilisecondsperTick && partyTime == true)
            {
                changeBGcolor = true; timesincelastTick -= MilisecondsperTick;
                for (int i = 0; i < 3; i++)
                {
                    balloons.Add(new Balloon(Content, random));
                }

                for (int i = 0; i < 900; i++)
                {
                    conffettis.Add(new conffetti(Content, random));
                }
            }
            if (timesincelastTick > MilisecondsperTick && partyTime == false)
            {
                changeBGcolor = false; timesincelastTick -= MilisecondsperTick;
            }

            inputs.Update();
            // TODO: Add your update logic here
            player.Update(gameTime);


            for (int i = 0; i < balloons.Count; i++)
            {
                balloons[i].Update(gameTime);
                if (balloons[i].isGone == true)
                {
                    balloons.RemoveAt(i);
                }
            }
            for (int i = 0; i < conffettis.Count; i++)
            {
                conffettis[i].Update(gameTime);
                if (conffettis[i].isGone == true)
                {
                    conffettis.RemoveAt(i);
                }
            }
            base.Update(gameTime);
        }
Пример #2
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 || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            InputManager.Update(gameTime);

            gameWorld.Update(gameTime, camera);
            camera.PointTo(gameWorld.player);
            frameCounter.Update(gameTime);

            base.Update(gameTime);
        }
Пример #3
0
 static void UpdateScene()
 {
     while (true)
     {
         if (Scene != null)
         {
             if (Stopwatch.ElapsedMilliseconds > 1)
             {
                 Input.Update();
                 Scene.Update();
                 Stopwatch.Restart();
             }
         }
     }
 }
Пример #4
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)
        {
            // TODO: Add your update logic here

            float fraps = (float)gameTime.ElapsedGameTime.Ticks / 10000000;

            fps += fraps;
            //if (fps >= 1f / 60)
            {
                cursor.Update(gameTime);
                base.Update(gameTime);
                fps -= 1f / 60;
                InputManager.Update();
            }
        }
Пример #5
0
        internal void HandleUpdate(GameTime gameTime)
        {
            GameEngine.gameTime = gameTime.TotalGameTime;
            HandleMouse(Mouse.GetState());
            Input.Update();

            for (int i = 0; i < _maxNumPlayers; ++i)
            {
                HandleGamePad(i);
            }

            HandleKeyboard();
            SetCamera();
            GameEngine.Update();
        }
Пример #6
0
        protected override void Update(GameTime gameTime)
        {
            /*
             * if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
             *  Exit();
             */

            Time.Update(gameTime);
            InputManager.Update();

            exitButton.Update();
            currentScene.Update();

            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            TouchCollection touchLocations = TouchManager.Touches;

            if (touchLocations.Count > 0)
            {
                Debug.WriteLine("ok");
            }

            InputManager.Update();
            Console.WriteLine(InputManager.MouseState.ScrollWheelValue);
            Console.WriteLine(InputManager.MouseState.HorizontalScrollWheelValue);

            base.Update(gameTime);
        }
Пример #8
0
        protected override void OnUpdate(GameTime dt)
        {
            ScreenService s = ((ScreenService)Services.GetService(typeof(ScreenService)));

            s.Update();
            if (game.IsMouseVisible != s.IsMouseVisible)
            {
                game.IsMouseVisible = s.IsMouseVisible;
            }
            InputManager i = ((InputManager)Services.GetService(typeof(InputManager)));

            i.Update();
            i.IsActive = IsActive;
            base.OnUpdate(dt);
        }
Пример #9
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Time.Update(gameTime);
            InputManager.Update();

            if (InputManager.IsKeyPressed(Keys.Space))
            {
                while (!(search.Start = search.Nodes[random.Next(search.Cols), random.Next(search.Rows)]).Passable)
                {
                    ;
                }
                while (!(search.End = search.Nodes[random.Next(search.Cols), random.Next(search.Rows)]).Passable)
                {
                    ;
                }

                search.Search();
                path.Clear();
                AStarNode current = search.End;

                while (current != null)
                {
                    path.Insert(0, current.Position);
                    current = current.Parent;
                }

                /*
                 * search.Start = search.Nodes[random.Next(search.Cols), random.Next(search.Rows)]; // assign a random start node (passable)
                 * search.End = search.Nodes[random.Next(search.Cols), random.Next(search.Rows)]; // assign a random end node (passable)
                 * search.Search();
                 * path.Clear();
                 * AStarNode current = search.End;
                 *
                 * while (current != null)
                 * {
                 *  path.Insert(0, current.Position);
                 *  current = current.Parent;
                 * }
                 */
            }

            base.Update(gameTime);
        }
Пример #10
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Time.Update(gameTime);
            InputManager.Update();

            if (InputManager.IsKeyDown(Keys.W))
            {
                cameraTransform.LocalPosition += cameraTransform.Forward * Time.ElapsedGameTime;
            }
            if (InputManager.IsKeyDown(Keys.S))
            {
                cameraTransform.LocalPosition += cameraTransform.Backward * Time.ElapsedGameTime;
            }
            if (InputManager.IsKeyDown(Keys.A))
            {
                cameraTransform.Rotate(Vector3.Up, Time.ElapsedGameTime);
            }
            if (InputManager.IsKeyDown(Keys.D))
            {
                cameraTransform.Rotate(Vector3.Up, -Time.ElapsedGameTime);
            }
            // ********** Parent Rotation *******************************
            if (InputManager.IsKeyDown(Keys.Up))
            {
                modelTransform.Rotate(Vector3.Up, Time.ElapsedGameTime);
            }
            if (InputManager.IsKeyDown(Keys.Down))
            {
                modelTransform.Rotate(Vector3.Down, Time.ElapsedGameTime);
            }
            if (InputManager.IsKeyDown(Keys.Right))
            {
                model2Transform.LocalPosition += modelTransform.Right * Time.ElapsedGameTime;
            }
            if (InputManager.IsKeyDown(Keys.Left))
            {
                model2Transform.LocalPosition += modelTransform.Left * Time.ElapsedGameTime;
            }

            // **********************************************************

            base.Update(gameTime);
        }
Пример #11
0
    //-----------------------------------------------------------------

    public void Update()
    {
        UI.UpdateFade();
        UI.UpdateUIAnimations();
        UI.Update();

        InputM.Update();

        AudioM.Update();

        if (CurrentState == null)
        {
            return;
        }
        CurrentState.Update();
    }
Пример #12
0
        public void Update(GameTime gameTime)
        {
            Input.Update();
            _currentScreen.Update(gameTime);

            if (_gameManager?.GameEngine?.GameState != null &&
                _gameManager.GameEngine.GameState.Completed)
            {
                CallAction(MenuManager.Action.ShowLevelCompletedScreen, null);
            }
            if (_gameManager?.GameEngine?.GameState != null &&
                _gameManager.GameEngine.GameState.Mode == GameState.State.GameOver)
            {
                CallAction(Action.ShowGameOverScreen, null);
            }
        }
Пример #13
0
        private static bool Update()
        {
            InputManager.Update();

            if (CurrentState == null)
            {
                throw new NullReferenceException(nameof(CurrentState));
            }

            if (InputManager.CheckAction(InputAction.CloseWindow))
            {
                return(false);
            }

            return(CurrentState.Update());
        }
Пример #14
0
        /// <summary>
        /// Reference page contains links to related conceptual articles.
        /// </summary>
        /// <param name="gameTime">Time passed since the last call to Update.</param>
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // we update the Interpolator and Timer providers
            Interpolator.Update((float)gameTime.ElapsedGameTime.TotalSeconds);
            Timer.Update((float)gameTime.ElapsedGameTime.TotalSeconds);

            // Update managers
            _inputManager.Update(gameTime);
            _gameStateManager.Update(gameTime);
            _scriptManager.Update(gameTime);
            _physicsManager.Update(gameTime);

            _fpsCounter.Update(gameTime);
        }
Пример #15
0
 public virtual void RawUpdate(float dt)
 {
     cumulativeDelta += dt * framesPerSecond;
     if (cumulativeDelta > 1f)
     {
         inputManager.Update();
         Update();
         cumulativeDelta -= 1f;
         if (cumulativeDelta >= 1f)
         {
             cumulativeDelta = 0f;
         }
     }
     framesSinceStart += 1;
     DrawUpdate(cumulativeDelta);
 }
        /// <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 || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            InputManager.Update();

            // TODO: Add your update logic here
            overworld.Update(gameTime);

            camera.Update();

            base.Update(gameTime);
        }
Пример #17
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)
        {
            InputManager.Update();
            simpleFps.Update(gameTime);
            Window.Title = simpleFps.msg;

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            SceneManager.ActiveScene.Update(gameTime.ElapsedGameTime.TotalMilliseconds);

            base.Update(gameTime);
        }
 // Update is called once per frame
 void Update()
 {
     waitTime -= Time.deltaTime;
     if (waitTime < 0)
     {
         if (!continueField.activeSelf)
         {
             continueField.SetActive(true);
         }
         inputManager.Update();
         if (inputManager.Direction() != Vector2.zero || inputManager.Shooting)
         {
             GameManager.SetScene(1);
         }
     }
 }
Пример #19
0
        protected override void Update(GameTime gameTime)
        {
            if (GameManager.CurrentRound != null)
            {
                foreach (Updatable obj in GameManager.CurrentRound)
                {
                    obj.Update();
                }
            }

            UiManager.Update();
            InputManager.Update();
            GameManager.Update();

            base.Update(gameTime);
        }
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Time.Update(gameTime);
            InputManager.Update();

            solTransform.Rotate(Vector3.Forward, Time.ElapsedGameTime);
            earthTransform.Rotate(Vector3.Backward, Time.ElapsedGameTime * 2);


            base.Update(gameTime);
        }
Пример #21
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 || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            World.Step(1 / 60.0f);

            InputManager.Update(gameTime);
            b.Computer.Step();
            TimerManager.Update(gameTime);
            currentScreen.Update(gameTime);

            base.Update(gameTime);
        }
Пример #22
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            _input.Update(gameTime, Keyboard.GetState());

            _world.Update(gameTime);

            _camera.Update(gameTime);


            base.Update(gameTime);
        }
Пример #23
0
    void Update()
    {
        InputManager.Update();

        // Use last device which provided input.
        var inputDevice = InputManager.ActiveDevice;

        // Set target object material color based on which action is pressed.
        if (inputDevice.Action1)
        {
            target.renderer.material.color = Color.green;
        }
        else
        if (inputDevice.Action2)
        {
            target.renderer.material.color = Color.red;
        }
        else
        if (inputDevice.Action3)
        {
            target.renderer.material.color = Color.blue;
        }
        else
        if (inputDevice.Action4)
        {
            target.renderer.material.color = Color.yellow;
        }
        else
        {
            target.renderer.material.color = Color.white;
        }

        // Rotate target object with both sticks and d-pad.
        target.transform.Rotate(Vector3.down, 500.0f * Time.deltaTime * inputDevice.Direction.x, Space.World);
        target.transform.Rotate(Vector3.right, 500.0f * Time.deltaTime * inputDevice.Direction.y, Space.World);
        target.transform.Rotate(Vector3.down, 500.0f * Time.deltaTime * inputDevice.RightStickX, Space.World);
        target.transform.Rotate(Vector3.right, 500.0f * Time.deltaTime * inputDevice.RightStickY, Space.World);

        // Zoom target object with scroll wheel.
        var z = inputDevice.GetControl(InputControlType.ScrollWheel);

        targetPosition.z          = Mathf.Clamp(targetPosition.z + z, -10.0f, 25.0f);
        target.transform.position = Vector3.MoveTowards(target.transform.position, targetPosition, Time.deltaTime * 25.0f);

        // Only supported on Windows with XInput and Xbox 360 controllers.
        InputManager.ActiveDevice.Vibrate(inputDevice.LeftTrigger, inputDevice.RightTrigger);
    }
Пример #24
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 (InputManager.IsKeyDown(Keys.Up))
            {
                player.Clip      = 0;
                playerDirection  = -Vector2.UnitY;
                player.Position += Vector2.UnitY * -5;
                player.Update();
            }

            else if (InputManager.IsKeyDown(Keys.Down))
            {
                player.Clip      = 1;
                playerDirection  = Vector2.UnitY;
                player.Position += Vector2.UnitY * 5;
                player.Update();
            }

            else if (InputManager.IsKeyDown(Keys.Left))
            {
                player.Clip      = 2;
                playerDirection  = Vector2.UnitX;
                player.Position += Vector2.UnitX * -5;
                player.Update();
            }

            else if (InputManager.IsKeyDown(Keys.Right))
            {
                player.Clip      = 3;
                playerDirection  = Vector2.UnitX;
                player.Position += Vector2.UnitX * 5;
                player.Update();
            }



            timeLeft      = timeLeft - Time.ElapsedGameTime;
            timeBar.Value = timeLeft / 90f;
            timeBar.Update();
            distanceWalked++;
            distanceBar.Value = distanceWalked / 1000f;
            distanceBar.Update();

            Time.Update(gameTime);
            InputManager.Update();
            base.Update(gameTime);
        }
Пример #25
0
        /// <summary>
        /// Allows each screen to run logic.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            // Read the keyboard and gamepad.
            _inputManager.Update();

            // Make a copy of the master screen list, to avoid confusion if
            // the process of updating one screen adds or removes others.
            _screensToUpdate.Clear();

            foreach (GameScreen screen in _screens)
            {
                _screensToUpdate.Add(screen);
            }

            bool otherScreenHasFocus  = !Game.IsActive;
            bool coveredByOtherScreen = false;

            // Loop as long as there are screens waiting to be updated.
            while (_screensToUpdate.Count > 0)
            {
                // Pop the topmost screen off the waiting list.
                GameScreen screen = _screensToUpdate[_screensToUpdate.Count - 1];

                _screensToUpdate.RemoveAt(_screensToUpdate.Count - 1);

                // Update the screen.
                screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

                if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active)
                {
                    // If this is the first active screen we came across,
                    // give it a chance to handle input.
                    if (!otherScreenHasFocus)
                    {
                        screen.HandleInput(gameTime);
                        otherScreenHasFocus = true;
                    }

                    // If this is an active non-popup, inform any subsequent
                    // screens that they are covered by it.
                    if (!screen.IsPopup)
                    {
                        coveredByOtherScreen = true;
                    }
                }
            }
        }
Пример #26
0
 protected override void Update(GameTime gameTime)
 {
     if (stop)
     {
         Exit();
     }
     InputManager.Update(CanvasScale);
     GlobalTime.Update(gameTime);
     GlobalTime.ChangeSpeed(GameSpeed);
     SceneManager.UpdateScenes();
     ParticleManager.UpdateParticles();
     if (Convert.ToBoolean(ConfigManager.GetValue("enable_sky")))
     {
         sky.Update();
     }
     base.Update(gameTime);
 }
Пример #27
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 (Keyboard.GetState().IsKeyDown(Keys.Escape) && _lastState.IsKeyUp(Keys.Escape) || InputManager.IsButtonPressed(Buttons.Back, PlayerIndex.One))
            {
                ScreenManager.Instance.HandleBackEvent();
            }

            #region Debug
            if (Keyboard.GetState().IsKeyDown(Keys.F11) && _lastState.IsKeyUp(Keys.F11))
            {
                _graphics.ToggleFullScreen();
            }
            _lastState = Keyboard.GetState();
            #endregion
            base.Update(gameTime);
            InputManager.Update(); // Must be called after base. (This updates InputManager._LastStates)
        }
Пример #28
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Time.Update(gameTime);
            InputManager.Update();

            foreach (Rigidbody rigidbody in rigidbodies)
            {
                rigidbody.Update();
            }

            Vector3 normal; // it is updated if a collision happens

            for (int i = 0; i < transforms.Count; i++)
            {
                if (boxCollider.Collides(colliders[i], out normal))
                {
                    numberCollisions++;
                    if (Vector3.Dot(normal, rigidbodies[i].Velocity) < 0)
                    {
                        rigidbodies[i].Impulse +=
                            Vector3.Dot(normal, rigidbodies[i].Velocity) * -2 * normal;
                    }
                }

                for (int j = i + 1; j < transforms.Count; j++)
                {
                    if (colliders[i].Collides(colliders[j], out normal))
                    {
                        numberCollisions++;
                    }

                    Vector3 velocityNormal = Vector3.Dot(normal,
                                                         rigidbodies[i].Velocity - rigidbodies[j].Velocity) * -2
                                             * normal * rigidbodies[i].Mass * rigidbodies[j].Mass;
                    rigidbodies[i].Impulse += velocityNormal / 2;
                    rigidbodies[j].Impulse += -velocityNormal / 2;
                }
            }

            base.Update(gameTime);
        }
Пример #29
0
        protected override void Update(GameTime gameTime)
        {
            inputManager.Update(gameTime);
            if (inputManager.IsExit)
            {
                Exit();
            }

            var deltaTimes = GetDeltaTimes(gameTime);

            if (Config.DebugMode)
            {
                _debugOverlay.Update(deltaTimes);
            }
            state?.Update(deltaTimes);
            base.Update(gameTime);
        }
Пример #30
0
        protected override void Update(GameTime gameTime)
        {
            if (Quit)
            {
                NetworkClient.Shutdown();
                Exit();
            }

            // TODO: Add your update logic here
            InputManager.Update();
            WindowManager.Update(gameTime);


            NetworkClient.CheckConnection(gameTime);

            base.Update(gameTime);
        }