示例#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();
            }
            foreach (var module in modules)
            {
                module.NotifyTick(gameTime);
            }

            if (inputManager.EnableFastForward)
            {
                DateTime startFastForward = DateTime.UtcNow;
                // Target 60 fps per second
                while ((DateTime.UtcNow - startFastForward).TotalSeconds < 0.015f)
                {
                    foreach (var module in modules)
                    {
                        if (module.WantsFastForward)
                        {
                            module.NotifyTick(gameTime);
                        }
                    }
                }
            }

            // Save progress every minute
            if ((DateTime.UtcNow - lastSerializationTime).TotalSeconds > 10)
            {
                lastSerializationTime = DateTime.UtcNow;
                tileMap.SerializeToFile("tilemap.dat");
                creatureManager.Serialize("creatures.dat");
            }



            base.Update(gameTime);
        }