Exemplo n.º 1
0
 private void BuildSectionByArchitectureList(GameObjectList architecturelist)
 {
     if (architecturelist.Count != 0)
     {
         Section section;
         GameObjectList list;
         if (architecturelist.Count == 1)
         {
             section = new Section();
             section.ID = base.Scenario.Sections.GetFreeGameObjectID();
             section.Scenario = base.Scenario;
             this.AddSection(section);
             base.Scenario.Sections.AddSectionWithEvent(section);
             list = base.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailsByConditions(SectionOrientationKind.无, true, false, true, true, false);
             if (list.Count > 0)
             {
                 section.AIDetail = list[GameObject.Random(list.Count)] as SectionAIDetail;
             }
             else
             {
                 section.AIDetail = base.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailList()[0] as SectionAIDetail;
             }
             section.AddArchitecture(architecturelist[0] as Architecture);
         }
         else
         {
             architecturelist.PropertyName = "Population";
             architecturelist.IsNumber = true;
             architecturelist.ReSort();
             int count = 0;
             int num2 = 2 + (this.ArchitectureCount / 8);
             if (architecturelist.Count < ((num2 * 3) / 2))
             {
                 count = architecturelist.Count;
             }
             else
             {
                 count = num2;
             }
             section = new Section();
             section.ID = base.Scenario.Sections.GetFreeGameObjectID();
             section.Scenario = base.Scenario;
             this.AddSection(section);
             base.Scenario.Sections.AddSectionWithEvent(section);
             list = base.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailsByConditions(SectionOrientationKind.无, true, false, true, true, false);
             if (list.Count > 0)
             {
                 section.AIDetail = list[GameObject.Random(list.Count)] as SectionAIDetail;
             }
             else
             {
                 section.AIDetail = base.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailList()[0] as SectionAIDetail;
             }
             Architecture architecture = architecturelist[0] as Architecture;
             section.AddArchitecture(architecture);
             if (architecture.ClosestArchitectures == null)
             {
                 architecture.GetClosestArchitectures();
             }
             if (architecture.AIAllLinkNodes.Count == 0)
             {
                 architecture.GenerateAllAILinkNodes(2);
             }
             foreach (LinkNode node in architecture.AIAllLinkNodes.Values)
             {
                 if (node.Level > 2)
                 {
                     break;
                 }
                 if ((node.A.BelongedFaction == this) && architecturelist.HasGameObject(node.A))
                 {
                     section.AddArchitecture(node.A);
                 }
                 if (section.ArchitectureCount >= count)
                 {
                     break;
                 }
             }
             if (count == architecturelist.Count)
             {
                 if (section.ArchitectureCount < count)
                 {
                     foreach (Architecture architecture2 in section.Architectures)
                     {
                         architecturelist.Remove(architecture2);
                     }
                     if (this.SectionCount == 1)
                     {
                         foreach (Architecture architecture2 in architecturelist)
                         {
                             this.FirstSection.AddArchitecture(architecture2);
                         }
                     }
                     else
                     {
                         foreach (Architecture architecture2 in architecturelist)
                         {
                             int num3 = 0x7fffffff;
                             Section section2 = null;
                             foreach (Section section3 in this.Sections)
                             {
                                 int distanceFromSection = architecture2.GetDistanceFromSection(section3);
                                 if (distanceFromSection < num3)
                                 {
                                     num3 = distanceFromSection;
                                     section2 = section3;
                                 }
                             }
                             section2.AddArchitecture(architecture2);
                         }
                     }
                 }
             }
             else
             {
                 foreach (Architecture architecture2 in section.Architectures)
                 {
                     architecturelist.Remove(architecture2);
                 }
                 this.BuildSectionByArchitectureList(architecturelist);
             }
         }
     }
 }
Exemplo n.º 2
0
 public Section CreateFirstSection()
 {
     if ((this.Capital != null) && (this.ArchitectureCount > 0))
     {
         Section section = new Section();
         section.Scenario = base.Scenario;
         section.ID = base.Scenario.Sections.GetFreeGameObjectID();
         section.Name = this.Capital.Name + "军区";
         section.AIDetail = base.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailsByConditions(SectionOrientationKind.无 , true, false, true, true, false)[0] as SectionAIDetail;
         foreach (Architecture architecture in this.Architectures)
         {
             section.AddArchitecture(architecture);
         }
         this.AddSection(section);
         base.Scenario.Sections.AddSectionWithEvent(section);
         return section;
     }
     return null;
 }