예제 #1
0
        /// <summary>
        /// Called every frame
        /// </summary>
        /// <param name="gameTime">The current time</param>
        public void Update(DwarfTime gameTime)
        {
            EntityFactory.DoLazyActions();
            if (FastForwardToDay)
            {
                if (Time.IsDay())
                {
                    FastForwardToDay = false;
                    foreach (CreatureAI minion in Master.Faction.Minions)
                    {
                        minion.Status.Energy.CurrentValue = minion.Status.Energy.MaxValue;
                    }
                    //Master.ToolBar.SpeedButton.SetSpeed(1);
                    Time.Speed = 100;
                }
                else
                {
                    //Master.ToolBar.SpeedButton.SetSpecialSpeed(3);
                    Time.Speed = 1000;
                }
            }

            //Drawer3D.DrawPlane(0, Camera.Position.X - 1500, Camera.Position.Z - 1500, Camera.Position.X + 1500, Camera.Position.Z + 1500, Color.Black);
            FillClosestLights(gameTime);
            IndicatorManager.Update(gameTime);
            AspectRatio        = GraphicsDevice.Viewport.AspectRatio;
            Camera.AspectRatio = AspectRatio;

            Camera.Update(gameTime, ChunkManager);
            HandleAmbientSound();

            Master.Update(Game, gameTime);
            GoalManager.Update(this);
            Time.Update(gameTime);

            if (Paused)
            {
                ComponentManager.UpdatePaused();
            }
            // If not paused, we want to just update the rest of the game.
            else
            {
                TutorialManager.Update(Gui);

                GamePerformance.Instance.StartTrackPerformance("Diplomacy");
                Diplomacy.Update(gameTime, Time.CurrentDate, this);
                GamePerformance.Instance.StopTrackPerformance("Diplomacy");

                GamePerformance.Instance.StartTrackPerformance("Factions");
                Factions.Update(gameTime);
                GamePerformance.Instance.StopTrackPerformance("Factions");

                GamePerformance.Instance.StartTrackPerformance("Components");
                ComponentManager.Update(gameTime, ChunkManager, Camera);
                GamePerformance.Instance.StopTrackPerformance("Components");

                Sky.TimeOfDay = Time.GetSkyLightness();

                Sky.CosTime             = (float)(Time.GetTotalHours() * 2 * Math.PI / 24.0f);
                DefaultShader.TimeOfDay = Sky.TimeOfDay;

                GamePerformance.Instance.StartTrackPerformance("Monster Spawner");
                MonsterSpawner.Update(gameTime);
                GamePerformance.Instance.StopTrackPerformance("Monster Spawner");

                GamePerformance.Instance.StartTrackPerformance("All Asleep");
                bool allAsleep = Master.AreAllEmployeesAsleep();
#if !UPTIME_TEST
                if (SleepPrompt == null && allAsleep && !FastForwardToDay && Time.IsNight())
                {
                    SleepPrompt = Gui.ConstructWidget(new Gui.Widgets.Confirm
                    {
                        Text       = "All of your employees are asleep. Skip to daytime?",
                        OkayText   = "Skip to Daytime",
                        CancelText = "Don't Skip",
                        OnClose    = (sender) =>
                        {
                            if ((sender as Confirm).DialogResult == Confirm.Result.OKAY)
                            {
                                FastForwardToDay = true;
                            }
                        }
                    });
                    Gui.ShowModalPopup(SleepPrompt);
                }
                else if (!allAsleep)
                {
                    if (SleepPrompt != null)
                    {
                        SleepPrompt.Close();
                    }
                    Time.Speed       = 100;
                    FastForwardToDay = false;
                    SleepPrompt      = null;
                }
#endif
                GamePerformance.Instance.StopTrackPerformance("All Asleep");
            }

            // These things are updated even when the game is paused

            GamePerformance.Instance.StartTrackPerformance("Chunk Manager");
            ChunkManager.Update(gameTime, Camera, GraphicsDevice);
            ChunkRenderer.Update(gameTime, Camera, GraphicsDevice);
            GamePerformance.Instance.StopTrackPerformance("Chunk Manager");

            GamePerformance.Instance.StartTrackPerformance("Sound Manager");
            SoundManager.Update(gameTime, Camera, Time);
            GamePerformance.Instance.StopTrackPerformance("Sound Manager");

            GamePerformance.Instance.StartTrackPerformance("Weather");
            Weather.Update(this.Time.CurrentDate, this);
            GamePerformance.Instance.StopTrackPerformance("Weather");

            if (gameFile != null)
            {
                // Cleanup game file.
                gameFile = null;
            }
        }