public void LoadInformationsFromString(InformationList informations, string dataString)
 {
     char[] separator = new char[] { ' ', '\n', '\r', '\t' };
     string[] strArray = dataString.Split(separator, StringSplitOptions.RemoveEmptyEntries);
     this.Informations.Clear();
     foreach (string str in strArray)
     {
         Information gameObject = informations.GetGameObject(int.Parse(str)) as Information;
         if (gameObject != null)
         {
             this.AddInformation(gameObject);
         }
     }
 }
 private void InformationDayEvent()
 {
     InformationList list = new InformationList();
     foreach (Information information in this.Informations)
     {
         information.DaysLeft--;
         if (information.DaysLeft == 0)
         {
             list.Add(information);
         }
         else
         {
             information.CheckAmbushTroop();
         }
     }
     foreach (Information information in list)
     {
         information.Purify();
         this.RemoveInformation(information);
         base.Scenario.Informations.Remove(information);
     }
 }
        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);
            }
        }
Beispiel #4
0
 public InformationList GetAllInformationList()
 {
     InformationList result = new InformationList();
     foreach (Information i in this.Informations)
     {
         result.Add(i);
     }
     foreach (Architecture a in this.Architectures)
     {
         foreach (Information i in a.Informations)
         {
             result.Add(i);
         }
     }
     return result;
 }