private void BtAddchrhi_Click(object sender, RoutedEventArgs e) { if (faction.Leader == null) { MessageBox.Show("请先选择势力君主"); } else { Window window = new Window(); window.Title = "请添加想要的城池"; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Width = 800; window.Height = 600; Grid grid = new Grid(); window.Content = grid; ListBox listBox = new ListBox(); listBox.HorizontalContentAlignment = HorizontalAlignment.Stretch; foreach (Architecture architecture in scen.Architectures) { if (!architectureListtemp.GameObjects.Contains(architecture)) { CheckBox checkBox = new CheckBox(); checkBox.IsChecked = false; checkBox.Content = architecture; Faction tempfaction = architecture.BelongedFaction; checkBox.Click += checkBox_check; void checkBox_check(object sender2, RoutedEventArgs e2) { if (checkBox.IsChecked == true) { if (tempfaction != null && architecture.Persons.HasGameObject(tempfaction.Leader)) { MessageBox.Show("无法选择此城池," + tempfaction.Name + "的君主" + tempfaction.Leader.Name + "在此城池中"); checkBox.IsChecked = false; } else { architectureListtemp.Add(architecture); } } else { architectureListtemp.Remove(architecture); } } listBox.Items.Add(checkBox); } } grid.Children.Add(listBox); window.Closed += window_Closed; void window_Closed(object sender3, EventArgs e3) { lbArchis.Items.Clear(); InitArchis(); } window.ShowDialog(); } }
private void EditArchitectures() { ArchitectureList list = new ArchitectureList(); for (int i = 0; i < this.dgvArchitectures.SelectedRows.Count; i++) { list.Add(this.Architectures[this.dgvArchitectures.SelectedRows[i].Index]); } frmEditArchitecture architecture = new frmEditArchitecture(); architecture.MainForm = this.MainForm; architecture.Architectures = list; architecture.ShowDialog(); this.dgvArchitectures.Invalidate(); }
private void ShowOrientationFrame() { GameDelegates.VoidFunction function = null; GameDelegates.VoidFunction function2 = null; GameDelegates.VoidFunction function3 = null; switch (this.EditingSection.AIDetail.OrientationKind) { case SectionOrientationKind.军区: this.TabListPlugin.InitialValues(this.EditingFaction.GetOtherSections(this.OriginalSection), null, this.screen.MouseState.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("Section", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.TerrainDetail; this.GameFramePlugin.Function = FrameFunction.Transport; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function == null) { function = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = null; this.EditingSection.OrientationSection = this.TabListPlugin.SelectedItem as Section; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function); break; case SectionOrientationKind.势力: this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.DiplomaticRelations.GetDiplomaticRelationDisplayListByFactionID(this.EditingFaction.ID).GetList(), null, this.screen.MouseState.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("DiplomaticRelation", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.CastTargetKind; this.GameFramePlugin.Function = FrameFunction.GetSectionToDemolish; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function2 == null) { function2 = delegate { this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = null; DiplomaticRelationDisplay selectedItem = this.TabListPlugin.SelectedItem as DiplomaticRelationDisplay; if (selectedItem.LinkedFaction1 == this.EditingFaction) { this.EditingSection.OrientationFaction = selectedItem.LinkedFaction2; } else if (selectedItem.LinkedFaction2 == this.EditingFaction) { this.EditingSection.OrientationFaction = selectedItem.LinkedFaction1; } this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function2); break; case SectionOrientationKind.州域: this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.States.GetList(), null, this.screen.MouseState.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("State", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.SectionAIDetail; this.GameFramePlugin.Function = FrameFunction.GetFaction; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function3 == null) { function3 = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = this.TabListPlugin.SelectedItem as State; this.EditingSection.OrientationArchitecture = null; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function3); break; case SectionOrientationKind.建筑: ArchitectureList allArch = this.EditingFaction.Scenario.Architectures; ArchitectureList targetArch = new ArchitectureList(); foreach (Architecture a in allArch) { if (a.BelongedFaction != this.EditingFaction) { targetArch.Add(a); } } this.TabListPlugin.InitialValues(targetArch, null, this.screen.MouseState.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("Architecture", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Architecture; this.GameFramePlugin.Function = FrameFunction.GetFaction; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function3 == null) { function3 = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = this.TabListPlugin.SelectedItem as Architecture; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function3); break; } this.GameFramePlugin.IsShowing = true; }
private void ShowAIDetailFrame() { this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailList(), this.EditingSection.AIDetail, this.screen.MouseState.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("SectionAIDetail", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Section; this.GameFramePlugin.Function = FrameFunction.GetSection; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; this.GameFramePlugin.SetOKFunction(delegate { this.EditingSection.AIDetail = this.TabListPlugin.SelectedItem as SectionAIDetail; switch (this.EditingSection.AIDetail.OrientationKind) { case SectionOrientationKind.军区: { SectionList otherSections = this.EditingFaction.GetOtherSections(this.OriginalSection); if (otherSections.Count == 1) { this.EditingSection.OrientationSection = otherSections[0] as Section; } break; } case SectionOrientationKind.势力: { GameObjectList diplomaticRelationListByFactionID = this.EditingFaction.Scenario.DiplomaticRelations.GetDiplomaticRelationListByFactionID(this.EditingFaction.ID); if (diplomaticRelationListByFactionID.Count == 1) { this.EditingSection.OrientationFaction = (diplomaticRelationListByFactionID[0] as DiplomaticRelation).GetDiplomaticFaction(this.EditingFaction.ID); } break; } case SectionOrientationKind.州域: { StateList states = this.EditingFaction.Scenario.States; if (states.Count == 1) { this.EditingSection.OrientationState = states[0] as State; } break; } case SectionOrientationKind.建筑: { ArchitectureList allArch = this.EditingFaction.Scenario.Architectures; ArchitectureList targetArch = new ArchitectureList(); foreach (Architecture a in allArch) { if (a.BelongedFaction != this.EditingFaction) { targetArch.Add(a); } } if (targetArch.Count == 1) { this.EditingSection.OrientationArchitecture = targetArch[0] as Architecture; } break; } } this.RefreshOKButton(); if (this.IsNew) { this.EditingSection.RefreshSectionName(); } this.RefreshOrientationButton(); this.RefreshLabelTextsDisplay(); }); this.GameFramePlugin.IsShowing = true; }
private void BtnArchitecture_Click(object sender, RoutedEventArgs e) { Window window = new Window(); window.Title = "選擇事件能觸發的建築"; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.Width = 800; window.Height = 600; Grid grid = new Grid(); window.Content = grid; DataGrid dataGrid1 = new DataGrid(); DataTable dt2 = new DataTable(); dt2.Columns.Add("點選", typeof(Boolean)); dt2.Columns.Add("ID", typeof(int)); dt2.Columns["ID"].ReadOnly = true; dt2.Columns.Add("名稱"); dt2.Columns["名稱"].ReadOnly = true; dt2.Columns.Add("種類"); dt2.Columns["種類"].ReadOnly = true; dt2.Columns.Add("州"); dt2.Columns["州"].ReadOnly = true; dt2.Columns.Add("地域"); dt2.Columns["地域"].ReadOnly = true; foreach (Architecture arch in scen.Architectures) { DataRow dr = dt2.NewRow(); dr["點選"] = tempArchitecture.GameObjects.Contains(arch); dr["ID"] = arch.ID; dr["名稱"] = arch.Name; dr["種類"] = arch.KindString; dr["州"] = arch.StateString; dr["地域"] = arch.RegionString; dt2.Rows.Add(dr); } dataGrid1.ItemsSource = dt2.DefaultView; grid.Children.Add(dataGrid1); dataGrid1.ColumnWidth = new DataGridLength(1, DataGridLengthUnitType.Star); window.Closed += Closed; window.ShowDialog(); void Closed(object source, EventArgs e2) { tempArchitecture.Clear(); for (int r = 0; r < dataGrid1.Items.Count; r++) { DataRowView item = dataGrid1.Items[r] as DataRowView; if (item == null) { continue; } if ((bool)item["點選"]) { tempArchitecture.Add((Architecture)scen.Architectures.GetGameObject((int)item["ID"])); } } lblArchitcture.Content = String.Join(" ", tempArchitecture.GameObjects.Select(p => p.Name)); } }
private void generatePerson() { this.scen.GameCommonData.PersonGeneratorSetting.bornLo = int.Parse(tbBornYearLo.Text); this.scen.GameCommonData.PersonGeneratorSetting.bornHi = int.Parse(tbBornYearHi.Text); this.scen.GameCommonData.PersonGeneratorSetting.debutLo = int.Parse(tbDebutAgeLo.Text); this.scen.GameCommonData.PersonGeneratorSetting.debutHi = int.Parse(tbDebutAgeHi.Text); this.scen.GameCommonData.PersonGeneratorSetting.dieLo = int.Parse(tbAgeLo.Text); this.scen.GameCommonData.PersonGeneratorSetting.dieHi = int.Parse(tbAgeHi.Text); this.scen.GameCommonData.PersonGeneratorSetting.debutAtLeast = int.Parse(tbDebutAtLeast.Text); try { ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[0]).generationChance = int.Parse(tbPersonType0.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[1]).generationChance = int.Parse(tbPersonType1.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[2]).generationChance = int.Parse(tbPersonType2.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[3]).generationChance = int.Parse(tbPersonType3.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[4]).generationChance = int.Parse(tbPersonType4.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[5]).generationChance = int.Parse(tbPersonType5.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[6]).generationChance = int.Parse(tbPersonType6.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[7]).generationChance = int.Parse(tbPersonType7.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[8]).generationChance = int.Parse(tbPersonType8.Text); ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[9]).generationChance = int.Parse(tbPersonType9.Text); } catch (ArgumentOutOfRangeException) { } int count = GameObject.Random(int.Parse(tbAddPersonLo.Text), int.Parse(tbAddPersonHi.Text)); int joinChance = int.Parse(tbJoinedFactionChance.Text); for (int i = 0; i < count; ++i) { bool joined = GameObject.Chance(joinChance); Architecture location = null; if (joined) { ArchitectureList candidates = new ArchitectureList(); foreach (Architecture j in scen.Architectures) { if (j.BelongedFaction != null) { candidates.Add(j); } } if (candidates.Count > 0) { location = (Architecture)candidates.GetRandomObject(); } else { joined = false; } } if (!joined) { location = (Architecture)scen.Architectures.GetRandomObject(); } Person p = Person.createPerson(scen, location, null, false, false); if (joined && location.BelongedFaction != null) { p.ChangeFaction(location.BelongedFaction); } } }
private void deleteArchitecture() { int toDeleteCnt = GameObject.Random(int.Parse(tbDeleteArchitectureLo.Text), int.Parse(tbDeleteArchitectureHi.Text)); int toDeletePopulationLo = int.Parse(tbDeleteArchitecturePopulationLo.Text); int toDeletePopulationHi = int.Parse(tbDeleteArchitecturePopulationHi.Text); if (toDeleteCnt == 0) { return; } ArchitectureList candidates = new ArchitectureList(); foreach (Architecture a in this.scen.Architectures) { if (a.PopulationCeiling >= toDeletePopulationLo && a.PopulationCeiling <= toDeletePopulationHi) { candidates.Add(a); } } GameObjectList toDelete = candidates.GetRandomList(); GameObjectList list = this.scen.Architectures.GetList(); int deleted = 0; foreach (Architecture a in list) { if (toDelete.GameObjects.Contains(a)) { if (a.BelongedFaction != null) { Architecture moveTo = a.BelongedFaction.Capital; if (a == moveTo) { continue; } foreach (Person p in a.Persons) { p.MoveToArchitecture(a); p.ArrivingDays = 0; } } foreach (Architecture i in a.AILandLinks.GetList()) { foreach (Architecture j in a.AILandLinks.GetList()) { if (i != j && a != i && a != j && !i.AILandLinks.GameObjects.Contains(j) && !j.AILandLinks.GameObjects.Contains(i)) { i.AILandLinks.Add(j); j.AILandLinks.Add(i); } } } foreach (Architecture i in a.AIWaterLinks.GetList()) { foreach (Architecture j in a.AIWaterLinks.GetList()) { if (i != j && a != i && a != j && !i.AIWaterLinks.GameObjects.Contains(j) && !j.AIWaterLinks.GameObjects.Contains(i)) { i.AIWaterLinks.Add(j); j.AIWaterLinks.Add(i); } } } this.scen.Architectures.Remove(a); deleted++; if (toDeleteCnt <= deleted) { break; } this.scen.ClearPersonStatusCache(); } } this.scen.ClearPersonStatusCache(); }
private void ShowOrientationFrame() { if (this.EditingFaction == null || this.EditingSection.AIDetail == null || this.TabListPlugin == null || this.GameFramePlugin == null) { return; } try { GameDelegates.VoidFunction function = null; GameDelegates.VoidFunction function2 = null; GameDelegates.VoidFunction function3 = null; switch (this.EditingSection.AIDetail.OrientationKind) { case SectionOrientationKind.军区: this.TabListPlugin.InitialValues(this.EditingFaction.GetOtherSections(this.OriginalSection), null, InputManager.NowMouse.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("Section", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.TerrainDetail; this.GameFramePlugin.Function = FrameFunction.Transport; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function == null) { function = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = null; this.EditingSection.OrientationSection = this.TabListPlugin.SelectedItem as Section; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function); break; case SectionOrientationKind.势力: var list0 = Session.Current.Scenario.DiplomaticRelations.GetDiplomaticRelationDisplayListByFactionID(this.EditingFaction.ID); if (list0 == null) { WebTools.TakeWarnMsg("list0 == null", "", new Exception("list0为空")); return; } var list = list0.GetList(); this.TabListPlugin.InitialValues(list, null, InputManager.NowMouse.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("DiplomaticRelation", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.CastTargetKind; this.GameFramePlugin.Function = FrameFunction.GetSectionToDemolish; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function2 == null) { function2 = delegate { this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = null; DiplomaticRelationDisplay selectedItem = this.TabListPlugin.SelectedItem as DiplomaticRelationDisplay; if (selectedItem.LinkedFaction1 == this.EditingFaction) { this.EditingSection.OrientationFaction = selectedItem.LinkedFaction2; } else if (selectedItem.LinkedFaction2 == this.EditingFaction) { this.EditingSection.OrientationFaction = selectedItem.LinkedFaction1; } this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function2); break; case SectionOrientationKind.州域: this.TabListPlugin.InitialValues(Session.Current.Scenario.States.GetList(), null, InputManager.NowMouse.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("State", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.SectionAIDetail; this.GameFramePlugin.Function = FrameFunction.GetFaction; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function3 == null) { function3 = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = this.TabListPlugin.SelectedItem as State; this.EditingSection.OrientationArchitecture = null; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function3); break; case SectionOrientationKind.建筑: ArchitectureList allArch = Session.Current.Scenario.Architectures; ArchitectureList targetArch = new ArchitectureList(); foreach (Architecture a in allArch) { if (a.BelongedFaction != this.EditingFaction) { targetArch.Add(a); } } this.TabListPlugin.InitialValues(targetArch, null, InputManager.NowMouse.ScrollWheelValue, ""); this.TabListPlugin.SetListKindByName("Architecture", true, false); this.TabListPlugin.SetSelectedTab(""); this.GameFramePlugin.Kind = FrameKind.Architecture; this.GameFramePlugin.Function = FrameFunction.GetFaction; this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull); this.GameFramePlugin.OKButtonEnabled = false; this.GameFramePlugin.CancelButtonEnabled = true; if (function3 == null) { function3 = delegate { this.EditingSection.OrientationFaction = null; this.EditingSection.OrientationSection = null; this.EditingSection.OrientationState = null; this.EditingSection.OrientationArchitecture = this.TabListPlugin.SelectedItem as Architecture; this.RefreshOKButton(); this.RefreshLabelTextsDisplay(); }; } this.GameFramePlugin.SetOKFunction(function3); break; } this.GameFramePlugin.IsShowing = true; } catch (Exception ex) { WebTools.TakeWarnMsg("MarshalSectionDialog.ShowOrientationFrame", "", ex); } }