GameFramework.EntityController.GetRandEnemyId C# (CSharp) Method

GetRandEnemyId() private method

private GetRandEnemyId ( int campId ) : int
campId int
return int
        internal int GetRandEnemyId(int campId)
        {
            int id = 0;
            List<int> ids = new List<int>();
            for (LinkedListNode<EntityInfo> linkNode = ClientModule.Instance.EntityManager.Entities.FirstValue; null != linkNode; linkNode = linkNode.Next) {
                EntityInfo info = linkNode.Value;
                if (EntityInfo.GetRelation(campId, info.GetCampId()) == CharacterRelation.RELATION_ENEMY && info.EntityType != (int)EntityTypeEnum.Tower) {
                    ids.Add(info.GetId());
                }
            }
            int index = Helper.Random.Next(ids.Count);
            if (index >= 0 && index < ids.Count) {
                id = ids[index];
            }
            return id;
        }

Same methods

EntityController::GetRandEnemyId ( int campId, HashSet history ) : int

Usage Example

Example #1
0
 static public int GetRandEnemyId(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             GameFramework.EntityController self = (GameFramework.EntityController)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             var ret = self.GetRandEnemyId(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             GameFramework.EntityController self = (GameFramework.EntityController)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.HashSet <System.Int32> a2;
             checkType(l, 3, out a2);
             var ret = self.GetRandEnemyId(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }