Exemplo n.º 1
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            GenerationProgress.Text       = Generator.LoadingMessage;
            GenerationProgress.Percentage = Generator.Progress * 100.0f;

            // Enable or disable start button based on Generator state.

            GuiRoot.Update(gameTime.ToRealTime());
            if (Generator.CurrentState == WorldGenerator.GenerationState.Finished)
            {
                Preview.Update();
            }
            base.Update(gameTime);

            Preview.PreparePreview(StateManager.Game.GraphicsDevice);
        }
Exemplo n.º 2
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            GuiRoot.Update(gameTime.ToRealTime());
            base.Update(gameTime);
        }
Exemplo n.º 3
0
 public override void Update(DwarfTime gameTime)
 {
     World.Tutorial("diplomacy");
     foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
     {
         GuiRoot.HandleInput(@event.Message, @event.Args);
         if ([email protected])
         {
             // Pass event to game...
         }
     }
     World.TutorialManager.Update(GuiRoot);
     GuiRoot.Update(gameTime.ToRealTime());
     base.Update(gameTime);
 }
Exemplo n.º 4
0
        public override void Update(DwarfTime gameTime)
        {
            if (!Game.IsActive)
            {
                return;
            }
            GuiRoot.Update(gameTime.ToRealTime());
            DwarfGame.GumInput.FireActions(GuiRoot, null);
            if (!WaitThread.IsAlive && Object.ReferenceEquals(StateManager.CurrentState, this) && !Done)
            {
                StateManager.PopState();
                Done = true;
            }

            base.Update(gameTime);
        }
Exemplo n.º 5
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
            }
            GuiRoot.Update(gameTime.ToRealTime());
            World.TutorialManager.Update(GuiRoot);

            if (TradePanel.Result == Gui.Widgets.TradeDialogResult.Pending)
            {
                return;
            }

            StateManager.PopState();
        }
Exemplo n.º 6
0
        public override void Update(DwarfTime gameTime)
        {
            if (!Game.IsActive)
            {
                return;
            }

            GuiRoot.Update(gameTime.ToRealTime());
            DwarfGame.GumInput.FireActions(GuiRoot, null);
            if (!WaitThread.IsAlive && !Done)
            {
                GameStateManager.PopState();
                Done = true;
            }

            base.Update(gameTime);
        }
Exemplo n.º 7
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            SpriteFrame.AnimationPlayer.Update(gameTime, false, Timer.TimerMode.Real);
            SpriteFrame.Sprite.Update(StateManager.Game.GraphicsDevice);
            GuiRoot.Update(gameTime.ToRealTime());

            base.Update(gameTime);
        }
Exemplo n.º 8
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            Progress.Percentage = (float)gameTime.TotalGameTime.TotalSeconds / 10.0f;
            Progress.Percentage = Progress.Percentage - (float)Math.Floor(Progress.Percentage);

            GuiRoot.Update(gameTime.ToRealTime());

            base.Update(gameTime);
        }
Exemplo n.º 9
0
        public override void Update(DwarfTime gameTime)
        {
            World.Tutorial("economy");

            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }
            SoundManager.Update(gameTime, World.Camera, World.Time);
            World.TutorialManager.Update(GuiRoot);

            //TabPanel.GetTabButton(1).IndicatorValue = World.GoalManager.NewAvailableGoals;
            //TabPanel.GetTabButton(3).IndicatorValue = World.GoalManager.NewCompletedGoals;

            GuiRoot.Update(gameTime.ToRealTime());
            base.Update(gameTime);
        }
Exemplo n.º 10
0
        public override void Update(DwarfTime gameTime)
        {
            if (DoneLoading)
            {
                // Todo: Decouple gui/input from world.
                // Copy important bits to PlayState - This is a hack; decouple world from gui and input instead.
                PlayState.Input = Input;
                StateManager.PopState(false);
                StateManager.PushState(new PlayState(Game, StateManager, World));

                World.OnSetLoadingMessage = null;
                Overworld.NativeFactions  = World.Natives;
            }
            else
            {
                if (Settings.GenerateFromScratch && Generator.CurrentState == WorldGenerator.GenerationState.Finished && World == null)
                {
                    Settings = Generator.Settings;
                    CreateWorld();
                }
                else if (Settings.GenerateFromScratch)
                {
                    if (!LoadTicker.HasMesssage(Generator.LoadingMessage))
                    {
                        LoadTicker.AddMessage(Generator.LoadingMessage);
                    }
                }

                foreach (var item in DwarfGame.GumInputMapper.GetInputQueue())
                {
                    GuiRoot.HandleInput(item.Message, item.Args);
                    if (item.Message == Gui.InputEvents.KeyPress)
                    {
                        Runner.Jump();
                    }
                }

                GuiRoot.Update(gameTime.ToRealTime());
                Runner.Update(gameTime);

                if (World != null && World.LoadStatus == WorldManager.LoadingStatus.Failure && !DisplayException)
                {
                    DisplayException = true;
                    string exceptionText = World.LoadingException == null
                        ? "Unknown exception."
                        : World.LoadingException.ToString();
                    GuiRoot.MouseVisible        = true;
                    GuiRoot.MousePointer        = new Gui.MousePointer("mouse", 4, 0);
                    DwarfTime.LastTime.IsPaused = false;
                    DwarfTime.LastTime.Speed    = 1.0f;
                    World = null;

                    GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm()
                    {
                        CancelText = "",
                        Text       = "Oh no! Loading failed :( This crash has been automatically reported to Completely Fair Games: " + exceptionText,
                        OnClick    = (s, a) =>
                        {
                            StateManager.PopState();
                            StateManager.ClearState();
                            StateManager.PushState(new MainMenuState(Game, StateManager));
                        },
                        OnClose = (s) =>
                        {
                            StateManager.PopState();
                            StateManager.ClearState();
                            StateManager.PushState(new MainMenuState(Game, StateManager));
                        },
                        Rect = GuiRoot.RenderData.VirtualScreen
                    });
                }
            }

            base.Update(gameTime);
        }
Exemplo n.º 11
0
        public override void Update(DwarfTime gameTime)
        {
            foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
            {
                GuiRoot.HandleInput(@event.Message, @event.Args);
                if ([email protected])
                {
                    // Pass event to game...
                }
            }

            if (NeedsRefresh)
            {
                NeedsRefresh = false;
                Grid.ClearItems();
                int i = 0;
                foreach (var item in Items)
                {
                    var itemWidget = new ChooserWidget
                    {
                        Item            = item,
                        Background      = new TileReference("basic", 0),
                        BackgroundColor = i % 2 == 0 ? new Vector4(0, 0, 0, 0.1f) : new Vector4(0, 0, 0, 0.2f)
                    };

                    Grid.AddItem(itemWidget);

                    itemWidget.DeleteButton.OnClick = (sender, args) =>
                    {
                        var confirm = GuiRoot.ConstructWidget(new Gui.Widgets.Confirm
                        {
                            OkayText   = "Delete",
                            CancelText = "Keep",
                            Text       = "Are you sure you want to delete this?",
                            OnClose    = (s) =>
                            {
                                if ((s as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                                {
                                    var selectedItem = itemWidget.Item;
                                    Items.Remove(selectedItem);
                                    try
                                    {
                                        global::System.IO.Directory.Delete(selectedItem.Path, true);
                                    }
                                    catch (Exception e)
                                    {
                                        GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm()
                                        {
                                            OkayText   = "Ok",
                                            CancelText = "",
                                            Text       = e.Message
                                        });
                                    }
                                    NeedsRefresh = true;
                                }
                            }
                        });
                        GuiRoot.ShowModalPopup(confirm);
                    };

                    if (itemWidget.LoadButton != null)
                    {
                        itemWidget.LoadButton.OnClick = (sender, args) =>
                        {
                            if (String.IsNullOrEmpty(itemWidget.Item.Valid) && OnProceedClicked != null)
                            {
                                OnProceedClicked(itemWidget.Item.Path);
                            }
                        }
                    }
                    ;

                    i++;
                }

                Grid.OnSelectedIndexChanged = (widget) =>
                {
                    this.ItemSelected = Grid.SelectedIndex;
                    NeedsRefresh      = true;
                };
                if (Grid.SelectedIndex > Items.Count - 1 || Grid.SelectedIndex < 0)
                {
                    Grid.SelectedIndex = 0;
                }
                ItemSelected = Grid.SelectedIndex;
                if (Items.Count > 0)
                {
                    DateTime directoryTime;
                    try
                    {
                        directoryTime = global::System.IO.File.GetLastWriteTime(Items[ItemSelected].Path + System.IO.Path.DirectorySeparatorChar + "meta.txt");
                    }
                    catch (Exception)
                    {
                        directoryTime = DateTime.MinValue;
                    }

                    BottomBar.Text = Items[ItemSelected].Path;

                    if (!String.IsNullOrEmpty(Items[ItemSelected].Valid))
                    {
                        BottomBar.Text += "\n" + Items[ItemSelected].Valid;
                    }
                    else
                    {
                        BottomBar.Text += "\n" + directoryTime.ToShortDateString() + " " + directoryTime.ToShortTimeString();
                    }
                }
                else
                {
                    BottomBar.Text = NoItemsText;
                }
            }

            GuiRoot.Update(gameTime.ToRealTime());
            base.Update(gameTime);
        }
Exemplo n.º 12
0
        public override void Update(DwarfTime gameTime)
        {
            if (DoneLoading)
            {
                // Todo: Decouple gui/input from world.
                // Copy important bits to PlayState - This is a hack; decouple world from gui and input instead.
                PlayState.Input = Input;
                GameStateManager.PopState(false);
                GameStateManager.PushState(new PlayState(Game, World));

                World.OnSetLoadingMessage = null;
            }
            else
            {
                if (LoadType == LoadTypes.GenerateOverworld)
                {
                    if (Generator.CurrentState == OverworldGenerator.GenerationState.Finished && World == null)
                    {
                        // World generation is finished!
                        LoadTicker.AddMessage("Checking spawn position...");
                        while (InitialCell.Bounds.Width == 8 && InitialCell.Bounds.Height == 8 && !IsGoodSpawn())
                        {
                            LoadTicker.AddMessage("Selecting new spawn...");
                            InitialCell = Settings.ColonyCells.EnumerateCells().Where(c => c.Bounds.Width == 8 && c.Bounds.Height == 8).SelectRandom();
                        }

                        CreateWorld();
                    }
                    else
                    {
                        if (!LoadTicker.HasMesssage(Generator.LoadingMessage))
                        {
                            LoadTicker.AddMessage(Generator.LoadingMessage);
                        }
                    }
                }

                foreach (var item in DwarfGame.GumInputMapper.GetInputQueue())
                {
                    GuiRoot.HandleInput(item.Message, item.Args);
                    if (item.Message == Gui.InputEvents.KeyPress)
                    {
                        Runner.Jump();
                    }
                }

                GuiRoot.Update(gameTime.ToRealTime());
                Runner.Update(gameTime);

                if (World != null && World.LoadStatus == WorldManager.LoadingStatus.Failure && !DisplayException)
                {
                    DisplayException = true;
                    string exceptionText = World.LoadingException == null
                        ? "Unknown exception."
                        : World.LoadingException.ToString();
                    GuiRoot.MouseVisible        = true;
                    GuiRoot.MousePointer        = new Gui.MousePointer("mouse", 4, 0);
                    DwarfTime.LastTime.IsPaused = false;
                    DwarfTime.LastTime.Speed    = 1.0f;
                    World = null;
                    DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed.", SharpRaven.Data.BreadcrumbLevel.Error);
                    GuiRoot.ShowModalPopup(new Gui.Widgets.Confirm()
                    {
                        CancelText = "",
                        Text       = "Oh no! Loading failed :( This crash has been automatically reported to the developers: " + exceptionText,
                        OnClick    = (s, a) =>
                        {
                            DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed. Player going back to start.");
                            GameStateManager.ClearState();
                        },
                        OnClose = (s) =>
                        {
                            DwarfGame.LogSentryBreadcrumb("Loading", "Loading failed. Player going back to start.");
                            GameStateManager.ClearState();
                        },
                        Rect = GuiRoot.RenderData.VirtualScreen
                    });
                }
            }

            base.Update(gameTime);
        }