GetVisibleList() 공개 메소드

public GetVisibleList ( ) : RefreshObject>.Dictionary
리턴 RefreshObject>.Dictionary
예제 #1
0
파일: GameMap.cs 프로젝트: tangfengray/soul
 //取该坐标点是否有对象[优先判断是否有阻挡]
 public bool GetPointOfObj(BaseObject obj, short x, short y)
 {
     if (!CanMove(x, y))
     {
         return(true);
     }
     obj.RefreshVisibleObject();
     foreach (RefreshObject baseobj in obj.GetVisibleList().Values)
     {
         BaseObject _obj = baseobj.obj;
         if (_obj.GetCurrentX() == x && _obj.GetCurrentY() == y)
         {
             return(true);
         }
     }
     if (mListAddObj.Count > 0)
     {
         for (int i = 0; i < mListAddObj.Count; i++)
         {
             BaseObject _obj = mListAddObj[i];
             if (_obj.GetCurrentX() == x && _obj.GetCurrentY() == y)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #2
0
 //从地图中删除自己
 public virtual void ClearThis()
 {
     NetMsg.MsgClearObjectInfo info = new NetMsg.MsgClearObjectInfo();
     info.id = GetTypeId();
     byte[] msg = info.GetBuffer();
     this.BrocatBuffer(msg);
     //移除范围内的对象..以便下次刷新怪物的时候刷新出来2015.10.16
     foreach (RefreshObject refobj in this.GetVisibleList().Values)
     {
         BaseObject obj = refobj.obj;
         if (obj.type != OBJECTTYPE.PLAYER)
         {
             continue;
         }
         if (obj.GetVisibleList().ContainsKey(this.GetGameID()))
         {
             obj.GetVisibleList().Remove(this.GetGameID());
         }
     }
     this.GetVisibleList().Clear();
     //  this.GetGameMap().BroadcastBuffer(this, msg);
 }
예제 #3
0
파일: GameMap.cs 프로젝트: tangfengray/soul
        //广播移动消息
        //public void BroadcastMove(BaseObject obj,byte[] data)
        //{
        //    foreach (BaseObject o in obj.mVisibleList.Values)
        //    {
        //        if (o.type == OBJECTTYPE.PLAYER)
        //        {
        //            PlayerObject po = o as PlayerObject;
        //            o.SendData(data);

        //       }
        //   }
        //}
        //广播消息
        public void BroadcastBuffer(BaseObject obj, byte[] buff)
        {
            //  obj.RefreshVisibleObject();
            foreach (RefreshObject o in obj.GetVisibleList().Values)
            {
                BaseObject _obj = o.obj;
                if (_obj.type == OBJECTTYPE.PLAYER && _obj.GetGameSession() != null)
                {
                    NetMsg.BaseMsg basemsg = new NetMsg.BaseMsg();
                    basemsg.Create(buff, _obj.GetGamePackKeyEx());
                    _obj.SendData(basemsg.GetBuffer());
                }
            }
        }
예제 #4
0
        protected override void ProcessAction_Move(GameStruct.Action act)
        {
            this.RefreshVisibleObject();
            List <BaseObject> list_add = null;

            foreach (RefreshObject refobj in this.GetVisibleList().Values)
            {
                BaseObject obj = refobj.obj;
                //    //角色没这个怪物的要刷新该怪物视野
                if (obj.type == OBJECTTYPE.PLAYER)
                {
                    if (!obj.GetVisibleList().ContainsKey(this.GetGameID())) //刷新该角色视野
                    {
                        //集合会被修改 与foreach冲突. 放到外面添加
                        if (list_add == null)
                        {
                            list_add = new List <BaseObject>();
                        }
                        list_add.Add(obj);
                    }
                    else
                    {
                        NetMsg.MsgMoveInfo moveinfo = new NetMsg.MsgMoveInfo();
                        moveinfo.Create(null, null);
                        moveinfo.id     = this.GetTypeId();
                        moveinfo.x      = GetCurrentX();
                        moveinfo.y      = GetCurrentY();
                        moveinfo.ucMode = DIR.MOVEMODE_RUN_DIR0 + Define.FIGHTKNIGHT_RUN_SPEED;
                        moveinfo.dir    = this.GetDir();
                        byte[] msg = moveinfo.GetBuffer();
                        this.BrocatBuffer(msg);
                    }
                }
            }
            if (list_add != null)
            {
                for (int i = 0; i < list_add.Count; i++)
                {
                    list_add[i].AddVisibleObject(this, true);
                    this.SendInfo(list_add[i] as PlayerObject);
                    //(list_add[i] as PlayerObject).SendMonsterInfo(this);
                }
            }
        }
예제 #5
0
        protected override void ProcessAction_Move(GameStruct.Action act)
        {
            this.RefreshVisibleObject();
            List <BaseObject> list_add = null;

            foreach (RefreshObject refobj in this.GetVisibleList().Values)
            {
                BaseObject obj = refobj.obj;
                //    //角色没这个怪物的要刷新该怪物视野
                //    //2015.9.5
                if (obj.type == OBJECTTYPE.PLAYER)
                {
                    if (!obj.GetVisibleList().ContainsKey(this.GetGameID())) //刷新该角色视野
                    {
                        //集合会被修改 与foreach冲突. 放到外面添加
                        if (list_add == null)
                        {
                            list_add = new List <BaseObject>();
                        }
                        list_add.Add(obj);
                    }
                    else
                    {
                        MsgMoveInfo moveinfo = new MsgMoveInfo();
                        moveinfo.Create(null, null);
                        moveinfo.id     = this.GetTypeId();
                        moveinfo.x      = GetCurrentX();
                        moveinfo.y      = GetCurrentY();
                        moveinfo.ucMode = 1;
                        moveinfo.dir    = this.GetDir();
                        byte[] msg = moveinfo.GetBuffer();
                        this.GetGameMap().BroadcastBuffer(this, msg);
                    }
                }
            }
            if (list_add != null)
            {
                for (int i = 0; i < list_add.Count; i++)
                {
                    //RefreshObject _addobj = new RefreshObject();
                    //_addobj.bRefreshTag = true;
                    //_addobj.obj = this;
                    //list_add[i].GetVisibleList()[this.GetGameID()] = _addobj;
                    list_add[i].AddVisibleObject(this, true);
                    (list_add[i] as PlayerObject).SendMonsterInfo(this);
                }
            }
            //if (mRefreshList.Count > 0)
            //{
            //    //角色没这个怪物的要刷新该怪物视野
            //    //2015.9.5
            //    foreach (BaseObject obj in mRefreshList.Values)
            //    {
            //        if (obj.type == OBJECTTYPE.PLAYER)
            //        {
            //            if (!obj.GetVisibleList().ContainsKey(this.GetGameID()))
            //            {
            //                (obj as PlayerObject).SendMonsterInfo(this);
            //                obj.GetVisibleList().Add(this.GetGameID(), this);
            //            }
            //        }
            //        mRefreshList.Clear();
            //    }
            //    MsgMoveInfo moveinfo = new MsgMoveInfo();
            //    moveinfo.Create(null, null);
            //    moveinfo.id = this.GetTypeId();
            //    moveinfo.x = GetCurrentX();
            //    moveinfo.y = GetCurrentY();
            //    moveinfo.ucMode = 1;
            //    moveinfo.dir = this.GetDir();
            //    byte[] msg = moveinfo.GetBuffer();
            //    this.GetGameMap().BroadcastBuffer(this,msg);

            //}
        }
예제 #6
0
 //广播移动消息
 //public void BroadcastMove(BaseObject obj,byte[] data)
 //{
 //    foreach (BaseObject o in obj.mVisibleList.Values)
 //    {
 //        if (o.type == OBJECTTYPE.PLAYER)
 //        {
 //            PlayerObject po = o as PlayerObject;
 //            o.SendData(data);
 //       }
 //   }
 //}
 //广播消息
 public void BroadcastBuffer(BaseObject obj, byte[] buff)
 {
     //  obj.RefreshVisibleObject();
     foreach (RefreshObject o in obj.GetVisibleList().Values)
     {
         BaseObject _obj = o.obj;
         if (_obj.type == OBJECTTYPE.PLAYER && _obj.GetGameSession() != null)
         {
             NetMsg.BaseMsg basemsg = new NetMsg.BaseMsg();
             basemsg.Create(buff, _obj.GetGamePackKeyEx());
             _obj.SendData(basemsg.GetBuffer());
         }
     }
 }
예제 #7
0
 //取该坐标点是否有对象[优先判断是否有阻挡]
 public bool GetPointOfObj(BaseObject obj, short x, short y)
 {
     if (!CanMove(x, y)) return true;
     obj.RefreshVisibleObject();
     foreach (RefreshObject baseobj in obj.GetVisibleList().Values)
     {
         BaseObject _obj = baseobj.obj;
         if (_obj.GetCurrentX() == x && _obj.GetCurrentY() == y)
         {
             return true;
         }
     }
     if (mListAddObj.Count > 0)
     {
         for (int i = 0; i < mListAddObj.Count; i++)
         {
             BaseObject _obj = mListAddObj[i];
             if (_obj.GetCurrentX() == x && _obj.GetCurrentY() == y)
             {
                 return true;
             }
         }
     }
     return false;
 }
예제 #8
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);
            }
        }