예제 #1
0
 public Point? GetCampaignPosition(Troop troop, List<Point> orientations, bool close)
 {
     GameArea allAvailableArea = this.GetAllAvailableArea(false);
     GameArea sourceArea = new GameArea();
     foreach (Point point in allAvailableArea.Area)
     {
         if ((base.Scenario.GetArchitectureByPosition(point) == this || troop.IsMovableOnPosition(point)) && base.Scenario.GetTroopByPosition(point) == null)
         {
             sourceArea.Area.Add(point);
         }
     }
     GameArea highestFightingForceArea = troop.GetHighestFightingForceArea(sourceArea);
     if (highestFightingForceArea != null)
     {
         if (close)
         {
             return base.Scenario.GetClosestPosition(highestFightingForceArea, orientations);
         }
         return base.Scenario.GetFarthestPosition(highestFightingForceArea, orientations);
     }
     return null;
 }
예제 #2
0
 public GameArea GetTroopEnterableArea(Troop troop)
 {
     GameArea area = new GameArea();
     foreach (Point point in this.ArchitectureArea.Area)
     {
         if (base.Scenario.GetWaterPositionMapCost(troop.Army.Kind.Type, point) < 3500)
         {
             area.AddPoint(point);
         }
     }
     foreach (Point point in this.ContactArea.Area)
     {
         if (troop.IsMovableOnPosition(point) && (base.Scenario.GetWaterPositionMapCost(troop.Army.Kind.Type, point) < 3500))
         {
             area.AddPoint(point);
         }
     }
     return area;
 }
예제 #3
0
        /*
        private void AIFacility()
        {
            if (((this.PlanArchitecture == null) || GameObject.Chance(10)) && (this.BuildingFacility < 0))
            {
                List<FacilityKind> list = new List<FacilityKind>();
                List<FacilityKind> list2 = new List<FacilityKind>();
                if (this.PlanFacilityKind != null)
                {
                    if (this.Technology >= this.PlanFacilityKind.TechnologyNeeded)
                    {
                        if ((this.Fund >= this.PlanFacilityKind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= this.PlanFacilityKind.PointCost))
                        {
                            this.BelongedFaction.DepositTechniquePointForFacility(this.PlanFacilityKind.PointCost);
                            this.BeginToBuildAFacility(this.PlanFacilityKind);
                            this.PlanFacilityKind = null;
                        }
                        else if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost))
                        {
                            this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days);
                        }
                    }
                    else
                    {
                        this.PlanFacilityKind = null;
                    }
                }
                else
                {
                    List<FacilityKind> list3 = new List<FacilityKind>();
                    int facilityPositionLeft = this.FacilityPositionLeft;
                    if (facilityPositionLeft <= 0)
                    {
                        foreach (Facility facility in this.Facilities.GetList())
                        {
                            if (((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && (this.Fund > (facility.FundCost * 10))) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20))
                            {
                                list3.Add(facility.Kind);
                                if (this.FacilityEnabled)
                                {
                                    facility.Influences.PurifyInfluence(this);
                                }
                                this.Facilities.Remove(facility);
                                base.Scenario.Facilities.Remove(facility);
                            }
                        }
                        if (list3.Count == 0)
                        {
                            return;
                        }
                        facilityPositionLeft = this.FacilityPositionLeft;
                    }
                    foreach (FacilityKind kind in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values)
                    {
                        if (list3.IndexOf(kind) >= 0)
                        {
                            continue;
                        }
                        if (kind.rongna > 0) continue;  //不造美女设施

                        if (((((!kind.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= kind.TechnologyNeeded) && (facilityPositionLeft >= kind.PositionOccupied))) && (!kind.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID))) && (!kind.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID))) && ((kind.FrontLine && ((this.HostileLine || (this.FrontLine && GameObject.Chance(50))) || (!this.FrontLine && GameObject.Chance(10)))) || (!kind.FrontLine && ((!this.FrontLine || (!this.HostileLine && GameObject.Chance(50))) || (this.HostileLine && GameObject.Chance(5))))))
                        {
                            list.Add(kind);
                            if ((this.Fund >= kind.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= kind.PointCost))
                            {
                                list2.Add(kind);
                            }
                        }
                    }
                    if (list2.Count > 0)
                    {
                        FacilityKind facilityKind = list2[GameObject.Random(list2.Count)];
                        this.BelongedFaction.DepositTechniquePointForFacility(facilityKind.PointCost);
                        this.BeginToBuildAFacility(facilityKind);
                    }
                    else if (list.Count > 0)
                    {
                        this.PlanFacilityKind = list[GameObject.Random(list.Count)];
                        if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost))
                        {
                            this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days);
                        }
                    }
                }// end if (this.PlanFacilityKind != null)
            }
        }
        */
        /*
        private void AIFoodTransfer()
        {
            Routeway connectedRouteway;
            int food;
            if (this.IsFoodAbundant || ((!this.HostileLine && (!this.FrontLine || !GameObject.Chance(20))) && !GameObject.Chance(1)))
            {
                if (this.TransferFoodArchitecture != null)
                {
                    LinkNode node = null;
                    this.AIAllLinkNodes.TryGetValue(this.TransferFoodArchitecture.ID, out node);
                    if (node != null)
                    {
                        connectedRouteway = this.GetRouteway(node, true);
                        if ((connectedRouteway != null) && (connectedRouteway.LastPoint != null))
                        {
                            if (this.BelongedFaction != this.TransferFoodArchitecture.BelongedFaction)
                            {
                                connectedRouteway.RemoveAfterClose = true;
                                connectedRouteway.Close();
                                this.TransferFoodArchitecture = null;
                            }
                            else
                            {
                                connectedRouteway.DestinationToEnd();
                                if (connectedRouteway.EndArchitecture == this.TransferFoodArchitecture)
                                {
                                    food = this.Food - this.EnoughFood;
                                    if ((food >= 0x186a0) || (food > this.TransferFoodArchitecture.FoodCostPerDayOfAllMilitaries))
                                    {
                                        if (connectedRouteway.IsActive)
                                        {
                                            int abundantFood = this.TransferFoodArchitecture.AbundantFood;
                                            if (food > abundantFood)
                                            {
                                                food = abundantFood;
                                            }
                                            this.DecreaseFood(food);
                                            this.TransferFoodArchitecture.IncreaseFood((int) (food * (1f - (connectedRouteway.LastPoint.ConsumptionRate * this.BelongedFaction.RateOfFoodTransportBetweenArchitectures))));
                                            this.TransferFoodArchitecture = null;
                                        }
                                        else if ((connectedRouteway.LastPoint.BuildFundCost * 2) <= this.Fund)
                                        {
                                            connectedRouteway.Building = true;
                                        }
                                    }
                                    else
                                    {
                                        this.TransferFoodArchitecture = null;
                                    }
                                }
                                else
                                {
                                    this.TransferFoodArchitecture = null;
                                }
                            }
                        }
                        else
                        {
                            this.TransferFoodArchitecture = null;
                        }
                    }
                    else
                    {
                        this.TransferFoodArchitecture = null;
                    }
                }
            }
            else
            {
                GameObjectList list = new GameObjectList();
                foreach (LinkNode node in this.AIAllLinkNodes.Values)
                {
                    if (node.Level > 3)
                    {
                        break;
                    }
                    if (node.A.BelongedFaction == this.BelongedFaction)
                    {
                        if (node.A.BelongedSection == this.BelongedSection)
                        {
                            list.Add(node.A);
                        }
                        else if (node.A.BelongedSection.AIDetail.AllowFoodTransfer && ((node.A.BelongedSection.OrientationSection == this.BelongedSection) || (node.A.BelongedSection.OrientationSection == null)))
                        {
                            list.Add(node.A);
                        }
                    }
                }
                if (list.Count > 1)
                {
                    list.PropertyName = "Food";
                    list.IsNumber = true;
                    list.ReSort();
                }
                foreach (Architecture architecture in list)
                {
                    connectedRouteway = architecture.GetConnectedRouteway(this);
                    if ((connectedRouteway == null) || (connectedRouteway.LastPoint == null))
                    {
                        connectedRouteway = this.GetConnectedRouteway(architecture);
                    }
                    if ((connectedRouteway != null) && (connectedRouteway.LastPoint != null))
                    {
                        food = 0;
                        if (architecture.IsFoodTwiceAbundant && (architecture.RecentlyAttacked <= 0))
                        {
                            food = (architecture.FoodCostPerDayOfAllMilitaries * 80) / 5;
                            if (architecture.BelongedSection.OrientationSection == this.BelongedSection)
                            {
                                food *= 2;
                                if (food > architecture.Food)
                                {
                                    food = architecture.Food;
                                }
                            }
                        }
                        else if (architecture.IsFoodAbundant && !architecture.HostileLine)
                        {
                            food = (architecture.FoodCostPerDayOfAllMilitaries * 40) / 5;
                            if (architecture.BelongedSection.OrientationSection == this.BelongedSection)
                            {
                                food *= 2;
                                if (food > architecture.Food)
                                {
                                    food = architecture.Food;
                                }
                            }
                        }
                        if (food >= 0x186a0)
                        {
                            architecture.DecreaseFood(food);
                            this.IncreaseFood((int) (food * (1f - (connectedRouteway.LastPoint.ConsumptionRate * this.BelongedFaction.RateOfFoodTransportBetweenArchitectures))));
                        }
                        else
                        {
                            architecture.TransferFoodArchitecture = null;
                        }
                    }
                    else if (architecture.TransferFoodArchitecture == null)
                    {
                        if ((((architecture.RecentlyAttacked == 0) && (!architecture.HostileLine || GameObject.Chance(20))) && (architecture.Food >= ((architecture.EnoughFood + this.EnoughFood) + 0x186a0))) && ((this.TransferFoodArchitectureCount <= GameObject.Random(2)) && (architecture.Food >= 0x61a80)))
                        {
                            architecture.TransferFoodArchitecture = this;
                        }
                    }
                    else if ((((architecture.BelongedFaction != this.BelongedFaction) || (this.BelongedFaction != architecture.TransferFoodArchitecture.BelongedFaction)) || ((architecture.RecentlyAttacked > 0) || architecture.TransferFoodArchitecture.IsFoodAbundant)) || ((architecture.Food < (architecture.EnoughFood + ((this.EnoughFood * 3) / 2))) && (architecture.Food < 0x61a80)))
                    {
                        architecture.TransferFoodArchitecture = null;
                    }
                }
            }
        }

        private void AIFundTransfer()
        {
            int fund;
            if (!this.IsFundEnough)
            {
                int num = this.EnoughFund - this.Fund;
                int num2 = 0;
                GameObjectList list = new GameObjectList();
                foreach (Architecture architecture in this.GetOtherArchitectureList())
                {
                    if (architecture.BelongedSection == this.BelongedSection)
                    {
                        list.Add(architecture);
                    }
                    else if (architecture.BelongedSection.AIDetail.AllowFundTransfer && ((architecture.BelongedSection.OrientationSection == this.BelongedSection) || (architecture.BelongedSection.OrientationSection == null)))
                    {
                        list.Add(architecture);
                    }
                }
                foreach (Architecture architecture in list)
                {
                    fund = 0;
                    if (architecture.Fund > architecture.AbundantFund)
                    {
                        fund = 0x3e8;
                        if (architecture.BelongedSection.OrientationSection == this.BelongedSection)
                        {
                            fund *= 2;
                            if (fund > architecture.Fund)
                            {
                                fund = architecture.Fund;
                            }
                        }
                    }
                    else if (architecture.Fund > architecture.EnoughFund)
                    {
                        fund = 500;
                        if (architecture.BelongedSection.OrientationSection == this.BelongedSection)
                        {
                            fund *= 2;
                            if (fund > architecture.Fund)
                            {
                                fund = architecture.Fund;
                            }
                        }
                    }
                    if (fund > 0)
                    {
                        architecture.DecreaseFund(fund);
                        this.AddFundPack(fund, base.Scenario.GetTranferFundDays(architecture, this));
                        num2 += fund;
                    }
                    if (num2 > num)
                    {
                        break;
                    }
                }
            }
            else if (((this.TransferFundArchitecture != null) && (this.TransferFundArchitecture.BelongedFaction == this.BelongedFaction)) && (this.TransferFundArchitecture.Fund < this.TransferFundArchitecture.FundCeiling))
            {
                fund = this.Fund - this.EnoughFund;
                if (fund > 500)
                {
                    this.DecreaseFund(fund);
                    this.TransferFundArchitecture.AddFundPack(fund, base.Scenario.GetTranferFundDays(this, this.TransferFundArchitecture));
                }
            }
            else if (this.BelongedSection != null && this.BelongedSection.AIDetail.AllowFundTransfer && this.IsFundAbundant)
            {
                foreach (Architecture architecture in this.GetOtherArchitectureList())
                {
                    if (!architecture.IsFundEnough)
                    {
                        fund = 0x3e8;
                        if (fund > this.Fund)
                        {
                            fund = this.Fund;
                        }
                        if (fund > 0)
                        {
                            this.DecreaseFund(fund);
                            architecture.AddFundPack(fund, base.Scenario.GetTranferFundDays(this, architecture));
                        }
                    }
                    if (!this.IsFundAbundant)
                    {
                        break;
                    }
                }
            }
        }

        */
        private Point? GetRandomStartingPosition(Troop troop)
        {
            GameArea allAvailableArea = this.GetAllAvailableArea(false);
            GameArea sourceArea = new GameArea();
            foreach (Point point in allAvailableArea.Area)
            {
                if (((base.Scenario.GetArchitectureByPosition(point) == this) && (base.Scenario.GetTroopByPosition(point) == null)) || troop.IsMovableOnPosition(point))
                {
                    sourceArea.Area.Add(point);
                }
            }
            if (sourceArea.Count == 0)
            {
                return null;
            }
            return sourceArea[GameObject.Random(sourceArea.Count)];
        }