本文整理汇总了C#中GameObjects.TroopList.GetList方法的典型用法代码示例。如果您正苦于以下问题:C# TroopList.GetList方法的具体用法?C# TroopList.GetList怎么用?C# TroopList.GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObjects.TroopList
的用法示例。
在下文中一共展示了TroopList.GetList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefensiveCampaign
private void DefensiveCampaign()
{
DateTime beforeStart = DateTime.UtcNow;
List<Point> orientations = new List<Point>();
TroopList hostileTroopsInView = this.GetHostileTroopsInView();
foreach (Troop troop in hostileTroopsInView)
{
orientations.Add(troop.Position);
}
if ((this.HasPerson() && this.HasCampaignableMilitary()) && (this.GetAllAvailableArea(false).Count != 0))
{
if (hostileTroopsInView.Count > 0)
{
TroopList friendlyTroopsInView = this.GetFriendlyTroopsInView();
int troopSent = 0;
int militaryCount = this.MilitaryCount;
Troop troop2;
TroopList list4 = new TroopList();
bool isBesideWater = this.IsBesideWater;
foreach (Military military in this.Militaries.GetRandomList())
{
if (military.IsFewScaleNeedRetreat && this.Endurance >= 30) continue;
if ((isBesideWater || (military.Kind.Type != MilitaryType.水军)) && (((((this.Endurance < 30) || military.Kind.AirOffence) || (military.Scales >= 2)) && (military.Morale > 0x2d)) && ((this.Endurance < 30) || (military.InjuryQuantity < military.Kind.MinScale))))
{
TroopList candidates = this.AISelectPersonIntoTroop(this, military);
foreach (Troop t in candidates)
{
list4.Add(t);
if (DateTime.UtcNow - beforeStart > new TimeSpan(0, 0, Parameters.MaxAITroopTime))
{
break;
}
}
}
if (DateTime.UtcNow - beforeStart > new TimeSpan(0, 0, Parameters.MaxAITroopTime))
{
break;
}
}
if (list4.Count > 0)
{
list4.IsNumber = true;
list4.PropertyName = "FightingForce";
list4.ReSort();
foreach (Troop troop in list4.GetList())
{
if (troop.FightingForce < 10000 && troop.FightingForce < (this.TotalHostileForce * 5 - this.TotalFriendlyForce) / 25)
{
break;
}
if (troop.Army.Scales < 5 && this.Endurance > 30)
{
continue;
}
bool personAlreadyOut = false;
foreach (Person p in troop.Candidates)
{
if (p.LocationTroop != null)
{
personAlreadyOut = true;
break;
}
}
if (personAlreadyOut) continue;
bool militaryOut = true;
foreach (Military m in this.Militaries)
{
if (troop.Army == m)
{
militaryOut = false;
break;
}
}
if (militaryOut) continue;
Point? nullable = this.GetCampaignPosition(troop, orientations, troop.Army.Scales > 0);
if (!nullable.HasValue)
{
break;
}
Person leader = troop.Candidates[0] as Person;
PersonList candidates = this.SelectSubOfficersToTroop(troop);
troop2 = this.CreateTroop(candidates, leader, troop.Army, -1, nullable.Value);
troop2.WillArchitecture = this;
if (this.DefensiveLegion == null)
{
this.CreateDefensiveLegion();
}
this.DefensiveLegion.AddTroop(troop2);
this.PostCreateTroop(troop2, false);
this.TotalFriendlyForce += troop2.FightingForce;
troopSent++;
}
//.........这里部分代码省略.........
示例2: DefensiveCampaign
private void DefensiveCampaign()
{
if ((this.HasPerson() && this.HasCampaignableMilitary()) && (this.GetAllAvailableArea(false).Count != 0))
{
TroopList hostileTroopsInView = this.GetHostileTroopsInView();
if (hostileTroopsInView.Count > 0)
{
List<Point> orientations = new List<Point>();
foreach (Troop troop in hostileTroopsInView)
{
orientations.Add(troop.Position);
}
TroopList friendlyTroopsInView = this.GetFriendlyTroopsInView();
int num = 0;
int militaryCount = this.MilitaryCount;
while ((num < militaryCount) && (this.TotalFriendlyForce < (this.TotalHostileForce * 5)))
{
Troop troop2;
num++;
int num3 = (this.TotalHostileForce * 5) - this.TotalFriendlyForce;
TroopList list4 = new TroopList();
bool isBesideWater = this.IsBesideWater;
//Label_033D:
foreach (Military military in this.Militaries.GetRandomList())
{
if ((isBesideWater || (military.Kind.Type != MilitaryType.水军)) && (((((this.Endurance < 30) || military.Kind.AirOffence) || (military.Scales >= 2)) && (military.Morale > 0x2d)) && ((this.Endurance < 30) || (military.InjuryQuantity < military.Kind.MinScale))))
{
PersonList list5;
if ((military.FollowedLeader != null) && this.Persons.HasGameObject(military.FollowedLeader))
{
list5 = new PersonList();
list5.Add(military.FollowedLeader);
military.FollowedLeader.Selected = true;
troop2 = Troop.CreateSimulateTroop(list5, military, this.Position);
list4.Add(troop2);
}
else
{
if ((((military.Leader != null) && (military.LeaderExperience >= 200)) && (((military.Leader.Strength >= 80) || (military.Leader.Command >= 80)) || military.Leader.HasLeaderValidCombatTitle)) && this.Persons.HasGameObject(military.Leader))
{
list5 = new PersonList();
list5.Add(military.Leader);
military.Leader.Selected = true;
troop2 = Troop.CreateSimulateTroop(list5, military, this.Position);
list4.Add(troop2);
//goto Label_033D;
continue;
}
foreach (Person person in this.Persons)
{
if (!person.Selected)
{
list5 = new PersonList();
list5.Add(person);
troop2 = Troop.CreateSimulateTroop(list5, military, this.Position);
list4.Add(troop2);
}
}
}
}
}
if (list4.Count <= 0)
{
break;
}
list4.IsNumber = true;
list4.PropertyName = "FightingForce";
list4.ReSort();
foreach (Troop troop in list4.GetList())
{
if (((troop.FightingForce < 0x2710) && (troop.FightingForce < (num3 / 0x19))) && (troop.Army.Scales < 10))
{
return;
}
Point? nullable = this.GetCampaignPosition(troop, orientations, troop.Army.Scales > 0);
if (!nullable.HasValue)
{
return;
}
if (troop.Army.Kind.AirOffence && (troop.Army.Scales < 2))
{
Architecture architectureByPositionNoCheck = base.Scenario.GetArchitectureByPositionNoCheck(nullable.Value);
if ((architectureByPositionNoCheck == null) || (architectureByPositionNoCheck.Endurance == 0))
{
continue;
}
}
Person leader = troop.Persons[0] as Person;
this.AddPersonToTroop(troop);
troop2 = this.CreateTroop(troop.Persons, leader, troop.Army, -1, nullable.Value);
troop2.WillArchitecture = this;
if (this.DefensiveLegion == null)
{
this.CreateDefensiveLegion();
}
this.DefensiveLegion.AddTroop(troop2);
this.PostCreateTroop(troop2, false);
this.TotalFriendlyForce += troop2.FightingForce;
break;
}
//.........这里部分代码省略.........
示例3: BuildOffensiveTroop
private Troop BuildOffensiveTroop(Architecture destination, LinkKind linkkind, bool offensive)
{
Troop troop;
if (linkkind == LinkKind.None)
{
return null;
}
TroopList list = new TroopList();
this.Persons.ClearSelected();
//Label_0309:
foreach (Military military in this.Militaries.GetRandomList())
{
if (military.Scales < military.RetreatScale * 1.5) continue;
if (military.IsTransport) continue; //never deal with transports in this function
switch (linkkind)
{
case LinkKind.Land:
{
if (military.Kind.Type != MilitaryType.水军)
{
break;
}
continue;
}
case LinkKind.Water:
{
//if ((military.Kind.Type == MilitaryType.水军) || (this.ValueWater && (!offensive || ((military.Quantity >= 0x1f40) && (GameObject.Random(military.Kind.Merit) <= 0)))))
if (GlobalVariables.LandArmyCanGoDownWater)
{
if (!offensive || (military.KindID != 28 && !military.IsTransport))
{
break;
}
}
else
{
if (military.Kind.Type == MilitaryType.水军)
{
break;
}
}
continue;
}
}
if ((((military.Scales > 5) && (military.Morale >= 80)) && (military.Combativity >= 80)) && (military.InjuryQuantity < military.Kind.MinScale)
&& (!offensive ||
(military.Merit > 0)
)) //do not use transport teams to attack
{
TroopList candidates = this.AISelectPersonIntoTroop(this, military);
foreach (Troop t in candidates)
{
list.Add(t);
}
}
}
if (list.Count > 0)
{
list.IsNumber = true;
list.PropertyName = "SimulatingFightingForce";
list.ReSort();
foreach (Troop troop2 in list.GetList())
{
bool personAlreadyOut = false;
foreach (Person p in troop2.Candidates)
{
if (p.LocationTroop != null)
{
personAlreadyOut = true;
break;
}
}
bool militaryOut = true;
foreach (Military m in this.Militaries)
{
if (troop2.Army == m)
{
militaryOut = false;
break;
}
}
if (personAlreadyOut) continue;
if (militaryOut) continue;
if (troop2.FightingForce < 10000 && offensive)
{
break;
}
Point? nullable = this.GetRandomStartingPosition(troop2);
if (!nullable.HasValue)
{
break;
}
Person leader = troop2.Candidates[0] as Person;
PersonList candidates = this.SelectSubOfficersToTroop(troop2);
troop = this.CreateTroop(candidates, leader, troop2.Army, -1, nullable.Value);
troop.WillArchitecture = destination;
Legion legion = this.BelongedFaction.GetLegion(destination);
if (legion == null)
{
legion = this.CreateOffensiveLegion(destination);
//.........这里部分代码省略.........
示例4: BuildOffensiveTroop
private Troop BuildOffensiveTroop(Architecture destination, LinkKind linkkind, bool offensive)
{
Troop troop;
if (linkkind == LinkKind.None)
{
return null;
}
TroopList list = new TroopList();
this.Persons.ClearSelected();
//Label_0309:
foreach (Military military in this.Militaries.GetRandomList())
{
switch (linkkind)
{
case LinkKind.Land:
{
if (military.Kind.Type != MilitaryType.水军)
{
break;
}
continue;
}
case LinkKind.Water:
{
if ((military.Kind.Type == MilitaryType.水军) || (this.ValueWater && (!offensive || ((military.Quantity >= 0x1f40) && (GameObject.Random(military.Kind.Merit) <= 0)))))
{
break;
}
continue;
}
}
if ((((military.Scales >= 3) && (military.Morale >= 80)) && (military.Combativity >= 80)) && (military.InjuryQuantity < military.Kind.MinScale))
{
PersonList list2;
Military military2 = military;
if ((linkkind == LinkKind.Water) && (military.Kind.Type != MilitaryType.水军))
{
Military military3 = Military.SimCreate(base.Scenario, this, base.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(0x1c));
military3.SetShelledMilitary(military);
military2 = military3;
}
if ((military2.FollowedLeader != null) && this.Persons.HasGameObject(military2.FollowedLeader))
{
list2 = new PersonList();
list2.Add(military2.FollowedLeader);
military2.FollowedLeader.Selected = true;
troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
list.Add(troop);
//goto Label_0309;
continue;
}
if ((((military2.Leader != null) && (military2.LeaderExperience >= 200)) && (((military2.Leader.Strength >= 80) || (military2.Leader.Command >= 80)) || military2.Leader.HasLeaderValidCombatTitle)) && this.Persons.HasGameObject(military2.Leader))
{
list2 = new PersonList();
list2.Add(military2.Leader);
military2.Leader.Selected = true;
troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
list.Add(troop);
//goto Label_0309;
continue;
}
foreach (Person person in this.Persons)
{
if (!person.Selected && (person.Command >= 40))
{
list2 = new PersonList();
list2.Add(person);
troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
list.Add(troop);
}
}
}
}
if (list.Count > 0)
{
list.IsNumber = true;
list.PropertyName = "SimulatingFightingForce";
list.ReSort();
foreach (Troop troop2 in list.GetList())
{
if (troop2.FightingForce < 0x2710)
{
break;
}
Point? nullable = this.GetCampaignPosition(troop2, destination.ArchitectureArea.Area, true);
if (!nullable.HasValue)
{
break;
}
Person leader = troop2.Persons[0] as Person;
this.AddPersonToTroop(troop2);
troop = this.CreateTroop(troop2.Persons, leader, troop2.Army, -1, nullable.Value);
troop.WillArchitecture = destination;
Legion legion = this.BelongedFaction.GetLegion(destination);
if (legion == null)
{
legion = this.CreateOffensiveLegion(destination);
}
legion.AddTroop(troop);
this.PostCreateTroop(troop, false);
//.........这里部分代码省略.........