private void AddAllAILink(int level, int levelMax, Architecture root, List<Architecture> path) { path.Add(root); if (root != this) { double num = 0.0; for (int i = 1; i < path.Count; i++) { num += base.Scenario.GetDistance(path[i - 1].ArchitectureArea, path[i].ArchitectureArea); } if (!this.AIAllLinkNodes.ContainsKey(root.ID)) { LinkNode node = new LinkNode(); node.A = root; node.Level = level; foreach (Architecture architecture in path) { node.Path.Add(architecture); } node.Distance = num; this.AIAllLinkNodes.Add(root.ID, node); } else if ((this.AIAllLinkNodes[root.ID].Level == level) && (this.AIAllLinkNodes[root.ID].Distance > num)) { this.AIAllLinkNodes[root.ID].Distance = num; this.AIAllLinkNodes[root.ID].Path.Clear(); foreach (Architecture architecture in path) { this.AIAllLinkNodes[root.ID].Path.Add(architecture); } } else if (this.AIAllLinkNodes[root.ID].Level > level) { this.AIAllLinkNodes[root.ID].Level = level; this.AIAllLinkNodes[root.ID].Path.Clear(); foreach (Architecture architecture in path) { this.AIAllLinkNodes[root.ID].Path.Add(architecture); } } } if (level < levelMax) { foreach (Architecture architecture in root.GetAILinks()) { this.AILinkProcedureDetails.Enqueue(new AILinkProcedureDetail(level + 1, architecture, path)); } } }
internal bool IsSelfMoveArmyEnough(LinkNode node) { switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: return (((((this.IsImportant && (this.HostileLine || this.FrontLine)) && (this.LandArmyScale > this.LargeArmyScale)) || (((this.IsImportant && !this.FrontLine) && (this.LandArmyScale > this.NormalArmyScale)) || ((!this.IsImportant && this.HostileLine) && (this.LandArmyScale > this.LargeArmyScale)))) || ((!this.IsImportant && this.FrontLine) && (this.LandArmyScale > this.NormalArmyScale))) || ((!this.IsImportant && !this.FrontLine) && (this.LandArmyScale > this.FewArmyScale))); case LinkKind.Water: return (((((this.IsImportant && (this.HostileLine || this.FrontLine)) && (this.WaterArmyScale > this.LargeArmyScale)) || (((this.IsImportant && !this.FrontLine) && (this.WaterArmyScale > this.NormalArmyScale)) || ((!this.IsImportant && this.HostileLine) && (this.WaterArmyScale > this.LargeArmyScale)))) || ((!this.IsImportant && this.FrontLine) && (this.WaterArmyScale > this.NormalArmyScale))) || ((!this.IsImportant && !this.FrontLine) && (this.WaterArmyScale > this.FewArmyScale))); case LinkKind.Both: return (((((this.IsImportant && (this.HostileLine || this.FrontLine)) && (this.ArmyScale > this.LargeArmyScale)) || (((this.IsImportant && !this.FrontLine) && (this.ArmyScale > this.NormalArmyScale)) || ((!this.IsImportant && this.HostileLine) && (this.ArmyScale > this.LargeArmyScale)))) || ((!this.IsImportant && this.FrontLine) && (this.ArmyScale > this.NormalArmyScale))) || ((!this.IsImportant && !this.FrontLine) && (this.ArmyScale > this.FewArmyScale))); } return false; }
internal bool IsSelfOffensiveArmyEnough(LinkNode node) { switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: return (((!base.Scenario.IsPlayer(node.A.BelongedFaction) && this.LandArmyScale > this.LargeArmyScale) || (node.A.IsImportant && (this.LandArmyScale > node.A.ArmyScale))) || (!node.A.IsImportant && ((this.LandArmyScale * 2) > (node.A.ArmyScale * 3)))); case LinkKind.Water: return (((!base.Scenario.IsPlayer(node.A.BelongedFaction) && this.WaterArmyScale > this.LargeArmyScale) || (node.A.IsImportant && (this.WaterArmyScale > node.A.ArmyScale))) || (!node.A.IsImportant && ((this.WaterArmyScale * 2) > (node.A.ArmyScale * 3)))); case LinkKind.Both: return (((!base.Scenario.IsPlayer(node.A.BelongedFaction) && this.ArmyScale > this.LargeArmyScale) || (node.A.IsImportant && (this.ArmyScale > node.A.ArmyScale))) || ((!node.A.IsImportant && (this.ArmyScale > this.NormalArmyScale)) && ((this.ArmyScale * 2) > (node.A.ArmyScale * 3)))); } return false; }
internal bool IsSelfFoodEnoughForOffensive(LinkNode node, Routeway routeway) { MilitaryList cropConsumptionOrderedList = Militaries; cropConsumptionOrderedList.PropertyName = "FoodCostPerDay"; cropConsumptionOrderedList.IsNumber = true; cropConsumptionOrderedList.ReSort(); PersonList leaderablePersonList = new PersonList(); foreach (Person p in this.Persons) { if (p.Command >= 40) { leaderablePersonList.Add(p); } } switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: { int crop = 0; int troopCnt = 0; foreach (Military m in cropConsumptionOrderedList) { if ((((m.Scales >= 3) && (m.Morale >= 80)) && (m.Combativity >= 80)) && (m.InjuryQuantity < m.Kind.MinScale) && m.Kind.Type != MilitaryType.水军) { crop += m.FoodCostPerDay; troopCnt++; if (troopCnt >= leaderablePersonList.Count) break; } } if (routeway.LastPoint == null) return false; return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (crop * (routeway.Length + 6))); } case LinkKind.Water: { int crop = 0; int troopCnt = 0; foreach (Military m in cropConsumptionOrderedList) { if ((((m.Scales >= 3) && (m.Morale >= 80)) && (m.Combativity >= 80)) && (m.InjuryQuantity < m.Kind.MinScale) && m.Kind.Type == MilitaryType.水军) { crop += m.FoodCostPerDay; troopCnt++; if (troopCnt >= leaderablePersonList.Count) break; } } if (routeway.LastPoint == null) return false; return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (crop * (routeway.Length + 6))); } case LinkKind.Both: { int crop = 0; int troopCnt = 0; foreach (Military m in cropConsumptionOrderedList) { if ((((m.Scales >= 3) && (m.Morale >= 80)) && (m.Combativity >= 80)) && (m.InjuryQuantity < m.Kind.MinScale)) { crop += m.FoodCostPerDay; troopCnt++; if (troopCnt >= leaderablePersonList.Count) break; } } if (routeway.LastPoint == null) return false; return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (crop * ((routeway.Length + 6) - (this.ArmyScale / 8)))); } } return false; }
internal bool IsSelfHelpArmyEnough(LinkNode node) { switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: return ((!this.IsImportant && (this.LandArmyScale >= this.FewArmyScale)) || (this.LandArmyScale >= this.NormalArmyScale)); case LinkKind.Water: return ((!this.IsImportant && (this.WaterArmyScale >= this.FewArmyScale)) || (this.WaterArmyScale >= this.NormalArmyScale)); case LinkKind.Both: return ((!this.IsImportant && (this.ArmyScale >= this.FewArmyScale)) || (this.ArmyScale >= this.NormalArmyScale)); } return false; }
internal bool IsNodeHelpArmyEnough(LinkNode node) { switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: return ((!node.A.IsImportant && (node.A.LandArmyScale >= node.A.FewArmyScale)) || (node.A.LandArmyScale >= node.A.NormalArmyScale)); case LinkKind.Water: return ((!node.A.IsImportant && (node.A.WaterArmyScale >= node.A.FewArmyScale)) || (node.A.WaterArmyScale >= node.A.NormalArmyScale)); case LinkKind.Both: return ((!node.A.IsImportant && (node.A.ArmyScale >= node.A.FewArmyScale)) || (node.A.ArmyScale >= node.A.NormalArmyScale)); } return false; }
internal bool IsSelfFoodEnough(LinkNode node, Routeway routeway) { //if (routeway.LastPoint != null) //临时加上,避免跳出 { switch (node.Kind) { case LinkKind.None: return false; case LinkKind.Land: return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (this.FoodCostPerDayOfLandMilitaries * ((routeway.Length + 6) - (this.LandArmyScale / 8)))); case LinkKind.Water: return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (this.FoodCostPerDayOfWaterMilitaries * ((routeway.Length + 6) - (this.WaterArmyScale / 8)))); case LinkKind.Both: return (((this.Food * (1f - routeway.LastPoint.ConsumptionRate)) * base.Scenario.Date.GetFoodRateBySeason(base.Scenario.Date.GetSeason(routeway.Length))) >= (this.FoodCostPerDayOfAllMilitaries * ((routeway.Length + 6) - (this.ArmyScale / 8)))); } } return false; }
public Routeway GetRouteway(LinkNode node, bool hasEnd) { foreach (Routeway routeway in this.Routeways) { if ((routeway.DestinationArchitecture == node.A) && (!hasEnd || (routeway.EndArchitecture == node.A))) { return routeway; } } return this.BuildRouteway(node, hasEnd); }
public bool HasRouteway(LinkNode node, bool hasEnd, out float rate) { foreach (Routeway routeway in this.Routeways) { if (((routeway.DestinationArchitecture == node.A) && (!hasEnd || (routeway.EndArchitecture == node.A))) && (routeway.LastPoint.ConsumptionRate <= this.BelongedFaction.RoutewayPathBuilder.ConsumptionMax)) { rate = routeway.LastPoint.ConsumptionRate; return true; } } return this.FindRouteway(node, hasEnd, out rate); }
public LinkKind CheckCampaignable(LinkNode node) { bool flag = true; bool flag2 = true; for (int i = 1; i < node.Path.Count; i++) { flag = flag && node.Path[i - 1].IsLandLink(node.Path[i]); flag2 = flag2 && node.Path[i - 1].IsWaterLink(node.Path[i]); } if (flag && flag2) { return LinkKind.Both; } if (flag) { return LinkKind.Land; } if (flag2) { return LinkKind.Water; } return LinkKind.None; }
public bool FindRouteway(LinkNode node, bool hasEnd, out float rate) { rate = 1f; Point key = new Point(base.ID, node.A.ID); if (!this.BelongedFaction.ClosedRouteways.ContainsKey(key)) { Point? nullable; Point? nullable2; base.Scenario.GetClosestPointsBetweenTwoAreas(this.GetRoutewayStartPoints(), node.A.GetAIRoutewayEndPoints(this, true), out nullable, out nullable2); if (nullable.HasValue && nullable2.HasValue) { this.BelongedFaction.RoutewayPathBuilder.MultipleWaterCost = node.Kind == LinkKind.Land; if (this.BelongedFaction.RoutewayPathAvail(nullable.Value, nullable2.Value, hasEnd)) { rate = this.BelongedFaction.RoutewayPathBuilder.PathConsumptionRate; return true; } } } return false; }
public Routeway BuildRouteway(LinkNode node, bool hasEnd) { Point key = new Point(base.ID, node.A.ID); if (!this.BelongedFaction.ClosedRouteways.ContainsKey(key)) { Point? nullable; Point? nullable2; base.Scenario.GetClosestPointsBetweenTwoAreas(this.GetRoutewayStartPoints(), node.A.GetAIRoutewayEndPoints(this, true), out nullable, out nullable2); if (nullable.HasValue && nullable2.HasValue) { this.BelongedFaction.RoutewayPathBuilder.MultipleWaterCost = false; this.BelongedFaction.RoutewayPathBuilder.MustUseWater = node.Kind == LinkKind.Water; if (this.BelongedFaction.RoutewayPathAvail(nullable.Value, nullable2.Value, hasEnd)) { Routeway routeway = this.CreateRouteway(this.BelongedFaction.GetCurrentRoutewayPath()); routeway.DestinationArchitecture = node.A; if (hasEnd) { routeway.EndArchitecture = node.A; } return routeway; } this.BelongedFaction.ClosedRouteways.Add(new Point(base.ID, node.A.ID), null); } } return null; }
private bool isArmyNavigableTo(LinkNode targetNode, Military military) { return GlobalVariables.LandArmyCanGoDownWater || ((targetNode.Kind == LinkKind.Land && military.Kind.Type != MilitaryType.水军) || (targetNode.Kind == LinkKind.Water && military.Kind.Type == MilitaryType.水军) || targetNode.Kind == LinkKind.Both); }
private bool HasHostileArchitectureOnPath(LinkNode node) { foreach (Architecture architecture in node.Path) { if (((architecture != this) && (architecture != node.A)) && !((architecture.BelongedFaction == null) || this.IsFriendly(architecture.BelongedFaction))) { return true; } } return false; }
private bool HasCloserOffensiveArchitecture(LinkNode node, out Architecture closer) { closer = null; foreach (Architecture architecture in this.BelongedFaction.Architectures) { if (architecture != this) { LinkNode node2 = null; architecture.AIAllLinkNodes.TryGetValue(node.A.ID, out node2); if (((node2 != null) && (node2.Level < node.Level)) && (node2.Kind != LinkKind.None)) { closer = architecture; return true; } } } return false; }
private int getArmyReserveForOffensive(LinkNode target) { int totalThreat = 0; int maxThreat = 0; int playerMaxThreat = 0; int playerTotalThreat = 0; foreach (LinkNode i in this.AIAllLinkNodes.Values) { if (i == target) continue; if (i.Level > 1) break; if (i.A.BelongedFaction != null && !this.IsFriendly(i.A.BelongedFaction)) { int threat = (i.Kind == LinkKind.Land ? i.A.AttackableLandArmyScale : i.A.AttackableWaterArmyScale); if (threat > maxThreat) { maxThreat = threat; if (base.Scenario.IsPlayer(i.A.BelongedFaction)) { playerMaxThreat = threat; } } totalThreat += threat; if (base.Scenario.IsPlayer(i.A.BelongedFaction)) { playerTotalThreat += threat; } } } int reserve; if (GlobalVariables.PinPointAtPlayer && this.BelongedSection.AIDetail.OrientationKind == SectionOrientationKind.势力 && base.Scenario.IsPlayer(this.BelongedSection.OrientationFaction)) { maxThreat = playerMaxThreat; totalThreat = playerTotalThreat; } Person leader = this.BelongedFaction.Leader; if (leader.Braveness >= 5 || leader.Calmness <= 5) { reserve = (int)(maxThreat * (0.8 + (leader.Calmness - leader.Braveness) * 0.1)); } else { reserve = (int)(totalThreat / 2 * (0.8 + (leader.Calmness - leader.Braveness) * 0.1)); } return reserve; }