//广播给所有玩家消息 public void BrocatBuffer(byte[] data) { foreach (PlayerObject obj in m_DicPlayerObject.Values) { NetMsg.BaseMsg msg = new NetMsg.BaseMsg(); msg.Create(data, obj.GetGamePackKeyEx()); obj.SendData(msg.GetBuffer()); } }
//广播移动消息 //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()); } } }
public override void ClearThis() { NetMsg.MsgClearObjectInfo info = new NetMsg.MsgClearObjectInfo(); info.id = GetTypeId(); byte[] msg = info.GetBuffer(); foreach (RefreshObject refobj in this.GetVisibleList().Values) { BaseObject obj = refobj.obj; if (obj.type == OBJECTTYPE.PLAYER && obj.GetGameSession() != null) { if (obj.GetGameID() == play.GetGameID()) continue; //不发给宿主玩家 NetMsg.BaseMsg data = new NetMsg.BaseMsg(); data.Create(msg, obj.GetGamePackKeyEx()); obj.SendData(data.GetBuffer()); } } //移除范围内的对象..以便下次刷新怪物的时候刷新出来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(); //base.ClearThis(); }
//广播 public void BroadcastBuffer(byte[] data, bool isThis = false/*是否也发给自己*/) { // this.RefreshVisibleObject(); foreach (RefreshObject o in GetVisibleList().Values) { BaseObject obj = o.obj; if (obj.type == OBJECTTYPE.PLAYER && obj.GetGameSession() != null) { NetMsg.BaseMsg msg = new NetMsg.BaseMsg(); msg.Create(data, obj.GetGamePackKeyEx()); obj.SendData(msg.GetBuffer()); } } if (isThis) { if (this.GetGameSession() != null) { NetMsg.BaseMsg msg = new NetMsg.BaseMsg(); msg.Create(data, this.GetGamePackKeyEx()); this.SendData(msg.GetBuffer()); } } }