public List <string> LoadArchitecturesFromString(ArchitectureList architectures, string dataString) { List <string> errorMsg = new List <string>(); char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.Architectures.Clear(); try { foreach (string str in strArray) { Architecture gameObject = architectures.GetGameObject(int.Parse(str)) as Architecture; if (gameObject != null) { this.AddArchitecture(gameObject); } else { errorMsg.Add("建筑ID" + str + "不存在"); } } } catch { errorMsg.Add("建筑列表应为半型空格分隔的建筑ID"); } if (this.ArchitectureCount == 0) { errorMsg.Add("没有建筑"); } return(errorMsg); }
public void LoadArchitectureFromString(ArchitectureList archs, string data) { char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = data.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.architecture = new ArchitectureList(); foreach (string i in strArray) { this.architecture.Add(archs.GetGameObject(int.Parse(i)) as Architecture); } }
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(); }
public ArchitectureList GetOtherArchitectureList(Architecture architecture) { ArchitectureList list = new ArchitectureList(); foreach (Architecture architecture2 in this.Architectures) { if (architecture2 != architecture) { list.Add(architecture2); } } return(list); }
public void LoadArchitecturesFromString(ArchitectureList architectures, string dataString) { char[] separator = new char[] { ' ', '\n', '\r' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.Architectures.Clear(); foreach (string str in strArray) { Architecture gameObject = architectures.GetGameObject(int.Parse(str)) as Architecture; if (gameObject != null) { this.AddArchitecture(gameObject); } } }
public List<string> LoadArchitecturesFromString(ArchitectureList architectures, string dataString) { List<string> errorMsg = new List<string>(); char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.Architectures.Clear(); try { foreach (string str in strArray) { Architecture gameObject = architectures.GetGameObject(int.Parse(str)) as Architecture; if (gameObject != null) { this.AddArchitecture(gameObject); } else { errorMsg.Add("建筑ID" + str + "不存在"); } } } catch { errorMsg.Add("建筑列表应为半型空格分隔的建筑ID"); } if (this.ArchitectureCount == 0) { errorMsg.Add("没有建筑"); } return errorMsg; }
private void QuickSortArchitecturesDistance(ArchitectureList List, int begin, int end) { if (begin < end) { int num = this.QuickSortPartitionArchitecturesDistance(List, begin, end); if (begin < (num - 1)) { this.QuickSortArchitecturesDistance(List, begin, num - 1); } if ((num + 1) < end) { this.QuickSortArchitecturesDistance(List, num + 1, end); } } }
public void LoadArchitecturesFromString(ArchitectureList architectures, string dataString) { char[] separator = new char[] { ' ', '\n', '\r', '\t' }; string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.Architectures.Clear(); foreach (string str in strArray) { Architecture gameObject = architectures.GetGameObject(int.Parse(str)) as Architecture; if (gameObject != null) { this.AddArchitecture(gameObject); } } }
public ArchitectureList GetSupplyArchitecturesByPositionAndFaction(Point position, Faction faction) { ArchitectureList list = new ArchitectureList(); if (!this.PositionOutOfRange(position)) { if (this.MapTileData[position.X, position.Y].SupplyingArchitectures == null) { return list; } foreach (Architecture architecture in this.MapTileData[position.X, position.Y].SupplyingArchitectures) { //if (faction.IsFriendly(architecture.BelongedFaction)) if (faction == architecture.BelongedFaction) { list.Add(architecture); } } } return list; }
public void GetClosestArchitectures() { this.ClosestArchitectures = new ArchitectureList(); foreach (Architecture architecture in base.Scenario.Architectures) { if (architecture != this) { this.ClosestArchitectures.Add(architecture); } } this.QuickSortArchitecturesDistance(this.ClosestArchitectures, 0, this.ClosestArchitectures.Count - 1); }
public ArchitectureList jingongjianzhuliebiao() { ArchitectureList jianzhuliebiao = new ArchitectureList(); if (base.Scenario.youhuangdi()) { jianzhuliebiao.Add(base.Scenario.huangdisuozaijianzhu()); } return jianzhuliebiao; }
public void addBattleEntry(bool addYearTable, GameDate date, OngoingBattle ob, Person p, ArchitectureList architectures, Dictionary <Faction, int> factionDamages) { if (factionDamages.Count < 1) { return; } if (p.BelongedFaction == null) { return; } String allFactionStrings = ""; FactionList fl = new FactionList(); foreach (Faction f in factionDamages.Keys) { allFactionStrings += "、" + (f == null ? "贼军" : f.Name); fl.Add(f); } allFactionStrings = allFactionStrings.Substring(1); String architectureStrings = ""; if (architectures.Count > 0) { foreach (Architecture a in architectures) { architectureStrings += "、" + a.Name; } architectureStrings = architectureStrings.Substring(1); } int dayDiff = (date.Year - ob.StartYear) * 360 + (date.Month - ob.StartMonth) * 30 + (date.Day - ob.StartDay) - 5; if (dayDiff <= 0) { return; } Dictionary <Faction, int> totalDamages = new Dictionary <Faction, int>(); foreach (Faction f in factionDamages.Keys) { totalDamages.Add(f, 0); foreach (KeyValuePair <Faction, int> pair in factionDamages) { if (f != pair.Key) { totalDamages[f] += pair.Value; } } } List <KeyValuePair <Faction, int> > damageList = totalDamages.ToList(); damageList.Sort((firstPair, nextPair) => - firstPair.Value.CompareTo(nextPair.Value)); List <KeyValuePair <Faction, int> > selfDamageList = factionDamages.ToList(); selfDamageList.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value)); String victorDescription = ""; String selfDescription = ""; if (ob.Skirmish) { if (damageList.Count > 1) { if (damageList[0].Value > damageList[1].Value * 1.5) { victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "大胜"; } else if (damageList[0].Value > damageList[1].Value * 1.2) { victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "小胜"; } else { victorDescription = "互有胜负"; } int rank = 0; foreach (KeyValuePair <Faction, int> i in damageList) { if (i.Key == p.BelongedFaction) { if (rank == 0) { if (damageList[0].Value > damageList[1].Value * 1.5) { selfDescription = "并大胜敌人"; } else if (damageList[0].Value > damageList[1].Value * 1.2) { selfDescription = "并小胜敌人"; } else { selfDescription = "互有胜负"; } } else if (rank == damageList.Count - 1) { if (damageList[0].Value > damageList[rank].Value * 1.5) { selfDescription = "却遭到大败"; } else if (damageList[0].Value > damageList[rank].Value * 1.2) { selfDescription = "却遭遇小败"; } else { selfDescription = "互有胜负"; } } } rank++; } } } if (ob.Skirmish) { if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleSkirmish"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", "", architectureStrings, "", "", dayDiff + "天", victorDescription), false); } this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleSkirmish_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", "", architectureStrings, "", "", dayDiff + "天", selfDescription)); } else { foreach (Architecture a in architectures) { if (a.BelongedFaction == null || (a.OldFactionName != a.BelongedFaction.Name)) { if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleOccupy"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天"), false); } if (p.BelongedFaction == a.BelongedFaction) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } else if (p.BelongedFaction.Name == a.OldFactionName) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_q"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } else { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_r"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } } else { String offenderString = ""; if (fl.Count > 1) { foreach (Faction f in fl) { if (f != a.BelongedFaction) { offenderString += "、" + f.Name; } } offenderString = offenderString.Substring(1); } if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleRetreat"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天"), false); } if (a.BelongedFaction == p.BelongedFaction) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天")); } else { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_q"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天")); } } } } }
public ArchitectureList ArchitectureListWithoutSelf() { ArchitectureList architectureList=new ArchitectureList() ; foreach (Architecture architecture in base.Scenario.Architectures) { architectureList.Add(architecture); } architectureList.Remove(this); return architectureList; }
public ArchitectureList GetClosestArchitectures(int count) { if (this.ClosestArchitectures == null) { this.GetClosestArchitectures(); } ArchitectureList list = new ArchitectureList(); if (count > this.ClosestArchitectures.Count) { count = this.ClosestArchitectures.Count; } for (int i = 0; i < count; i++) { list.Add(this.ClosestArchitectures[i]); } return list; }
private void OutsideTacticsAI() { if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (((this.RecentlyAttacked <= 0) && this.HasPerson()) && this.IsFundEnough)) { Architecture architecture2; int diplomaticRelation; Person firstHalfPerson; ArchitectureList list = new ArchitectureList(); ArchitectureList list2 = new ArchitectureList(); foreach (Architecture architecture in this.GetClosestArchitectures(20)) { if (!this.BelongedFaction.IsArchitectureKnown(architecture)) { list.Add(architecture); } else { list2.Add(architecture); } } if ((list.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics) { if (list.Count > 1) { list.PropertyName = "Population"; list.IsNumber = true; list.ReSort(); } if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(list.Count))) && GameObject.Chance(20)) && this.InformationAvail()) { architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture; if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("InformationAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) { firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind(); if (firstHalfPerson.CurrentInformationKind != null) { firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } if (((this.PlanArchitecture == null) && (GameObject.Random(40) < GameObject.Random(list.Count))) && (this.HasPerson() && (GameObject.Random(this.Fund) >= this.SpyArchitectureFund))) { architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture; if ((!architecture2.HasFactionSpy(this.BelongedFaction) || GameObject.Chance(20)) && (((architecture2.BelongedFaction != null) && (GameObject.Random(architecture2.AreaCount + 4) >= 4)) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("SpyAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && (GameObject.Random(firstHalfPerson.SpyAbility) >= 200)) { firstHalfPerson.GoForSpy(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } if (((list2.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics) { if (list2.Count > 1) { list2.PropertyName = "PersonCount"; list2.IsNumber = true; list2.ReSort(); } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50)) { ArchitectureList list3 = new ArchitectureList(); foreach (Architecture architecture in list2) { if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) { list3.Add(architecture); } } if (list3.Count > 0) { architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture; if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("GossipAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200))) { firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50)) { ArchitectureList list4 = new ArchitectureList(); foreach (Architecture architecture in list2) { if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson()) { list4.Add(architecture); } } foreach (Architecture architecture in this.BelongedFaction.Architectures) { if (architecture.HasCaptive()) { list4.Add(architecture); } } if (list4.Count > 0) { architecture2 = list4[GameObject.Random(list4.Count)] as Architecture; if (architecture2.BelongedFaction == this.BelongedFaction) { Captive extremeLoyaltyCaptive = architecture2.GetExtremeLoyaltyCaptive(true); if ((((extremeLoyaltyCaptive != null) && (extremeLoyaltyCaptive.CaptivePerson != null)) && ((extremeLoyaltyCaptive.Loyalty < 100) && (extremeLoyaltyCaptive.CaptiveFaction != null))) && (extremeLoyaltyCaptive.CaptivePerson != extremeLoyaltyCaptive.CaptiveFaction.Leader)) { firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(0x21))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyCaptive.Loyalty * 5)))) { firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); firstHalfPerson.GoForConvince(extremeLoyaltyCaptive.CaptivePerson); } } } else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50)) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0)) { Person extremeLoyaltyPerson = architecture2.GetExtremeLoyaltyPerson(true); if (((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader)) { firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5)))) { firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); firstHalfPerson.GoForConvince(extremeLoyaltyPerson); } } } } } } } } }
private void AIPersonTransfer() { int num2; if ((this.MilitaryCount == 0) && ((this.IsImportant || (this.AreaCount > 1)) || (this.Population > this.RecruitmentPopulationBoundary))) { this.AIRecruitment(false); } if ((((this.BelongedFaction.ArchitectureCount > 1) && (this.PersonCount > this.MilitaryCount)) && (this.RecentlyAttacked > 0)) && ((this.Endurance == 0) || ((this.Endurance < 30) && GameObject.Chance(0x21)))) { int num = this.PersonCount - this.MilitaryCount; GameObjectList list = new GameObjectList(); list = this.Persons.GetList(); if (list.Count > 1) { list.IsNumber = true; list.SmallToBig = true; list.PropertyName = "FightingForce"; list.ReSort(); } Architecture capital = this.BelongedFaction.Capital; if (capital == this) { ArchitectureList otherArchitectureList = this.GetOtherArchitectureList(); if (otherArchitectureList.Count > 1) { otherArchitectureList.IsNumber = true; otherArchitectureList.PropertyName = "ArmyScaleWeighing"; otherArchitectureList.ReSort(); } capital = otherArchitectureList[0] as Architecture; } num2 = 0; while (num2 < num) { (list[num2] as Person).MoveToArchitecture(capital); this.RemovePerson(list[num2] as Person); if (GameObject.Chance(20)) { break; } num2++; } } else if (((this.PersonCount + this.MovingPersons.Count) < this.MilitaryCount) || (this.PlanArchitecture != null)) { if (this.RecentlyAttacked > 0) { int num3 = (this.MilitaryCount - this.PersonCount) - this.MovingPersons.Count; PersonList list3 = new PersonList(); foreach (Architecture architecture2 in GameObject.Chance(20) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures) { if ((architecture2 != this) && (((architecture2.BelongedSection.AIDetail != null) && architecture2.BelongedSection.AIDetail.AutoRun) && (((architecture2.RecentlyAttacked <= 0) && ((architecture2.PersonCount + architecture2.MovingPersons.Count) >= architecture2.MilitaryCount)) || (((architecture2.Fund < (100 * this.AreaCount)) && (architecture2.Domination >= (architecture2.DominationCeiling * 0.8))) && (architecture2.Endurance >= (architecture2.EnduranceCeiling * 0.2f)))))) { foreach (Person person in architecture2.Persons) { if ((!architecture2.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !architecture2.HasExperiencedLeaderMilitary(person))) && (person.Command >= 40)) { list3.Add(person); } } } } if (list3.Count > 0) { if (list3.Count > 1) { list3.IsNumber = true; list3.PropertyName = "FightingForce"; list3.ReSort(); } for (num2 = 0; (num2 < num3) && (num2 < list3.Count); num2++) { Architecture locationArchitecture = (list3[num2] as Person).LocationArchitecture; (list3[num2] as Person).MoveToArchitecture(this); locationArchitecture.RemovePerson(list3[num2] as Person); } } } } else if (this.HasPerson() && GameObject.Chance(10)) { PersonList list4 = new PersonList(); if (this.Kind.HasPopulation && (this.Population < (0x3e8 * this.AreaCount))) { if (this.IsCapital && (this.Fund >= this.ChangeCapitalCost)) { Architecture newCapital = this.BelongedFaction.SelectNewCapital(); if (newCapital != this) { this.DecreaseFund(this.ChangeCapitalCost); this.BelongedFaction.ChangeCapital(newCapital); } } foreach (Person person in this.Persons) { if (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person))) { list4.Add(person); } } } else { foreach (Person person in this.Persons) { if ((person.WorkKind == ArchitectureWorkKind.无) && (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person)))) { list4.Add(person); } } } if (list4.Count > 0) { ArchitectureList list5 = new ArchitectureList(); foreach (Architecture architecture2 in (base.Scenario.Date.Day == 1) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures) { if ((architecture2 != this) && ((((architecture2.IsRegionCore || architecture2.IsStateAdmin) || (architecture2.Kind.HasPopulation && (architecture2.Population > this.Population))) || GameObject.Chance(5)) || ((architecture2.Fund >= (100 * this.AreaCount)) && ((((architecture2.PersonCount + architecture2.MovingPersons.Count) < architecture2.MilitaryCount) || (architecture2.Domination < (architecture2.DominationCeiling * 0.8))) || (architecture2.Endurance < (architecture2.EnduranceCeiling * 0.2f)))))) { list5.Add(architecture2); } } if (list5.Count > 0) { if (list5.Count > 1) { list5.PropertyName = "ArmyScaleWeighing"; list5.IsNumber = true; list5.ReSort(); } for (num2 = 0; (num2 < list4.Count) && (num2 < list5.Count); num2++) { (list4[num2] as Person).MoveToArchitecture(list5[num2] as Architecture); this.RemovePerson(list4[num2] as Person); } } } } }
public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario,MainGameScreen mainGameScreen) { this.mainMapLayer = mainMapLayer; this.Architectures = scenario.Architectures; this.gameScenario = scenario; //this.huangditupian = huangditupian; }
public ArchitectureList GetViewingArchitecturesByPosition(Point position) { ArchitectureList list = new ArchitectureList(); if (!this.PositionOutOfRange(position)) { if (this.MapTileData[position.X, position.Y].ViewingArchitectures == null) { return list; } foreach (Architecture architecture in this.MapTileData[position.X, position.Y].ViewingArchitectures) { list.Add(architecture); } } return list; }
private int QuickSortPartitionArchitecturesDistance(ArchitectureList List, int begin, int end) { Architecture architecture = List[begin] as Architecture; int simpleDistance = base.Scenario.GetSimpleDistance(architecture.Position, this.Position); int num2 = begin; while (begin < end) { int num3 = base.Scenario.GetSimpleDistance((List[end] as Architecture).Position, this.Position); while ((begin < end) && (num3 >= simpleDistance)) { end--; num3 = base.Scenario.GetSimpleDistance((List[end] as Architecture).Position, this.Position); } if (begin >= end) { return begin; } this.QuickSortSwapArchitectureDistance(List, begin, end); begin++; for (num3 = base.Scenario.GetSimpleDistance((List[begin] as Architecture).Position, this.Position); (begin < end) && (num3 <= simpleDistance); num3 = base.Scenario.GetSimpleDistance((List[begin] as Architecture).Position, this.Position)) { begin++; } if (begin >= end) { return begin; } this.QuickSortSwapArchitectureDistance(List, begin, end); end--; } return begin; }
public void Init() { Architectures = new ArchitectureList(); }
private void QuickSortSwapArchitectureDistance(ArchitectureList List, int i, int j) { GameObject obj2 = List[i]; List[i] = List[j]; List[j] = obj2; }
private ArchitectureList GetAttackPossibleArchitectures(bool last) { ArchitectureList list = new ArchitectureList(); foreach (Point point in this.OffenceArea.Area) { Architecture architectureByPosition = base.Scenario.GetArchitectureByPosition(point); if (architectureByPosition != null) { if ((architectureByPosition.Endurance == 0) || this.IsFriendly(architectureByPosition.BelongedFaction)) { continue; } if (this.IfAttackArchitecture(architectureByPosition, last)) { list.Add(architectureByPosition); } } } return list; }
public void FindLinks(ArchitectureList allArch) { pathFinder.OnGetCost += new RoutewayPathFinder.GetCost(RoutewayPathBuilder_OnGetCost); pathFinder.OnGetPenalizedCost += new RoutewayPathFinder.GetPenalizedCost(RoutewayPathBuilder_OnGetPenalizedCost); FindLandLinks(allArch, 50); FindWaterLinks(allArch, 50); }
public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario,MainGameScreen mainGameScreen) { this.screen = mainGameScreen; this.mainMapLayer = mainMapLayer; this.Architectures = scenario.Architectures; this.gameScenario = scenario; }
public ArchitectureList GetClosestArchitectures(int count, double maxDistance) { if (this.ClosestArchitectures == null) { this.GetClosestArchitectures(); } ArchitectureList list = new ArchitectureList(); if (count > this.ClosestArchitectures.Count) { count = this.ClosestArchitectures.Count; } for (int i = 0; i < count; i++) { if (base.Scenario.GetDistance(this.ArchitectureArea, (this.ClosestArchitectures[i] as Architecture).ArchitectureArea) <= maxDistance) { list.Add(this.ClosestArchitectures[i]); } else { break; } } if (list.Count == 0) { list.Add(this.ClosestArchitectures[0]); } return list; }
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; }
public ArchitectureList GetOtherArchitectureList(Architecture architecture) { ArchitectureList list = new ArchitectureList(); foreach (Architecture architecture2 in this.Architectures) { if (architecture2 != architecture) { list.Add(architecture2); } } return list; }
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); ((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); 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); if (joined && location.BelongedFaction != null) { p.ChangeFaction(location.BelongedFaction); } } }
private void OutsideTacticsAI() { if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (((this.RecentlyAttacked <= 0) && this.HasPerson()) && this.IsFundEnough)) { Architecture architecture2; int diplomaticRelation; Person firstHalfPerson; ArchitectureList list = new ArchitectureList(); ArchitectureList list2 = new ArchitectureList(); foreach (Architecture architecture in this.GetClosestArchitectures(20, 40)) { if (!this.BelongedFaction.IsArchitectureKnown(architecture)) { list.Add(architecture); } else { list2.Add(architecture); } } /*if (this.BelongedSection != null && (list.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics) { if (list.Count > 1) { list.PropertyName = "Population"; list.IsNumber = true; list.ReSort(); } if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(list.Count))) && GameObject.Chance(20)) && this.InformationAvail()) { architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture; if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("InformationAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) { firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind(); if (firstHalfPerson.CurrentInformationKind != null) { firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } if (((this.PlanArchitecture == null) && (GameObject.Random(40) < GameObject.Random(list.Count))) && (this.HasPerson() && (GameObject.Random(this.Fund) >= this.SpyArchitectureFund))) { architecture2 = list[GameObject.Random(list.Count / 2)] as Architecture; if ((!architecture2.HasFactionSpy(this.BelongedFaction) || GameObject.Chance(20)) && (((architecture2.BelongedFaction != null) && (GameObject.Random(architecture2.AreaCount + 4) >= 4)) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("SpyAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && (GameObject.Random(firstHalfPerson.SpyAbility) >= 200)) { firstHalfPerson.GoForSpy(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } }*/ if ((this.BelongedSection != null) && ((list2.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics) { if (list2.Count > 1) { list2.PropertyName = "PersonCount"; list2.IsNumber = true; list2.ReSort(); } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50)) { ArchitectureList list3 = new ArchitectureList(); foreach (Architecture architecture in list2) { if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) { list3.Add(architecture); } } if (list3.Count > 0) { architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture; if (GameObject.Chance(100 - architecture2.noEscapeChance * 2)) { if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("GossipAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200))) { firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50)) { ArchitectureList list4 = new ArchitectureList(); foreach (Architecture architecture in list2) { if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson()) { list4.Add(architecture); } } foreach (Architecture architecture in this.BelongedFaction.Architectures) { if (architecture.HasCaptive()) { list4.Add(architecture); } } if (list4.Count > 0) { architecture2 = list4[GameObject.Random(list4.Count)] as Architecture; if (architecture2.BelongedFaction == this.BelongedFaction) { Captive extremeLoyaltyCaptive = architecture2.GetLowestLoyaltyCaptiveRecruitable(); if ((((extremeLoyaltyCaptive != null) && (extremeLoyaltyCaptive.CaptivePerson != null)) && ((extremeLoyaltyCaptive.Loyalty < 100 || (GlobalVariables.AIAutoTakePlayerCaptives && !GlobalVariables.AIAutoTakePlayerCaptiveOnlyUnfull && base.Scenario.IsPlayer(extremeLoyaltyCaptive.CaptiveFaction))))) && (extremeLoyaltyCaptive.CaptiveFaction == null || extremeLoyaltyCaptive.CaptivePerson != extremeLoyaltyCaptive.CaptiveFaction.Leader)) { PersonList firstHalfPersonList = this.GetFirstHalfPersonList("ConvinceAbility"); foreach (Person i in firstHalfPersonList) { if ((GameObject.Random(this.BelongedFaction.PersonCount) < 5 && i != null) || ((((i != null) && (!this.HasFollowedLeaderMilitary(i) || GameObject.Chance(33))) && (GameObject.Random(i.NonFightingNumber) > GameObject.Random(i.FightingNumber))) && (GameObject.Random(i.FightingNumber) < 100)) && ((GameObject.Random(i.ConvinceAbility) >= 200) && (GameObject.Random(i.ConvinceAbility) > GameObject.Random(extremeLoyaltyCaptive.Loyalty * 5)))) { i.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); i.GoForConvince(extremeLoyaltyCaptive.CaptivePerson); } } } } else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50)) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0)) { Person extremeLoyaltyPerson = architecture2.GetLowestLoyaltyPersonRecruitable(); if ((extremeLoyaltyPerson != null) && ((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader)) { firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5)))) { firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); firstHalfPerson.GoForConvince(extremeLoyaltyPerson); } } } } } } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.JailBreakArchitectureFund)) && GameObject.Chance(50) && this.JailBreakAvail()) { List<Architecture> a = new List<Architecture>(); foreach (Architecture architecture in base.Scenario.Architectures) { if (architecture.HasFactionCaptive(this.BelongedFaction) && list2.GameObjects.Contains(architecture)) { a.Add(architecture); } } if (a.Count > 0) { Architecture target = a[GameObject.Random(a.Count)] as Architecture; if (GameObject.Chance(100 - target.noEscapeChance * 2)) { int totalCaptiveValue = 0; foreach (Captive c in target.Captives) { if (c.CaptiveFaction == this.BelongedFaction) { totalCaptiveValue += c.AIWantsTheCaptive; } } if (GameObject.Random(totalCaptiveValue) > GameObject.Random(100000)) { firstHalfPerson = this.GetFirstHalfPerson("JailBreakAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100))) { firstHalfPerson.GoForJailBreak(base.Scenario.GetClosestPoint(target.ArchitectureArea, this.Position)); } } } } } } } }
public ArchitectureList GetRoutewayArchitecturesByPosition(Routeway routeway, Point position) { ArchitectureList list = new ArchitectureList(); if (!this.PositionOutOfRange(position)) { foreach (Architecture architecture in routeway.BelongedFaction.Architectures) { if ((architecture != routeway.StartArchitecture) && architecture.GetRoutewayStartArea().HasPoint(position)) { list.Add(architecture); } } } return list; }
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; }
public void LoadArchitectureFromString(ArchitectureList archs, string data) { char[] separator = new char[] { ' ', '\n', '\r' }; string[] strArray = data.Split(separator, StringSplitOptions.RemoveEmptyEntries); this.architecture = new ArchitectureList(); foreach (string i in strArray) { this.architecture.Add(archs.GetGameObject(int.Parse(i)) as Architecture); } }
private void screen_OnMouseMove(Point position, bool leftDown) { this.commentDrawing = false; if (StaticMethods.PointInRectangle(position, this.BackgroundDisplayPosition)) { this.screen.DefaultMouseArrowTexture = this.DefaultMouseArrowTexture; if (StaticMethods.PointInRectangle(position, this.ExtendButtonDisplayPosition)) { if (this.ExtendButtonState == ButtonState.Normal) { this.ExtendButtonState = ButtonState.Selected; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if (this.EndButtonState == ButtonState.Selected) { this.EndButtonState = ButtonState.Normal; } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("延伸粮道", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("请根据实际情况设计粮道的路径。"); this.Comment.AddNewLine(); this.Comment.AddText("提示", Color.Lime); this.Comment.AddText(":您可以在延伸点按下鼠标之后进行拖拽。"); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.ExtendButtonDisplayPosition.Right, this.ExtendButtonDisplayPosition.Top); } else if (StaticMethods.PointInRectangle(position, this.CutButtonDisplayPosition)) { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Normal) { this.CutButtonState = ButtonState.Selected; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if (this.EndButtonState == ButtonState.Selected) { this.EndButtonState = ButtonState.Normal; } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("截断粮道", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("用以删除某一点之后的粮道。"); this.Comment.AddNewLine(); this.Comment.AddText("提示", Color.Lime); this.Comment.AddText(":如果选择粮道的起点则删除整条粮道。请小心操作。"); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.CutButtonDisplayPosition.Right, this.CutButtonDisplayPosition.Top); } else if (StaticMethods.PointInRectangle(position, this.DirectionSwitchDisplayPosition)) { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Normal) { this.DirectionSwitchState = ButtonState.Selected; } if (this.EndButtonState == ButtonState.Selected) { this.EndButtonState = ButtonState.Normal; } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("转换方向", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("用以转换粮道的运输方向。"); this.Comment.AddNewLine(); this.Comment.AddText("提示", Color.Lime); this.Comment.AddText(":仅在粮道两端都为我方建筑时有效。未完全疏通的粮道将被关闭。"); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.DirectionSwitchDisplayPosition.Right, this.DirectionSwitchDisplayPosition.Top); } else if (StaticMethods.PointInRectangle(position, this.BuildButtonDisplayPosition)) { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if (this.BuildButtonState == ButtonState.Normal) { if (leftDown) { this.BuildButtonState = ButtonState.Down; } else { this.BuildButtonState = ButtonState.Selected; } } if (this.EndButtonState == ButtonState.Selected) { this.EndButtonState = ButtonState.Normal; } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("疏通粮道", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("结束粮道的编辑工作并且开始疏通粮道。"); this.Comment.AddNewLine(); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.BuildButtonDisplayPosition.Right, this.BuildButtonDisplayPosition.Top); } else if (StaticMethods.PointInRectangle(position, this.EndButtonDisplayPosition)) { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if (this.BuildButtonState == ButtonState.Selected) { this.BuildButtonState = ButtonState.Normal; } if (this.EndButtonState == ButtonState.Normal) { if (leftDown) { this.EndButtonState = ButtonState.Down; } else { this.EndButtonState = ButtonState.Selected; } } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("结束编辑", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("结束粮道的编辑工作。"); this.Comment.AddNewLine(); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.EndButtonDisplayPosition.Right, this.EndButtonDisplayPosition.Top); } else { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if ((this.EndButtonState == ButtonState.Selected) || (this.EndButtonState == ButtonState.Down)) { this.EndButtonState = ButtonState.Normal; } this.draging = leftDown && !this.extending; } } else { if (this.ExtendButtonState == ButtonState.Selected) { this.ExtendButtonState = ButtonState.Normal; } if (this.CutButtonState == ButtonState.Selected) { this.CutButtonState = ButtonState.Normal; } if (this.DirectionSwitchState == ButtonState.Selected) { this.DirectionSwitchState = ButtonState.Normal; } if ((this.BuildButtonState == ButtonState.Selected) || (this.BuildButtonState == ButtonState.Down)) { this.BuildButtonState = ButtonState.Normal; } if ((this.EndButtonState == ButtonState.Selected) || (this.EndButtonState == ButtonState.Down)) { this.EndButtonState = ButtonState.Normal; } Point positionByPoint = this.screen.GetPositionByPoint(position); if (this.ExtendButtonState == ButtonState.Down) { if (this.EditingRouteway.CurrentExtendArea.HasPoint(positionByPoint)) { this.CurrentPositionArchitectures = this.screen.Scenario.GetRoutewayArchitecturesByPosition(this.EditingRouteway, positionByPoint); if (this.extending) { this.ExtendRouteway(positionByPoint); } else if (this.CurrentPositionArchitectures.Count > 0) { if (this.CurrentPositionArchitectures.Count > 1) { this.CurrentPositionArchitectures.PropertyName = "Food"; this.CurrentPositionArchitectures.IsNumber = true; this.CurrentPositionArchitectures.ReSort(); } this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("连接到", Color.Yellow); this.Comment.AddText(this.CurrentPositionArchitectures[0].Name, Color.Lime); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.screen.GetDestination(positionByPoint).Right, this.screen.GetDestination(positionByPoint).Top); } this.screen.DefaultMouseArrowTexture = this.ExtendMouseArrowTexture; } else { if ((this.extending && (this.EditingRouteway.RoutePoints.Last.Previous != null)) && (positionByPoint == this.EditingRouteway.RoutePoints.Last.Previous.Value.Position)) { this.CutRouteway(this.EditingRouteway.LastPoint.Position); } this.screen.DefaultMouseArrowTexture = this.ExtendDisabledMouseArrowTexture; } } else if (this.CutButtonState == ButtonState.Down) { if (this.EditingRouteway.ContainsPoint(positionByPoint)) { this.screen.DefaultMouseArrowTexture = this.CutMouseArrowTexture; } else { this.screen.DefaultMouseArrowTexture = this.CutDisabledMouseArrowTexture; } } if (!this.draging && !this.extending) { RoutePoint point = this.EditingRouteway.GetPoint(positionByPoint); if (point != null) { this.commentDrawing = true; this.Comment.Clear(); this.Comment.AddText("当前坐标粮道信息", Color.Yellow); this.Comment.AddNewLine(); this.Comment.AddText("消耗率:"); this.Comment.AddText(StaticMethods.GetPercentString(point.ConsumptionRate, 1), Color.Red); this.Comment.AddNewLine(); this.Comment.AddText("开通费用:"); this.Comment.AddText(point.BuildFundCost.ToString()); this.Comment.AddNewLine(); this.Comment.AddText("维持费用:"); this.Comment.AddText(point.ActiveFundCost.ToString()); this.Comment.AddNewLine(); this.Comment.ResortTexts(); this.Comment.DisplayOffset = new Point(this.screen.GetDestination(positionByPoint).Right, this.screen.GetDestination(positionByPoint).Top); } } } if (this.draging) { this.Drag(); } }
private void FindWaterLinks(ArchitectureList allArch, int maxDistance) { if (!this.IsBesideWater) return; foreach (Architecture i in allArch) { if (i == this) continue; if (!i.IsBesideWater) continue; if (i.AIWaterLinks.GameObjects.Contains(this)) continue; pathFinder.startingArchitecture = this; pathFinder.targetArchitecture = i; pathFinder.MultipleWaterCost = false; pathFinder.MustUseWater = true; if (base.Scenario.GetSimpleDistance(i.Position, this.Position) < maxDistance) { pathFinder.ConsumptionMax = 0.7f; Point? p1; Point? p2; base.Scenario.GetClosestPointsBetweenTwoAreas(this.GetWaterTroopMovableArea(), i.GetWaterTroopMovableArea(), out p1, out p2); if (p1.HasValue && p2.HasValue) { if (pathFinder.GetPath(p1.Value, p2.Value, true)) { this.AIWaterLinks.Add(i); i.AIWaterLinks.Add(this); } } } } }
private void OutsideTacticsAI() { ConvinceNoFactionAI(); if (this.PlanArchitecture == null && this.RecentlyAttacked <= 0 && this.HasPerson() && this.IsFundEnough) { Architecture architecture2; int diplomaticRelation; Person firstHalfPerson; ArchitectureList unknownArch = new ArchitectureList(); ArchitectureList knownArch = new ArchitectureList(); foreach (Architecture architecture in this.GetClosestArchitectures(20, 40)) { if (!this.BelongedFaction.IsArchitectureKnown(architecture)) { unknownArch.Add(architecture); } else { knownArch.Add(architecture); } } if (this.BelongedSection != null && (unknownArch.Count > 0) && this.BelongedSection.AIDetail.AllowInvestigateTactics) { if (unknownArch.Count > 1) { unknownArch.PropertyName = "Population"; unknownArch.IsNumber = true; unknownArch.ReSort(); } if ((((this.RecentlyAttacked <= 0) && (GameObject.Random(40) < GameObject.Random(unknownArch.Count))) && GameObject.Chance(20)) && this.InformationAvail()) { architecture2 = unknownArch[GameObject.Random(unknownArch.Count / 2)] as Architecture; if ((!this.BelongedFaction.IsArchitectureKnown(architecture2) || GameObject.Chance(20)) && ((architecture2.BelongedFaction != null) && (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("InformationAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) { firstHalfPerson.CurrentInformationKind = this.GetFirstHalfInformationKind(); if (firstHalfPerson.CurrentInformationKind != null) { firstHalfPerson.GoForInformation(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } } if ((this.BelongedSection != null) && ((knownArch.Count > 0) && (this.PlanArchitecture == null)) && this.BelongedSection.AIDetail.AllowPersonTactics) { if (knownArch.Count > 1) { knownArch.PropertyName = "PersonCount"; knownArch.IsNumber = true; knownArch.ReSort(); } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.GossipArchitectureFund)) && GameObject.Chance(50)) { ArchitectureList list3 = new ArchitectureList(); foreach (Architecture architecture in knownArch) { if ((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) { list3.Add(architecture); } } if (list3.Count > 0) { architecture2 = list3[GameObject.Random(list3.Count / 2)] as Architecture; if (GameObject.Chance(100 - architecture2.noEscapeChance * 2)) { if ((!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(10)) && ((architecture2.Fund < architecture2.EnoughFund) || ((architecture2.Fund < architecture2.AbundantFund) && GameObject.Chance(20)))) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 200) <= GameObject.Random(50))) || ((diplomaticRelation < 0) && (GameObject.Random(Math.Abs(diplomaticRelation) + 100) >= GameObject.Random(100)))) { firstHalfPerson = this.GetFirstHalfPerson("GossipAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100)) && ((GameObject.Random(architecture2.GetGossipablePersonCount() + 4) >= 4) && (GameObject.Random(firstHalfPerson.GossipAbility) >= 200))) { firstHalfPerson.GoForGossip(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); } } } } } } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.ConvincePersonFund)) && GameObject.Chance(50)) { ArchitectureList list4 = new ArchitectureList(); foreach (Architecture architecture in knownArch) { if (((architecture.BelongedFaction != this.BelongedFaction) && (architecture.BelongedFaction != null)) && architecture.HasPerson()) { list4.Add(architecture); } } foreach (Architecture architecture in this.BelongedFaction.Architectures) { if (architecture.HasCaptive()) { list4.Add(architecture); } } if (list4.Count > 0) { architecture2 = list4[GameObject.Random(list4.Count)] as Architecture; if (architecture2.BelongedFaction == this.BelongedFaction) { ConvinceCaptivesAI(architecture2); } else if (!this.IsFriendly(architecture2.BelongedFaction) || GameObject.Chance(50)) { diplomaticRelation = base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, architecture2.BelongedFaction.ID); if (((diplomaticRelation >= 0) && (GameObject.Random(diplomaticRelation + 50) <= GameObject.Random(50))) || (diplomaticRelation < 0)) { Person extremeLoyaltyPerson = architecture2.GetLowestLoyaltyPersonRecruitable(); if ((extremeLoyaltyPerson != null) && ((extremeLoyaltyPerson.Loyalty < 100) && (extremeLoyaltyPerson.BelongedFaction != null)) && (extremeLoyaltyPerson != extremeLoyaltyPerson.BelongedFaction.Leader)) { firstHalfPerson = this.GetFirstHalfPerson("ConvinceAbility"); if ((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(20))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && ((GameObject.Random(firstHalfPerson.ConvinceAbility) >= 200) && (GameObject.Random(firstHalfPerson.ConvinceAbility) > GameObject.Random(extremeLoyaltyPerson.Loyalty * 5)))) { firstHalfPerson.OutsideDestination = new Point?(base.Scenario.GetClosestPoint(architecture2.ArchitectureArea, this.Position)); firstHalfPerson.GoForConvince(extremeLoyaltyPerson); } } } } } } if ((this.HasPerson() && (GameObject.Random(this.Fund) >= this.JailBreakArchitectureFund)) && GameObject.Chance(50) && this.JailBreakAvail()) { List<Architecture> a = new List<Architecture>(); foreach (Architecture architecture in base.Scenario.Architectures) { if (architecture.HasFactionCaptive(this.BelongedFaction) && knownArch.GameObjects.Contains(architecture)) { a.Add(architecture); } } if (a.Count > 0) { Architecture target = a[GameObject.Random(a.Count)] as Architecture; if (GameObject.Chance(100 - target.noEscapeChance * 2)) { int totalCaptiveValue = 0; foreach (Captive c in target.Captives) { if (c.CaptiveFaction == this.BelongedFaction) { totalCaptiveValue += c.AIWantsTheCaptive; } } if (GameObject.Random(totalCaptiveValue) > GameObject.Random(100000)) { firstHalfPerson = this.GetFirstHalfPerson("JailBreakAbility"); if (((((firstHalfPerson != null) && (!this.HasFollowedLeaderMilitary(firstHalfPerson) || GameObject.Chance(10))) && (GameObject.Random(firstHalfPerson.NonFightingNumber) > GameObject.Random(firstHalfPerson.FightingNumber))) && (GameObject.Random(firstHalfPerson.FightingNumber) < 100))) { firstHalfPerson.GoForJailBreak(base.Scenario.GetClosestPoint(target.ArchitectureArea, this.Position)); } } } } } } } InformationList toRemove = new InformationList(); int dayCost = this.InformationDayCost; foreach (Information i in this.Informations) { bool stop = true; if (i.DaysStarted <= 3) { stop = false; } else if (i.DaysStarted < GameObject.Random(10) + 30 && this.IsFundIncomeEnough && this.IsFundEnough && dayCost < 500) { foreach (Point p in i.Area.Area) { Architecture a = base.Scenario.GetArchitectureByPosition(p); if (a != null && !this.IsFriendly(a.BelongedFaction)) { stop = false; break; } } } if (stop) { bool hasEnemy = false; bool hasOwn = false; foreach (Point p in i.Area.Area) { Troop t = base.Scenario.GetTroopByPosition(p); if (t != null && !this.IsFriendly(t.BelongedFaction)) { hasEnemy = true; } if (t != null && t.BelongedFaction == this.BelongedFaction) { hasOwn = true; } if (hasEnemy && hasOwn) { stop = false; break; } } } if (stop && this.PlanArchitecture != null) { foreach (Point p in i.Area.Area) { Architecture a = base.Scenario.GetArchitectureByPosition(p); if (a == this.PlanArchitecture) { stop = false; break; } } } if (!stop) { foreach (Information j in this.Informations) { if (i == j) continue; if (toRemove.GameObjects.Contains(i)) continue; if (j.Position == i.Position && j.Radius >= i.Radius && j.DayCost < i.DayCost) { stop = true; break; } } } if (stop) { toRemove.Add(i); dayCost -= i.DayCost; } } foreach (Information i in toRemove) { i.Purify(); this.RemoveInformation(i); base.Scenario.Informations.Remove(i); } }
public void addBattleEntry(bool addYearTable, GameDate date, OngoingBattle ob, Person p, ArchitectureList architectures, Dictionary<Faction, int> factionDamages) { if (factionDamages.Count < 1) return; if (p.BelongedFaction == null) return; String allFactionStrings = ""; FactionList fl = new FactionList(); foreach (Faction f in factionDamages.Keys) { allFactionStrings += "、" + (f == null ? "贼军" : f.Name); fl.Add(f); } allFactionStrings = allFactionStrings.Substring(1); String architectureStrings = ""; if (architectures.Count > 0) { foreach (Architecture a in architectures) { architectureStrings += "、" + a.Name; } architectureStrings = architectureStrings.Substring(1); } int dayDiff = (date.Year - ob.StartYear) * 360 + (date.Month - ob.StartMonth) * 30 + (date.Day - ob.StartDay) - 5; if (dayDiff <= 0) return; Dictionary<Faction, int> totalDamages = new Dictionary<Faction, int>(); foreach (Faction f in factionDamages.Keys) { totalDamages.Add(f, 0); foreach (KeyValuePair<Faction, int> pair in factionDamages) { if (f != pair.Key) { totalDamages[f] += pair.Value; } } } List<KeyValuePair<Faction, int>> damageList = totalDamages.ToList(); damageList.Sort((firstPair, nextPair) => -firstPair.Value.CompareTo(nextPair.Value)); List<KeyValuePair<Faction, int>> selfDamageList = factionDamages.ToList(); selfDamageList.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value)); String victorDescription = ""; String selfDescription = ""; if (ob.Skirmish) { if (damageList.Count > 1) { if (damageList[0].Value > damageList[1].Value * 1.5) { victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "大胜"; } else if (damageList[0].Value > damageList[1].Value * 1.2) { victorDescription = (damageList[0].Key == null ? "贼军" : damageList[0].Key.Name) + "小胜"; } else { victorDescription = "互有胜负"; } int rank = 0; foreach (KeyValuePair<Faction, int> i in damageList) { if (i.Key == p.BelongedFaction) { if (rank == 0) { if (damageList[0].Value > damageList[1].Value * 1.5) { selfDescription = "并大胜敌人"; } else if (damageList[0].Value > damageList[1].Value * 1.2) { selfDescription = "并小胜敌人"; } else { selfDescription = "互有胜负"; } } else if (rank == damageList.Count - 1) { if (damageList[0].Value > damageList[rank].Value * 1.5) { selfDescription = "却遭到大败"; } else if (damageList[0].Value > damageList[rank].Value * 1.2) { selfDescription = "却遭遇小败"; } else { selfDescription = "互有胜负"; } } } rank++; } } } if (ob.Skirmish) { if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleSkirmish"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", "", architectureStrings, "", "", dayDiff + "天", victorDescription), false); } this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleSkirmish_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", "", architectureStrings, "", "", dayDiff + "天", selfDescription)); } else { foreach (Architecture a in architectures) { if (a.BelongedFaction == null || (a.OldFactionName != a.BelongedFaction.Name)) { if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleOccupy"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天"), false); } if (p.BelongedFaction == a.BelongedFaction) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } else if (p.BelongedFaction.Name == a.OldFactionName) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_q"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } else { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleOccupy_r"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.OldFactionName, dayDiff + "天")); } } else { String offenderString = ""; if (fl.Count > 1) { foreach (Faction f in fl) { if (f != a.BelongedFaction) { offenderString += "、" + f.Name; } } offenderString = offenderString.Substring(1); } if (addYearTable) { this.addTableEntry(date, fl, String.Format(yearTableStrings["battleRetreat"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天"), false); } if (a.BelongedFaction == p.BelongedFaction) { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_p"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天")); } else { this.addPersonInGameBiography(p, date, String.Format(yearTableStrings["battleRetreat_q"], p.BelongedFaction == null ? "贼军" : p.BelongedFaction.Name, allFactionStrings + "之间", a.BelongedFaction == null ? "贼军" : a.BelongedFaction.Name, a.Name, offenderString, a.OldFactionName, dayDiff + "天")); } } } } }