本文整理汇总了C#中GameObjects.TroopList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TroopList.Add方法的具体用法?C# TroopList.Add怎么用?C# TroopList.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObjects.TroopList
的用法示例。
在下文中一共展示了TroopList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCreditWithPosition
public override int GetCreditWithPosition(Troop source, out Point? position)
{
//position = 0;
position = new Point(0, 0);
TroopList hostileTroopsInView = source.GetHostileTroopsInView();
TroopList list2 = new TroopList();
foreach (Troop troop in hostileTroopsInView)
{
if ((troop.IsInArchitecture || !troop.DaysToReachPosition(source.Position, 1)) || (troop.Army.Kind.Type == MilitaryType.水军))
{
list2.Add(troop);
}
}
foreach (Troop troop in list2)
{
hostileTroopsInView.Remove(troop);
}
if (hostileTroopsInView.Count == 0)
{
return 0;
}
List<Point> orientations = new List<Point>();
int num = 0;
foreach (Troop troop in hostileTroopsInView)
{
orientations.Add(troop.Position);
num += troop.FightingForce;
}
int num2 = 0;
int fightingForce = source.FightingForce;
int num4 = source.TroopIntelligence + source.ChanceIncrementOfStratagem;
if (num4 > 100)
{
num4 = 100;
}
num2 = (((GameObject.Square(num4) / 60) * num) / fightingForce) / 100;
if (num2 > 0)
{
GameArea area = new GameArea();
foreach (Point point in source.GetStratagemArea(source.Position).Area)
{
if (!source.Scenario.PositionIsOnFire(point) && (source.Scenario.IsPositionEmpty(point) && source.Scenario.IsFireVaild(point, false, MilitaryType.步兵)))
{
area.Area.Add(point);
}
}
if (area.Count > 0)
{
position = source.Scenario.GetClosestPosition(area, orientations);
}
else
{
num2 = 0;
}
}
return num2;
}
示例2: conflictionPathSearcher_OnCheckPosition
private PathResult conflictionPathSearcher_OnCheckPosition(Point position, List<Point> middlePath)
{
TroopList list = new TroopList();
TroopList list2 = new TroopList();
foreach (Troop troop in this.troop.BelongedFaction.KnownTroops.Values)
{
if (!troop.IsFriendly(this.troop.BelongedFaction))
{
switch (this.troop.HostileAction)
{
case HostileActionKind.EvadeEffect:
if (troop.OffenceArea.HasPoint(position))
{
list.Add(troop);
}
break;
case HostileActionKind.EvadeView:
if (troop.ViewArea.HasPoint(position))
{
list.Add(troop);
}
break;
}
}
else if (troop.Position == position)
{
list2.Add(troop);
}
}
if ((list.Count > 0) || (list2.Count > 0))
{
bool flag = false;
foreach (Troop troop in list)
{
switch (this.troop.HostileAction)
{
case HostileActionKind.NotCare:
this.troop.Scenario.SetPenalizedMapDataByPosition(troop.Position, 0xdac);
break;
case HostileActionKind.Attack:
this.troop.Scenario.SetPenalizedMapDataByPosition(troop.Position, 0xdac);
break;
case HostileActionKind.EvadeEffect:
this.troop.Scenario.SetPenalizedMapDataByArea(troop.OffenceArea, 1);
break;
case HostileActionKind.EvadeView:
this.troop.Scenario.SetPenalizedMapDataByArea(troop.ViewArea, 1);
break;
}
}
/*foreach (Troop troop in list2)
{
switch (this.troop.FriendlyAction)
{
}
}*/
flag = this.ModifyFirstTierPath(this.troop.Position, this.troop.FirstTierDestination, middlePath);
foreach (Troop troop in list)
{
switch (this.troop.HostileAction)
{
case HostileActionKind.NotCare:
this.troop.Scenario.ClearPenalizedMapDataByPosition(troop.Position);
break;
case HostileActionKind.Attack:
this.troop.Scenario.ClearPenalizedMapDataByPosition(troop.Position);
break;
case HostileActionKind.EvadeEffect:
this.troop.Scenario.ClearPenalizedMapDataByArea(troop.OffenceArea);
break;
case HostileActionKind.EvadeView:
this.troop.Scenario.ClearPenalizedMapDataByArea(troop.ViewArea);
break;
}
}
/*foreach (Troop troop in list2)
{
switch (this.troop.FriendlyAction)
{
}
}*/
if (flag)
{
return PathResult.Found;
}
return PathResult.NotFound;
}
return PathResult.Aborted;
}
示例3: AISelectPersonIntoTroop
private TroopList AISelectPersonIntoTroop(Architecture from, Military military)
{
TroopList result = new TroopList();
if (military.FollowedLeader != null && from.Persons.HasGameObject(military.FollowedLeader) && military.FollowedLeader.LocationTroop == null)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(military.FollowedLeader, from.Persons, true), military, from.Position));
}
else if (military.Leader != null && military.LeaderExperience >= 10 && (military.Leader.Strength >= 80 || military.Leader.Command >= 80 || military.Leader.HasLeaderValidTitle)
&& from.Persons.HasGameObject(military.Leader) && military.Leader.LocationTroop == null)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(military.Leader, from.Persons, true), military, from.Position));
}
else
{
GameObjectList pl = from.Persons.GetList();
pl.PropertyName = "FightingForce";
pl.IsNumber = true;
pl.SmallToBig = false;
pl.ReSort();
foreach (Person person in pl)
{
if (!person.Selected)
{
if (person.HasMilitaryKindTitle(military.Kind))
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(person, from.Persons, false), military, from.Position));
}
else if (person.HasMilitaryTypeTitle(military.Kind.Type))
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(person, from.Persons, false), military, from.Position));
}
else if ((this.BelongedFaction.AvailableMilitaryKinds.GetMilitaryKindList().GameObjects.Contains(military.Kind) && military.Kind.RecruitLimit > 10) ||
person.FightingForce >= Parameters.AIUniqueTroopFightingForceThreshold || this.Endurance < 30)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(person, from.Persons, false), military, from.Position));
}
}
}
}
return result;
}
示例4: GetHostileTroopsInView
public TroopList GetHostileTroopsInView()
{
GameArea viewArea = this.ViewArea;
if ((this.RecentlyAttacked > 0) || (this.ArmyScale > this.LargeArmyScale))
{
viewArea = this.LongViewArea;
}
TroopList list = new TroopList();
foreach (Point point in viewArea.Area)
{
Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
if ((troopByPosition != null) && (!troopByPosition.IsFriendly(this.BelongedFaction) && (troopByPosition.Status != TroopStatus.埋伏)))
{
int days = 1;
if ((((this.BelongedFaction != null) && (troopByPosition.BelongedFaction != null)) && (this.RecentlyAttacked <= 0)) && (base.Scenario.GetDiplomaticRelation(this.BelongedFaction.ID, troopByPosition.BelongedFaction.ID) >= 0))
{
days = 0;
}
if (troopByPosition.DaysToReachPosition(base.Scenario.GetClosestPoint(this.ArchitectureArea, troopByPosition.Position), days))
{
list.Add(troopByPosition);
}
}
}
return list;
}
示例5: 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++;
}
//.........这里部分代码省略.........
示例6: GetSurroundAttackingTroop
public TroopList GetSurroundAttackingTroop(Troop troop)
{
TroopList list = new TroopList();
foreach (Point point in GameArea.GetArea(troop.Position, 1, true).Area)
{
if (point == troop.Position)
{
continue;
}
Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
if ((troopByPosition != null) && ((troopByPosition == this) || ((this.IsFriendly(troopByPosition.BelongedFaction) && troopByPosition.SurroundAvail()) && troopByPosition.CanAttack(troop))))
{
list.Add(troopByPosition);
}
}
return list;
}
示例7: AISelectPersonIntoTroop
private TroopList AISelectPersonIntoTroop(Architecture from, Military military)
{
TroopList result = new TroopList();
if ((military.FollowedLeader != null) && from.Persons.HasGameObject(military.FollowedLeader) && military.FollowedLeader.LocationTroop == null)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(military.FollowedLeader, from.Persons, true), military, from.Position));
}
else if ((((military.Leader != null) && (military.LeaderExperience >= 10)) && (((military.Leader.Strength >= 80) || (military.Leader.Command >= 80)) || military.Leader.HasLeaderValidCombatTitle))
&& from.Persons.HasGameObject(military.Leader) && military.Leader.LocationTroop == null)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(military.Leader, from.Persons, true), military, from.Position));
}
else
{
foreach (Person person in from.Persons)
{
if (!person.Selected)
{
if ((this.BelongedFaction.AvailableMilitaryKinds.GetMilitaryKindList().GameObjects.Contains(military.Kind) && !military.Kind.Unique) ||
person.FightingForce >= Parameters.AIUniqueTroopFightingForceThreshold || this.Endurance < 30)
{
result.Add(Troop.CreateSimulateTroop(this.AISelectPersonIntoTroop_inner(person, from.Persons, false), military, from.Position));
}
}
}
}
return result;
}
示例8: BeRouted
public void BeRouted()
{
if (this.BelongedFaction == null)
{
this.Destroy();
base.Scenario.Militaries.Remove(this.Army);
base.Scenario.Troops.RemoveTroop(this);
if ((this.StartingArchitecture != null) && (this.StartingArchitecture.RobberTroop == this))
{
this.StartingArchitecture.RobberTroop = null;
}
if (this.OrientationTroop != null)
{
this.OrientationTroop.OperationDone = !this.OrientationTroop.CanAttackAfterRout;
}
}
else
{
bool flag = false;
if ((this.BelongedFaction.Leader == this.Leader) && (this.BelongedFaction.ArchitectureCount == 0))
{
flag = true;
}
foreach (Person person in this.Persons)
{
if ((this.StartingArchitecture == null) || (this.BelongedFaction != this.StartingArchitecture.BelongedFaction))
{
if (this.BelongedFaction.Capital != null)
{
this.StartingArchitecture = this.BelongedFaction.Capital;
}
else
{
this.BelongedFaction.RemovePerson(person);
}
}
if (this.StartingArchitecture != null)
{
person.MoveToArchitecture(this.StartingArchitecture);
}
else if (base.Scenario.Architectures.Count > 0)
{
person.MoveToArchitecture(base.Scenario.Architectures[0] as Architecture);
}
person.LocationTroop = null;
}
this.Destroy();
this.BelongedLegion.RemoveTroop(this);
if (this.Army.ShelledMilitary == null)
{
this.BelongedFaction.RemoveMilitary(this.Army);
}
else
{
this.BelongedFaction.RemoveMilitary(this.Army.ShelledMilitary);
base.Scenario.Militaries.Remove(this.Army.ShelledMilitary);
}
base.Scenario.Militaries.Remove(this.Army);
if (flag)
{
TroopList list = new TroopList();
foreach (Troop troop in this.BelongedFaction.Troops)
{
if (troop != this)
{
list.Add(troop);
}
}
foreach (Troop troop in list)
{
troop.FactionDestroy();
}
this.BelongedFaction.Destroy();
}
else
{
this.BelongedFaction.RemoveTroop(this);
}
base.Scenario.Troops.RemoveTroop(this);
if ((this.OrientationTroop != null) && !this.ProhibitAllAction)
{
this.OrientationTroop.OperationDone = !this.OrientationTroop.CanAttackAfterRout && !this.OrientationTroop.StuntCanAttackAfterRout;
if (!(this.OrientationTroop.OperationDone || this.OrientationTroop.QueueEnded))
{
this.OrientationTroop.AttackedTroopList.Clear();
}
}
}
}
示例9: DayEvent
public void DayEvent()
{
if (this.BelongedFaction != null)
{
this.ViewingWillArchitecture = this.IsViewingWillArchitecture();
this.ContactingWillArchitecture = this.IsContactingWillArchitecture();
this.OffencingWillArchitecture = this.IsOffencingWillArchitecture();
this.ContactHostileTroopCount = this.GetContactHostileTroops().Count;
this.ContactFriendlyTroopCount = this.GetContactFriendlyTroops().Count;
this.SetFriendlyTroopsInView();
this.SetHostileTroopsInView();
}
if (this.StartingArchitecture != null)
{
}
if ((this.IncrementPerDayOfCombativity + this.CombativityIncrementPerDayByViewArea) > 0)
{
this.IncreaseCombativity(this.IncrementPerDayOfCombativity + this.CombativityIncrementPerDayByViewArea);
}
if ((this.DecrementPerDayOfCombativity + this.CombativityDecrementPerDayByViewArea) > 0)
{
this.DecreaseCombativity(this.DecrementPerDayOfCombativity + this.CombativityDecrementPerDayByViewArea);
}
if ((this.InjuryRecoveryPerDayRate > 0f) && (this.InjuryQuantity > 0))
{
int number = this.Army.Recovery(this.InjuryRecoveryPerDayRate);
if (number > 0)
{
this.RefreshOffence();
this.RefreshDefence();
this.IncrementNumberList.AddNumber(number, CombatNumberKind.人数, this.Position);
this.ShowNumber = true;
}
}
if (this.ChaosDayLeft > 0)
{
this.ChaosDayLeft--;
if ((this.ChaosDayLeft == 0) || this.StuntRecoverFromChaos)
{
this.SetRecoverFromChaos();
}
}
if (base.Scenario.FireTable.HasPosition(this.Position))
{
this.SetOnFire(Parameters.FireDamageScale * base.Scenario.GetTerrainDetailByPositionNoCheck(this.Position).FireDamageRate);
}
if (this.CutRoutewayDays > 0)
{
this.CutRoutewayDays--;
if (this.CutRoutewayDays == 0)
{
this.CutPositionRouteway();
}
else if (this.CheckPositionRouteway())
{
this.Controllable = false;
this.Operated = true;
}
else
{
this.CutRoutewayDays = 0;
if (this.OnEndCutRouteway != null)
{
this.OnEndCutRouteway(this, false);
}
}
}
if (this.Food >= this.FoodCostPerDay)
{
this.Food -= this.FoodCostPerDay;
this.RefillFoodByArchitecture();
this.RefillFoodByRouteway();
}
else
{
this.RefillFoodByArchitecture();
this.RefillFoodByRouteway();
if (this.Food < this.FoodCostPerDay)
{
this.Food = 0;
if (this.RecentlyFighting > 0)
{
this.DecreaseCombativity(10);
this.DecreaseMorale((int) (10f * this.MoraleChangeRateOnOutOfFood));
}
else
{
this.DecreaseCombativity(5);
this.DecreaseMorale(5);
}
CheckTroopRout(this);
}
else
{
this.Food -= this.FoodCostPerDay;
}
}
if (this.BelongedFaction != null)
{
foreach (TroopEvent event2 in base.Scenario.TroopEvents.GetRandomList())
//.........这里部分代码省略.........
示例10: BeRouted
public void BeRouted()
{
if (this.BelongedFaction == null)
{
this.Destroy(true, true);
if (this.StartingArchitecture != null && this.StartingArchitecture.RobberTroop == this) //盗贼队
{
this.StartingArchitecture.RobberTroop = null;
this.StartingArchitecture.RobberTroopID = -1;
}
if (this.OrientationTroop != null)
{
this.OrientationTroop.OperationDone = !this.OrientationTroop.CanAttackAfterRout;
}
}
else
{
if (this.IsTransport && this.WillArchitecture != null)
{
this.WillArchitecture.SuspendTroopTransfer = 0;
}
bool flag = false;
if ((this.BelongedFaction.Leader == this.Leader) && (this.BelongedFaction.ArchitectureCount == 0))
{
//flag = true;
}
Faction f = this.BelongedFaction;
this.Destroy(true, true);
foreach (Person p in this.persons)
{
foreach (Person q in this.persons)
{
if (p == q) continue;
p.AdjustRelation(q, -0.5f / (this.persons.Count - 1), -3);
}
}
foreach (Person person in this.persons)
{
Point from = this.Position;
if ((this.StartingArchitecture == null) || (f != this.StartingArchitecture.BelongedFaction))
{
if (f.Capital != null)
{
this.StartingArchitecture = f.Capital;
}
}
if (this.StartingArchitecture != null)
{
person.LocationArchitecture = this.StartingArchitecture;
person.MoveToArchitecture(this.StartingArchitecture, from);
}
person.LocationTroop = null;
}
this.persons.Clear();
if (flag)
{
TroopList list = new TroopList();
foreach (Troop troop in this.BelongedFaction.Troops)
{
if (troop != this)
{
list.Add(troop);
}
}
foreach (Troop troop in list)
{
troop.FactionDestroy();
}
this.BelongedFaction.Destroy();
}
if ((this.OrientationTroop != null) && !this.ProhibitAllAction)
{
this.OrientationTroop.OperationDone = !this.OrientationTroop.CanAttackAfterRout && !this.OrientationTroop.StuntCanAttackAfterRout;
if (!(this.OrientationTroop.OperationDone || this.OrientationTroop.QueueEnded))
{
this.OrientationTroop.AttackedTroopList.Clear();
}
}
}
ExtensionInterface.call("BeRouted", new Object[] { this.Scenario, this });
}
示例11: DayEvent
public void DayEvent()
{
if (!GameObject.Chance(this.chanceTirednessStopIncrease))
{
this.Army.Tiredness += GlobalVariables.TirednessIncrease;
}
foreach (Person p in this.Persons)
{
if (!GameObject.Chance(p.chanceTirednessStopIncrease) && !GameObject.Chance(this.chanceTirednessStopIncrease))
{
p.Tiredness += GlobalVariables.TirednessIncrease;
}
}
if (this.BelongedFaction != null)
{
this.ViewingWillArchitecture = this.IsViewingWillArchitecture();
this.ContactingWillArchitecture = this.IsContactingWillArchitecture();
this.OffencingWillArchitecture = this.IsOffencingWillArchitecture();
this.ContactHostileTroopCount = this.GetContactHostileTroops().Count;
this.ContactFriendlyTroopCount = this.GetContactFriendlyTroops().Count;
this.SetFriendlyTroopsInView();
this.SetHostileTroopsInView();
}
if (this.StartingArchitecture != null)
{
}
if ((this.IncrementPerDayOfCombativity + this.CombativityIncrementPerDayByViewArea) > 0)
{
this.IncreaseCombativity(this.IncrementPerDayOfCombativity + this.CombativityIncrementPerDayByViewArea);
}
if ((this.DecrementPerDayOfCombativity + this.CombativityDecrementPerDayByViewArea) > 0)
{
this.DecreaseCombativity(this.DecrementPerDayOfCombativity + this.CombativityDecrementPerDayByViewArea);
}
if ((this.InjuryRecoveryPerDayRate > 0f) && (this.InjuryQuantity > 0))
{
int number = this.Army.Recovery(this.InjuryRecoveryPerDayRate);
if (number > 0)
{
this.RefreshOffence();
this.RefreshDefence();
this.IncrementNumberList.AddNumber(number, CombatNumberKind.人数, this.Position);
this.ShowNumber = true;
}
}
if (this.ChaosDayLeft > 0)
{
this.ChaosDayLeft--;
if ((this.ChaosDayLeft == 0) || this.StuntRecoverFromChaos)
{
this.SetRecoverFromChaos();
}
}
if (base.Scenario.FireTable.HasPosition(this.Position))
{
this.SetOnFire(Parameters.FireDamageScale * base.Scenario.GetTerrainDetailByPositionNoCheck(this.Position).FireDamageRate);
}
if (this.CutRoutewayDays > 0)
{
this.CutRoutewayDays--;
if (this.CutRoutewayDays == 0)
{
this.CutPositionRouteway();
}
else if (this.CheckPositionRouteway())
{
this.Controllable = false;
this.Operated = true;
}
else
{
this.CutRoutewayDays = 0;
if (this.OnEndCutRouteway != null)
{
this.OnEndCutRouteway(this, false);
}
}
}
if (this.Food >= this.FoodCostPerDay)
{
this.Food -= this.FoodCostPerDay;
this.RefillFood();
}
else
{
this.RefillFood();
if (this.Food < this.FoodCostPerDay)
{
this.Food = 0;
if (this.RecentlyFighting > 0)
{
this.DecreaseCombativity(10);
this.DecreaseMorale((int)(10f * this.MoraleChangeRateOnOutOfFood));
}
else
{
this.DecreaseCombativity(5);
//.........这里部分代码省略.........
示例12: ResetFaction
public void ResetFaction(Faction faction)
{
this.ResetAuto();
if ((faction != null) && base.Scenario.IsPlayer(faction))
{
this.AutoHiring = true;
this.AutoRewarding = true;
}
if (this.BelongedFaction != null)
{
this.ClearFundPacks();
this.ClearRouteways();
this.ReleaseAllCaptive();
this.BelongedSection.RemoveArchitecture(this);
this.DefensiveLegion = null;
if (this == this.BelongedFaction.Capital)
{
Person leader = this.BelongedFaction.Leader;
foreach (Person person2 in this.Persons)
{
this.BelongedFaction.RemovePerson(person2);
this.AddNoFactionPerson(person2);
}
this.Persons.Clear();
foreach (Person person2 in this.MovingPersons)
{
person2.OutsideTask = OutsideTaskKind.无;
person2.TaskDays = 0;
if (person2.BelongedFaction != null)
{
person2.BelongedFaction.RemovePerson(person2);
}
}
this.MovingPersons.Clear();
if ((leader.LocationTroop == null) || leader.IsCaptive)
{
TroopList list = new TroopList();
foreach (Troop troop in this.BelongedFaction.Troops)
{
list.Add(troop);
}
foreach (Troop troop in list)
{
troop.FactionDestroy();
}
this.BelongedFaction.Destroy();
if (faction != null)
{
faction.CheckLeaderDeath(leader);
}
}
this.BelongedFaction.Capital = null;
}
else
{
PersonList list2 = new PersonList();
foreach (Person person2 in this.Persons)
{
person2.MoveToArchitecture(this.BelongedFaction.Capital);
list2.Add(person2);
}
foreach (Person person2 in list2)
{
this.RemovePerson(person2);
}
foreach (Person person2 in this.MovingPersons)
{
person2.MoveToArchitecture(this.BelongedFaction.Capital);
}
this.MovingPersons.Clear();
}
if (this.BelongedFaction != null)
{
this.BelongedFaction.RemoveArchitectureMilitaries(this);
this.BelongedFaction.RemoveArchitectureKnownData(this);
this.BelongedFaction.RemoveArchitecture(this);
}
if (faction != null)
{
faction.AddArchitecture(this);
faction.AddArchitectureMilitaries(this);
faction.AddArchitecturePersons(this);
}
else
{
this.BelongedFaction = null;
}
}
else if (faction != null)
{
faction.AddArchitecture(this);
faction.AddArchitectureMilitaries(this);
}
if (faction != null)
{
this.jianzhuqizi.qizidezi.Text = faction.ToString().Substring(0, 1);
}
//.........这里部分代码省略.........
示例13: 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;
}
//.........这里部分代码省略.........
示例14: 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);
//.........这里部分代码省略.........
示例15: GetContactHostileTroops
public TroopList GetContactHostileTroops()
{
TroopList list = new TroopList();
foreach (Point point in GameArea.GetArea(this.Position, 1, true).Area)
{
if ((point != this.Position) && this.BelongedFaction.IsPositionKnown(point))
{
Troop troopByPosition = base.Scenario.GetTroopByPosition(point);
if (!((troopByPosition == null) || this.IsFriendly(troopByPosition.BelongedFaction)))
{
list.Add(troopByPosition);
}
}
}
return list;
}