/// <summary> /// Update the content. /// </summary> /// <returns>The update.</returns> /// <param name="gameTime">Game time.</param> public override void Update(GameTime gameTime) { Dictionary <string, int> troops = new Dictionary <string, int>(); game.GetUnits().ToList().ForEach(u => troops.Add(u.Name, game.GetArmy(game.PlayerFactionId, u.Id).Size)); recruitmentDialog.Location = new Point2D(GameMap.Location.X + (GameMap.Size.Width - recruitmentDialog.Size.Width) / 2, GameMap.Location.Y + (GameMap.Size.Height - recruitmentDialog.Size.Height) / 2); buildDialog.Location = new Point2D(GameMap.Location.X + (GameMap.Size.Width - buildDialog.Size.Width) / 2, GameMap.Location.Y + (GameMap.Size.Height - buildDialog.Size.Height) / 2); InfoBar.Provinces = game.GetFactionProvinces(game.PlayerFactionId).Count(); InfoBar.Holdings = game.GetFactionHoldings(game.PlayerFactionId).Count(); InfoBar.Wealth = game.GetFaction(game.PlayerFactionId).Wealth; InfoBar.Troops = troops; if (!string.IsNullOrEmpty(GameMap.SelectedProvinceId)) { ProvinceBar.SetProvince(GameMap.SelectedProvinceId); } SideBar.FactionId = game.PlayerFactionId; base.Update(gameTime); }
/// <summary> /// Loads the content. /// </summary> public override void LoadContent() { string initialWorldId = "narivia"; string initialFactionId = "f_alpalet"; if (ScreenArgs != null && ScreenArgs.Length >= 2) { initialWorldId = ScreenArgs[0]; initialFactionId = ScreenArgs[1]; } recruitmentDialog = new GuiRecruitmentDialog { Size = new Size2D(256, 288) }; buildDialog = new GuiBuildingDialog { Size = new Size2D(256, 224) }; recruitmentDialog.Hide(); buildDialog.Hide(); game = new GameManager(); game.NewGame(initialWorldId, initialFactionId); troopsOld = new Dictionary <string, int>(); relationsOld = new Dictionary <string, int>(); game.GetUnits().ToList().ForEach(u => troopsOld.Add(u.Name, game.GetArmy(game.PlayerFactionId, u.Id).Size)); game.GetFactionRelations(game.PlayerFactionId).ToList().ForEach(r => relationsOld.Add(r.TargetFactionId, r.Value)); GameMap.AssociateGameManager(ref game); ProvinceBar.AssociateGameManager(ref game); SideBar.AssociateGameManager(ref game); recruitmentDialog.AssociateGameManager(ref game); buildDialog.AssociateGameManager(ref game); SideBar.FactionId = game.PlayerFactionId; GuiManager.Instance.GuiElements.Add(GameMap); GuiManager.Instance.GuiElements.Add(InfoBar); GuiManager.Instance.GuiElements.Add(ProvinceBar); GuiManager.Instance.GuiElements.Add(SideBar); GuiManager.Instance.GuiElements.Add(NotificationBar); GuiManager.Instance.GuiElements.Add(recruitmentDialog); GuiManager.Instance.GuiElements.Add(buildDialog); base.LoadContent(); string factionName = game.GetFaction(game.PlayerFactionId).Name; ShowNotification($"Welcome to {game.GetWorld().Name}", $"The era of peace has ended! Old rivalries remerged, and a global war broke out." + Environment.NewLine + $"Conquer the world in the name of {factionName}, and secure its place in the golden pages of history!", NotificationType.Informational, NotificationStyle.Big, new Size2D(256, 256)); ProvinceBar.SetProvince(game.GetFactionCapital(game.PlayerFactionId).Id); LinkEvents(); GameMap.CentreCameraOnLocation(game.GetFactionCentreX(game.PlayerFactionId), game.GetFactionCentreY(game.PlayerFactionId)); }