コード例 #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.ToGameTime());
            if (Generator.CurrentState == WorldGenerator.GenerationState.Finished)
            {
                Preview.Update();
            }
            base.Update(gameTime);

            Preview.PreparePreview(StateManager.Game.GraphicsDevice);
        }
コード例 #2
0
ファイル: TutorialViewState.cs プロジェクト: Rod995/dwarfcorp
        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);
        }
コード例 #3
0
ファイル: FactionViewState.cs プロジェクト: Rod995/dwarfcorp
 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);
 }
コード例 #4
0
ファイル: GameState.cs プロジェクト: polytronicgr/dwarfcorp
        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);
        }
コード例 #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();
        }
コード例 #6
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.ToGameTime());

            base.Update(gameTime);
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: GuiDebugState.cs プロジェクト: Rod995/dwarfcorp
        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);
        }
コード例 #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.ToGameTime());
            base.Update(gameTime);
        }
コード例 #10
0
 public override void Update(DwarfTime gameTime)
 {
     foreach (var @event in DwarfGame.GumInputMapper.GetInputQueue())
     {
         GuiRoot.HandleInput(@event.Message, @event.Args);
         if ([email protected])
         {
             if (@event.Args.KeyValue > 0)
             {
                 DialogueContext.Skip();
             }
             // Pass event to game...
         }
     }
     SoundManager.Update(gameTime, World.Camera, World.Time);
     GuiRoot.Update(gameTime.ToGameTime());
     DialogueContext.Update(gameTime);
     World.TutorialManager.Update(GuiRoot);
     World.Paused  = true;
     IsInitialized = true;
     base.OnEnter();
 }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: LoadState.cs プロジェクト: sodomon2/dwarfcorp
        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);
        }
コード例 #14
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;

                if (PreviewOffset >= Items.Count && Items.Count > 0) // We're looking at an empty last page...
                {
                    PreviewOffset -= Grid.ItemsThatFit;
                }

                // Keep from selecting empty squares on final, incomplete page.
                var pageSize = System.Math.Min(Items.Count - PreviewOffset, Grid.ItemsThatFit);
                if (ItemSelected >= pageSize)
                {
                    ItemSelected = pageSize - 1;
                }

                var totalPages = (int)System.Math.Ceiling((float)Items.Count / (float)Grid.ItemsThatFit);
                Grid.Text = String.Format("Page {0} of {1}", (int)System.Math.Ceiling((float)PreviewOffset / (float)Grid.ItemsThatFit), totalPages);

                PrevButton.Hidden   = PreviewOffset == 0;
                NextButton.Hidden   = (PreviewOffset + Grid.ItemsThatFit >= Items.Count);
                DeleteButton.Hidden = Items.Count == 0;
                LoadButton.Hidden   = Items.Count == 0;

                for (var i = 0; i < Grid.Children.Count; ++i)
                {
                    var square = Grid.GetChild(i);
                    if (i < pageSize)
                    {
                        square.Hidden          = false;
                        square.BackgroundColor = new Vector4(1, 1, 1, 1);
                        if (i == ItemSelected)
                        {
                            square.BackgroundColor = new Vector4(1, 0, 0, 1);
                        }
                    }
                    else
                    {
                        square.Hidden = true;
                    }
                    square.Invalidate();
                }

                if (Items.Count > 0)
                {
                    var directoryTime = System.IO.Directory.GetLastWriteTime(Items[PreviewOffset + ItemSelected].Path);

                    BottomBar.Text = Items[PreviewOffset + ItemSelected].Path;

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

            GuiRoot.Update(gameTime.ToGameTime());
            base.Update(gameTime);
        }