예제 #1
0
        /// <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));
        }