コード例 #1
0
        /// <summary>
        /// Gets the <see cref="McKnight.Similization.Server.City"/>, and if necessary,
        /// the <see cref="McKnight.Similization.Server.DiplomaticTie"/> from the user.
        /// </summary>
        protected virtual void SelectCity(string cityPickerTitle)
        {
            ClientApplication ca = ClientApplication.Instance;

            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("espionageTiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    ties.Add(t);
                }
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.tie = picker.DiplomaticTie;

            ICityPicker cityPicker = (ICityPicker)ca.GetControl(typeof(ICityPicker));

            cityPicker.PickerTitle = cityPickerTitle;
            cityPicker.InitializePicker(this.DiplomaticTie.ForeignCountry);
            cityPicker.ShowSimilizationControl();
            this.city = cityPicker.City;
        }
コード例 #2
0
 private static string GetAdvisorText(Country parent, Country foreign)
 {
     if (foreign == null)
     {
         //there's no foreign country, so the advisor will have to offer
         //other advice.
         return(ClientResources.GetString("militaryAdvisor_needUnits"));
     }
     else
     {
         //we can talk about anything.
         return(GetMilitaryComparisonString(parent, foreign));
     }
 }
コード例 #3
0
        private static string GetCountryHeaderText(Country country)
        {
            if (country == null)
            {
                return(string.Empty);
            }

            string s         = ClientResources.GetString(StringKey.MilitaryAdvisorCountryHeader);
            string adjective = country.Civilization.Adjective;
            string gov       = country.Government.Name;
            string text      = string.Format(CultureInfo.InvariantCulture, s, adjective, gov);

            return(text);
        }
コード例 #4
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication    ca     = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.ShowSimilizationControl();
            DiplomaticTie tie = picker.DiplomaticTie;

            if (tie == null)
            {
                OnCanceled();
                return;
            }
            ICityPicker cityPicker = (ICityPicker)ca.GetControl(typeof(ICityPicker));

            cityPicker.PickerTitle = ClientResources.GetString("investigateCity_cityPickerTitle");
            cityPicker.ShowSimilizationControl();
            City city = cityPicker.City;

            if (city == null)
            {
                OnCanceled();
                return;
            }
            bool   success = tie.InvestigateCity(city);
            string text    = string.Empty;

            if (success)
            {
                text = ClientResources.GetString("investigateCity_success");
                text = string.Format(CultureInfo.CurrentCulture, text, city.Name);
                ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
                ICityControl cityControl = (ICityControl)ca.GetControl(typeof(ICityControl));
                cityControl.Editable = false;
                cityControl.City     = city;
                cityControl.ShowSimilizationControl();
            }
            else
            {
                text = ClientResources.GetString("investigateCity_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    tie.ForeignCountry.Civilization.Adjective);
                ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            }
            OnInvoked();
        }
コード例 #5
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication client = ClientApplication.Instance;
            ILoadGameWindow   window = (ILoadGameWindow)client.GetControl(typeof(ILoadGameWindow));

            window.ShowSimilizationControl();
            if (window.LoadedGameFile == null || window.LoadedGameFile.Length == 0)
            {
                OnCanceled();
                return;
            }
            client.Console.WriteLine(string.Format(CultureInfo.InvariantCulture, ClientResources.GetString("item_loading"), window.LoadedGameFile));
            client.ServerInstance.LoadGame(window.LoadedGameFile);
            client.Console.WriteLine(ClientResources.GetString("game_loaded"));
            OnInvoked();
        }
コード例 #6
0
        /// <summary>
        /// Invokes the Command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            string cityPickerTitle = ClientResources.GetString("propaganda_cityPickerTitle");

            SelectCity(cityPickerTitle);
            if (this.City == null)
            {
                OnCanceled();
                return;
            }
            EspionageResult result = this.DiplomaticTie.SpreadPropaganda(this.City);
            string          text   = string.Empty;

            switch (result)
            {
            case EspionageResult.Failure:
                text = ClientResources.GetString("propaganda_failure");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name);
                break;

            case EspionageResult.ImmuneToEspionage:
                text = ClientResources.GetString("propaganda_immune");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.Civilization.Adjective);
                break;

            case EspionageResult.Success:
                text = ClientResources.GetString("propaganda_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.City.Name);
                break;
            }
            IGameWindow gw = ClientApplication.Instance.GameWindow;

            gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }
コード例 #7
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication client = ClientApplication.Instance;
            string            message, title;

            message = ClientResources.GetString(StringKey.DisbandConfirmation);
            title   = ClientResources.GetString(StringKey.GameTitle);

            bool confirmed = client.GameWindow.GetUserConfirmation(message, title);

            if (confirmed)
            {
                Country player = client.Player;
                Unit    unit   = client.ServerInstance.ActiveUnit;
                player.DisbandUnit(unit);
            }
            OnInvoked();
        }
コード例 #8
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication ca        = ClientApplication.Instance;
            bool hasValidTies           = false;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker));

            picker.PickerTitle = ClientResources.GetString("plantSpy_tiePickerTitle");
            Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>();

            foreach (DiplomaticTie t in ca.Player.DiplomaticTies)
            {
                //TODO:  account for needed improvements
                if (t.HasEmbassy)
                {
                    hasValidTies = true;
                    if (!t.HasSpy)
                    {
                        ties.Add(t);
                    }
                }
            }
            if (ties.Count == 0 && hasValidTies)
            {
                //all the valid civs already have spys.
                string msg = ClientResources.GetString("plantSpy_spysExists");
                ca.GameWindow.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle));
                OnCanceled();
                return;
            }
            picker.InitializePicker(ties);
            picker.ShowSimilizationControl();
            this.tie = picker.DiplomaticTie;
            EspionageResult result = this.DiplomaticTie.PlantSpy();
            string          text   = string.Empty;

            switch (result)
            {
            case EspionageResult.Success:
                text = ClientResources.GetString("plantspy_success");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.CapitalCity.Name);
                break;

            case EspionageResult.Failure:
                text = ClientResources.GetString("plantspy_failure");
                text = string.Format(
                    CultureInfo.CurrentCulture,
                    text,
                    this.DiplomaticTie.ForeignCountry.CapitalCity.Name,
                    this.DiplomaticTie.ForeignCountry.Government.LeaderTitle,
                    this.DiplomaticTie.ForeignCountry.LeaderName);
                break;
            }
            IGameWindow gw = ClientApplication.Instance.GameWindow;

            gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle));
            OnInvoked();
        }