GameFramework.EntityController.SelectTargetForSkill C# (CSharp) Method

SelectTargetForSkill() private method

private SelectTargetForSkill ( string type, int actorId, TableConfig cfg, int seq, HashSet history ) : int
type string
actorId int
cfg TableConfig
seq int
history HashSet
return int
        internal int SelectTargetForSkill(string type, int actorId, TableConfig.Skill cfg, int seq, HashSet<int> history)
        {
            if (string.IsNullOrEmpty(type))
                return 0;
            EntityViewModel view = GetEntityViewById(actorId);
            if(null!=view && null!=view.Entity){
                EntityInfo entity = view.Entity;
                int campId = entity.GetCampId();
                if (type.CompareTo("minhp") == 0) {
                    int targetId = 0;
                    float minhp = float.MaxValue;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    ClientModule.Instance.KdTree.Query(pos, cfg.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (minhp > kdObj.Object.Hp && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY) {
                            int objId = kdObj.Object.GetId();
                            if (!history.Contains(objId)) {
                                minhp = kdObj.Object.Hp;
                                targetId = objId;
                            }
                        }
                    });
                    return targetId;
                } else if (type.CompareTo("maxdist") == 0) {
                    int targetId = 0;
                    float maxDistSqr = 0;
                    ScriptRuntime.Vector3 pos = entity.GetMovementStateInfo().GetPosition3D();
                    ClientModule.Instance.KdTree.Query(pos, cfg.distance, (float distSqr, KdTreeObject kdObj) => {
                        if (maxDistSqr < distSqr && EntityInfo.GetRelation(campId, kdObj.Object.GetCampId()) == CharacterRelation.RELATION_ENEMY) {
                            int objId = kdObj.Object.GetId();
                            if (!history.Contains(objId)) {
                                maxDistSqr = distSqr;
                                targetId = objId;
                            }
                        }
                    });
                    return targetId;
                } else if (type.CompareTo("randenemy") == 0) {
                    return GetRandEnemyId(campId, history);
                } else if (type.CompareTo("randfriend") == 0) {
                    return GetRandFriendId(campId, history);
                }
            }
            return 0;
        }

Usage Example

コード例 #1
0
 static public int SelectTargetForSkill(IntPtr l)
 {
     try {
         GameFramework.EntityController self = (GameFramework.EntityController)checkSelf(l);
         System.String a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         TableConfig.Skill a3;
         checkType(l, 4, out a3);
         System.Int32 a4;
         checkType(l, 5, out a4);
         System.Collections.Generic.HashSet <System.Int32> a5;
         checkType(l, 6, out a5);
         var ret = self.SelectTargetForSkill(a1, a2, a3, a4, a5);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }