Browse Source

增加编辑器单位选技器一个新选项:指定阵营里最重的单位

大爷 1 year ago
parent
commit
25a89651b8

+ 15 - 0
Common/CommonAI/Zone/Instance/InstanceZone.cs

@@ -602,6 +602,21 @@ namespace CommonAI.Zone.Instance
             }
             return null;
         }
+        public InstanceUnit getTheWeightOneAtForce(int force)
+        {
+            float weightest = -999;
+            InstanceUnit theone = null;
+            foreach (InstanceUnit u in mObjects.Units)
+            {
+                if (u.Force == force && u.Weight > weightest)
+                {
+                    theone = u;
+                    weightest = u.Weight;
+                }
+            }
+            return theone;
+        }
+
 
         public InstanceUnit getUnitByName(string name)
         {

+ 15 - 0
Common/CommonAI/Zone/ZoneEditor/EventTrigger/Values.Units.cs

@@ -292,6 +292,21 @@ namespace CommonAI.Zone.ZoneEditor.EventTrigger
                 return api.UnitAPI;
             }
         }
+
+        [DescAttribute("指定阵营里最重的单位", "功能")]
+        public class BossUnit : UnitValue
+        {
+            [DescAttribute("阵营force")]
+            public int force = 0;
+            public override string ToString()
+            {
+                return string.Format("阵营{0}里最重的单位", force);
+            }
+            public override InstanceUnit GetValue(IEditorValueAdapter api, EventArguments args)
+            {
+                return api.ZoneAPI.getTheWeightOneAtForce(force);
+            }
+        }
     }
 
 }