/// <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; }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)client.GetControl(typeof(IDiplomaticTiePicker)); picker.ShowSimilizationControl(); DiplomaticTie tie = picker.DiplomaticTie; if (tie == null) { return; } //get an instance of the diplomacy control DiplomacyControl = (IDiplomacyControl)client.GetControl(typeof(IDiplomacyControl)); IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory(); //initialize the properties of the control DiplomacyControl.DiplomaticTie = tie; DiplomacyControl.ForeignLeaderHeaderText = string.Format( CultureInfo.InvariantCulture, ClientResources.GetString(StringKey.DiplomacyCountryHeader), tie.ForeignCountry.Name, ClientApplication.GetAttitudeString(tie.Attitude)); DiplomacyControl.ForeignLeaderPhrase = AIDiplomacyPhraseHelper.GetForeignLeaderGreeting(tie); DiplomacyControl.AdvisorHelpRequested += new EventHandler(HandleAdvisorHelpRequested); _advice = DiplomacyAdvice.GetAdvice(tie); DiplomacyControl.AdvisorPhrase = _advice[_adviceIndex]; //get the tasks DiplomacyTask[] tasks = DiplomacyHelper.GetDiplomacyTasks(tie, null, null); string taskText; DiplomacyCommand command; IDiplomacyTaskLink taskLink; //add the tasks to the diplomacy control. foreach (DiplomacyTask task in tasks) { taskText = DiplomacyHelper.GetTaskString(task, tie); command = DiplomacyHelper.GetTaskCommand(task, DiplomacyControl); taskLink = factory.CreateTaskLink(taskText, command); DiplomacyControl.TaskLinks.Add(taskLink); } DiplomacyControl.ShowSimilizationControl(); OnInvoked(); }
/// <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(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); 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.DiplomaticTie = picker.DiplomaticTie; this.City = this.DiplomaticTie.ForeignCountry.CapitalCity; string text = string.Empty; EspionageResult result = this.DiplomaticTie.StealWorldMap(); switch (result) { case EspionageResult.ImmuneToEspionage: text = ClientResources.GetString("stealworldmap_immune"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Adjective); break; case EspionageResult.Success: text = ClientResources.GetString("stealworldmap_success"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Noun); break; case EspionageResult.Failure: text = ClientResources.GetString("stealworldmap_failure"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name); break; case EspionageResult.SpyCaught: text = ClientResources.GetString("stealworldmap_spycaught"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; } OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { Settler settler; string newCityName; OnInvoking(); ClientApplication client = ClientApplication.Instance; GameRoot root = client.ServerInstance; if (root.ActiveUnit == null) { throw new InvalidOperationException(ClientResources.GetExceptionString("Unit_Null")); } if (!root.ActiveUnit.CanSettle) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ClientResources.GetExceptionString("Unit_CannotSettle"), root.ActiveUnit.Name)); } INewCityControl newCityWindow = (INewCityControl)client.GetControl(typeof(INewCityControl)); settler = (Settler)root.ActiveUnit; newCityWindow.ShowSimilizationControl(); newCityName = newCityWindow.CityName; _city = settler.Settle(newCityName); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; this.optionsControl = client.GetControl(typeof(IOptionsControl)) as IOptionsControl; this.optionsControl.Closed += new EventHandler <ControlClosedEventArgs>(OptionsControlClosed); this.optionsControl.ShowSimilizationControl(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IHelpControl helpControl = (IHelpControl)client.GetControl(typeof(IHelpControl)); helpControl.ShowSimilizationControl(); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication ca = ClientApplication.Instance; IAboutBox aboutBox = (IAboutBox)ca.GetControl(typeof(IAboutBox)); aboutBox.ShowSimilizationControl(); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IDomesticAdvisorControl ctl = client.GetControl(typeof(IDomesticAdvisorControl)) as IDomesticAdvisorControl; ctl.AdvisorText = GetAdvisorText(); ctl.ShowSimilizationControl(); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IHistograph histograph = client.GetControl(typeof(IHistograph)) as IHistograph; histograph.ShowSimilizationControl(); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IForeignAdvisorControl ctl = client.GetControl(typeof(IForeignAdvisorControl)) as IForeignAdvisorControl; ctl.ShowSimilizationControl(); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; IMilitaryAdvisorControl ctl = (IMilitaryAdvisorControl)client.GetControl(typeof(IMilitaryAdvisorControl)); ctl.CountryHeaderText = GetCountryHeaderText(client.Player); ctl.ForeignCountryHeaderText = GetCountryHeaderText(ctl.ForeignCountry); ctl.ForeignCountryChanged += new EventHandler(OnForeignCountryChanged); ctl.AdvisorText = GetAdvisorText(client.Player, ctl.ForeignCountry); ctl.ShowSimilizationControl(); OnInvoked(); }
/// <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(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; ISaveGameWindow wnd = (ISaveGameWindow)client.GetControl(typeof(ISaveGameWindow)); wnd.ShowSimilizationControl(); GameRoot root = client.ServerInstance; if (wnd.SavedGameFile.Length > 0) { root.SaveGame(wnd.SavedGameFile); OnInvoked(); } else { OnCanceled(); } }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); picker.PickerTitle = ClientResources.GetString("establishEmbassy_tiePickerTitle"); Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>(); foreach (DiplomaticTie t in ca.Player.DiplomaticTies) { //TODO: account for needed improvements if (!t.HasEmbassy) { ties.Add(t); } } if (ties.Count == 0) { string msg = ClientResources.GetString("establishEmbassy_noTies"); ca.GameWindow.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle)); OnCanceled(); } picker.InitializePicker(ties); picker.ShowSimilizationControl(); this.tie = picker.DiplomaticTie; this.tie.HasEmbassy = true; string text = ClientResources.GetString("establishEmbassy_success"); text = string.Format( CultureInfo.CurrentCulture, text, ca.Player.Government.LeaderTitle, this.tie.ForeignCountry.Civilization.Adjective, ClientResources.GetCitySizeString(this.tie.ForeignCountry.CapitalCity.SizeClass), this.tie.ForeignCountry.CapitalCity.Name ); ca.GameWindow.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle)); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; GameRoot root = client.ServerInstance; //load the ruleset string loadingMessage = ClientResources.GetString("item_loading"); string message = string.Format(CultureInfo.CurrentCulture, loadingMessage, this.rulesetPath); client.Console.WriteLine(message); root.LoadRuleset(this.rulesetPath); //load the tileset message = string.Format(CultureInfo.CurrentCulture, loadingMessage, this.tilesetPath); client.Console.WriteLine(message); client.LoadTileset(this.tilesetPath); INewGameControl ctl = (INewGameControl)client.GetControl(typeof(INewGameControl)); ctl.ResultChosen += new EventHandler(HandleResultChosen); ctl.ShowSimilizationControl(); }
/// <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(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); 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.DiplomaticTie = picker.DiplomaticTie; IGameWindow gw = ClientApplication.Instance.GameWindow; bool canSteal = CheckForStealableTechnologies(); if (!canSteal) { string msg = ClientResources.GetString("stealtechnology_noneavailable"); msg = string.Format( CultureInfo.CurrentCulture, ClientApplication.Instance.Player.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.Civilization.Noun); gw.ShowMessageBox(msg, ClientResources.GetString(StringKey.GameTitle)); OnCanceled(); } this.City = this.DiplomaticTie.ForeignCountry.CapitalCity; EspionageResult result = this.DiplomaticTie.StealTechnology(); string text = string.Empty; switch (result) { case EspionageResult.Failure: text = ClientResources.GetString("stealtechnology_failure"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name); break; case EspionageResult.ImmuneToEspionage: text = ClientResources.GetString("stealtechnology_immune"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Adjective); break; case EspionageResult.SpyCaught: text = ClientResources.GetString("stealtechnology_spycaught"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; case EspionageResult.Success: text = ClientResources.GetString("stealtechnology_success"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Noun); break; } gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle)); OnInvoked(); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); picker.PickerTitle = ClientResources.GetString("exposespy_tiePickerTitle"); 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.DiplomaticTie = picker.DiplomaticTie; IGameWindow gw = ClientApplication.Instance.GameWindow; this.City = this.DiplomaticTie.ForeignCountry.CapitalCity; EspionageResult result = this.DiplomaticTie.ExposeSpy(); string text = string.Empty; switch (result) { case EspionageResult.ImmuneToEspionage: text = ClientResources.GetString("exposespy_immune"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName, ClientApplication.Instance.Player.CapitalCity.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; case EspionageResult.SpyCaught: text = ClientResources.GetString("exposespy_spycaught"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; case EspionageResult.Success: text = ClientResources.GetString("exposespy_success"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName, ClientApplication.Instance.Player.CapitalCity.Name); break; case EspionageResult.SuccessWithCapturedSpy: text = ClientResources.GetString("exposespy_success_spycaught"); text = string.Format( CultureInfo.CurrentCulture, text, ClientApplication.Instance.Player.CapitalCity.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; } gw.ShowMessageBox(text, ClientResources.GetString(StringKey.GameTitle)); OnInvoked(); }