コード例 #1
0
        private ObjCharacter GetCanAttack(ObjNPC npc)
        {
            if (mLastEnemy == null || mLastEnemy.IsDead() || !mLastEnemy.Active)
            {
                ObjCharacter temp   = null;
                var          maxDis = 9999999.0f;
                foreach (var pair in npc.Scene.mObjDict)
                {
                    var t = pair.Value as ObjCharacter;
                    if (t == null || npc.Equals(t) || npc.GetCamp() == t.GetCamp())
                    {
                        continue;
                    }
                    if (t.IsDead() || !t.Active)
                    {
                        continue;
                    }

                    /**if (!mAddList.Contains(t.TypeId))
                     * {
                     *  continue;
                     * }**/
                    var dis = (npc.GetPosition() - t.GetPosition()).LengthSquared();
                    if (dis < maxDis)
                    {
                        temp   = t;
                        maxDis = dis;
                    }
                }
                return(temp);
            }
            return(mLastEnemy);
        }