GetGameID() публичный Метод

public GetGameID ( ) : uint
Результат uint
Пример #1
0
 //添加可视对象
 //
 public void AddVisibleObject(BaseObject obj,bool bRefreshTag = true)
 {
     RefreshObject refobj = null;
     if (this.GetVisibleList().ContainsKey(obj.GetGameID()))
     {
         refobj = mVisibleList[obj.GetGameID()];
         refobj.bRefreshTag = bRefreshTag;
         return;
     }
     refobj = new RefreshObject();
     refobj.bRefreshTag = bRefreshTag;
     refobj.obj = obj;
     mVisibleList[obj.GetGameID()] = refobj;
 }
Пример #2
0
        //添加可视对象
        //
        public void AddVisibleObject(BaseObject obj, bool bRefreshTag = true)
        {
            RefreshObject refobj = null;

            if (this.GetVisibleList().ContainsKey(obj.GetGameID()))
            {
                refobj             = mVisibleList[obj.GetGameID()];
                refobj.bRefreshTag = bRefreshTag;
                return;
            }
            refobj                        = new RefreshObject();
            refobj.bRefreshTag            = bRefreshTag;
            refobj.obj                    = obj;
            mVisibleList[obj.GetGameID()] = refobj;
        }
Пример #3
0
        //刷新可视对象列表
        public virtual void RefreshVisibleObject()
        {
            //在地图被销毁的怪物啊-- 掉落物品啊..刷新的时候找不到了就删除掉!
            uint        id       = 0;
            List <uint> templist = null;

            foreach (RefreshObject refobj in mVisibleList.Values)
            {
                BaseObject obj = refobj.obj;
                if (obj.type == OBJECTTYPE.MONSTER ||
                    obj.type == OBJECTTYPE.GUARDKNIGHT)
                {
                    id = obj.GetTypeId();
                }
                else
                {
                    id = obj.GetGameID();
                }
                if (GetGameMap().GetObject(id) == null)
                {
                    if (templist == null)
                    {
                        templist = new List <uint>();
                    }
                    templist.Add(id);
                }
            }
            if (templist != null)
            {
                for (int i = 0; i < templist.Count; i++)
                {
                    mVisibleList.Remove(templist[i]);
                }
            }
        }
Пример #4
0
        //删除地图对象
        public void RemoveObj(BaseObject obj)
        {
            uint id;

            if (obj.type == OBJECTTYPE.MONSTER)
            {
                id = obj.GetTypeId();
            }
            else
            {
                id = obj.GetGameID();
            }
            if (mDicObject.ContainsKey(id))
            {
                if (obj.type == OBJECTTYPE.PLAYER)
                {
                    PlayerObject play = obj as PlayerObject;
                    play.ClearThis(); //广播删除自己
                }
                if (obj.type == OBJECTTYPE.EUDEMON)
                {
                    EudemonObject eudemon = obj as EudemonObject;
                    eudemon.ReCall();
                }
                if (obj.type == OBJECTTYPE.PTICH)
                {
                    PtichObject ptich = obj as PtichObject;
                    ptich.ClearThis();
                }
                //加到临时删除列表- 下次process时处理删除
                mListDeleteObj.Add(obj);
                //  mDicObject.Remove(id);
            }
            if (this.GetObjectCount(OBJECTTYPE.PLAYER) == 0)
            {
                last_null_tick = System.Environment.TickCount;
            }
        }
Пример #5
0
        public void Process()
        {
            if (mDicObject.Count == 0 &&
                mListDeleteObj.Count == 0 &&
                mListAddObj.Count == 0)
            {
                return;                         //地图没人..就不处理了
            }
            //删除离开地图的玩家
            if (mListDeleteObj.Count > 0)
            {
                uint id;
                for (int i = 0; i < mListDeleteObj.Count; i++)
                {
                    BaseObject obj = mListDeleteObj[i] as BaseObject;
                    if (obj.type == OBJECTTYPE.MONSTER ||
                        obj.type == OBJECTTYPE.GUARDKNIGHT)
                    {
                        id = obj.GetTypeId();
                    }
                    else
                    {
                        id = obj.GetGameID();
                    }
                    //obj.Dispose();
                    //if (obj.type == OBJECTTYPE.PLAYER)
                    //{
                    //    UserEngine.Instance().RemovePlayObject(obj as PlayerObject);
                    //}
                    if (mDicObject.ContainsKey(id))
                    {
                        mDicObject.Remove(id);
                    }
                }
                mListDeleteObj.Clear();
            }

            //要添加的对象
            if (mListAddObj.Count > 0)
            {
                for (int i = 0; i < mListAddObj.Count; i++)
                {
                    BaseObject obj = mListAddObj[i];
                    if (obj.type == OBJECTTYPE.MONSTER) //怪物是以typeid为主键
                    {
                        mDicObject[obj.GetTypeId()] = obj;
                    }
                    else
                    {
                        mDicObject[obj.GetGameID()] = obj;
                    }
                }
                mListAddObj.Clear();
            }
            //地图所有对象run
            //需要拷贝一份词典,因为在循环里面会改变该词典的集合--
            //需要优化 这里效率太低了
            // Dictionary<uint, BaseObject> tempdic = new Dictionary<uint, BaseObject>(mDicObject);
            //2015.11.12 已解决,声明了一个删除的列表- mListDeleteObj 在removeobj后加入到列表 process再进行删除-内存不涨了 好开心o(∩_∩)o 哈哈
            foreach (BaseObject obj in mDicObject.Values)
            {
                if (!obj.Run())
                {
                    mListDeleteObj.Add(obj);
                }
            }
        }
Пример #6
0
 //删除地图对象
 public void RemoveObj(BaseObject obj)
 {
     uint id ;
     if(obj.type == OBJECTTYPE.MONSTER) id = obj.GetTypeId();
     else id =obj.GetGameID();
     if ( mDicObject.ContainsKey(id))
     {
         if (obj.type == OBJECTTYPE.PLAYER)
         {
             PlayerObject play = obj as PlayerObject;
             play.ClearThis(); //广播删除自己
         }
         if (obj.type == OBJECTTYPE.EUDEMON)
         {
             EudemonObject eudemon = obj as EudemonObject;
             eudemon.ReCall();
         }
         if (obj.type == OBJECTTYPE.PTICH)
         {
             PtichObject ptich = obj as PtichObject;
             ptich.ClearThis();
         }
         //加到临时删除列表- 下次process时处理删除
         mListDeleteObj.Add(obj);
       //  mDicObject.Remove(id);
     }
     if (this.GetObjectCount(OBJECTTYPE.PLAYER) == 0)
     {
         last_null_tick = System.Environment.TickCount;
     }
 }
Пример #7
0
        public void SendMonsterInfo(BaseObject obj)
        {
            if (this.GetGameSession() == null) return;

            NetMsg.MsgMonsterInfo info = new NetMsg.MsgMonsterInfo();
            info.Create(null, GetGamePackKeyEx());
            MonsterObject o = obj as MonsterObject;
            info.id = o.GetTypeId();
            info.typeid = o.GetBasicAttribute().id;
            info.lookface = o.GetBasicAttribute().lookface;
            info.x = o.GetCurrentX();
            info.y = o.GetCurrentY();
            info.level = o.GetBasicAttribute().level;
            info.maxhp = o.GetAttribute().life_max;
            info.hp = o.GetAttribute().life;
            info.dir = o.GetDir();

            if (obj.GetType().FullName == "MapServer.AnShaXieLongObject")
            {
                info.param = (int)(obj as AnShaXieLongObject).mPlay.GetTypeId();
            }
            this.SendData(info.GetBuffer());

            //加到怪物可视列表
            if (!obj.GetVisibleList().ContainsKey(this.GetGameID()))
            {
                //RefreshObject refobj = new RefreshObject();
                //refobj.obj = this;
                //obj.GetVisibleList()[this.GetGameID()] = refobj;
                obj.AddVisibleObject(this, false);
            }
            //自己的可视列表 //人物不走动的情况下,怪物进入了视野范围
            if (!this.GetVisibleList().ContainsKey(obj.GetGameID()))
            {
                //RefreshObject refobj = new RefreshObject();
                //refobj.bRefreshTag = true;
                //refobj.obj = obj;
                //this.GetVisibleList()[this.GetGameID()] = refobj;
                this.AddVisibleObject(obj, true);
            }
        }