コード例 #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();
            }

            // TODO: Add your update logic here
            HandleInput();

            if (map.MapReload)
            {
                map.ReloadMap();
                map.UpdateMapViewport(gameplayArea);
                tank.Reset();
                pathFinder.Reset();
            }

            if (pathFinder.SearchStatus == SearchStatusEnum.PathFound && !tank.Moving)
            {
                foreach (Point point in pathFinder.FinalPath())
                {
                    tank.Waypoints.Enqueue(map.MapToWorld(point, true));
                }
                tank.Moving = true;
            }
            pathFinder.Update(gameTime);
            tank.Update(gameTime);

            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)
        {
            HandleInput();

            if (map.MapReload)
            {
                map.ReloadMap();
                map.UpdateMapViewport(gameplayArea);
                tank.Reset();
                pathFinder.Reset();
            }

            if (pathFinder.SearchStatus == SearchStatus.PathFound && !tank.Moving)
            {
                foreach (Point point in pathFinder.FinalPath())
                {
                    tank.Waypoints.Enqueue(map.MapToWorld(point, true));
                }
                tank.Moving = true;
            }
            pathFinder.Update(gameTime);
            tank.Update(gameTime);
            base.Update(gameTime);
        }