public byte[] ServerEncode(CellAttachedInfo info) { Push(VUInt16.Instance.Encode(MSGIDType.CLIENT_AOI_NEW_ENTITY)); Push(VUInt16.Instance.Encode(info.typeId)); Push(VUInt32.Instance.Encode(info.id)); Push(VUInt8.Instance.Encode(info.face)); Push(VUInt16.Instance.Encode(info.x)); Push(VUInt16.Instance.Encode(info.y)); Push(VUInt16.Instance.Encode(info.z)); if (info.props != null) { for (int i = 0; i < info.props.Count; i++) { var prop = info.props[i]; Push(VUInt16.Instance.Encode(CurrentEntity.PropertiesIdMapping[prop.Property.Name])); Push(prop.Property.VType.Encode(prop.Value)); } } var result = new Byte[m_unLen]; Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen); EndPluto(result); return(result); }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; var entity = CurrentEntity; if (entity != null) { info.entity = entity; info.props = new List <KeyValuePair <EntityDefProperties, object> >(); while (unLen < data.Length) {//还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) { info.props.Add(new KeyValuePair <EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen))); } } } Arguments = new object[1] { info }; }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; var entity = CurrentEntity; if (entity != null) { info.entity = entity; info.props = new List<KeyValuePair<EntityDefProperties, object>>(); while (unLen < data.Length) {//还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) info.props.Add(new KeyValuePair<EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen))); } } Arguments = new object[1] { info }; }
public byte[] ServerEncode(CellAttachedInfo info) { Push(VUInt16.Instance.Encode(MSGIDType.CLIENT_AOI_DEL_ENTITY)); Push(VUInt32.Instance.Encode(info.id)); var result = new Byte[m_unLen]; Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen); EndPluto(result); return(result); }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; Arguments = new object[1] { info }; }
protected override void DoDecode(byte[] data, ref int unLen) { /*[UINT16][UINT16][UINT32][UINT8][INT16][INT16] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] ... * 总长度 etype eid face x y 单个aoi长度 etype eid face x y 属性 单个aoi长度 etype eid face x y 属性 */ var list = new List <CellAttachedInfo>(); var info = new CellAttachedInfo(); //VUInt16.Instance.Decode(data, ref unLen); //总长度 info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //etype info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; //list.Add(info);//暂时忽略自身数据 while (unLen < data.Length) { LoggerHelper.Debug("aois"); var entityInfo = new CellAttachedInfo(); var entityLength = (ushort)VUInt16.Instance.Decode(data, ref unLen); //单个entity数据总长度 var endIdx = unLen + entityLength; //结束位置 entityInfo.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); entityInfo.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //entityInfo.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 entityX = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 entityY = (UInt16)VUInt16.Instance.Decode(data, ref unLen); entityInfo.x = (short)entityX; entityInfo.y = (short)entityY; var entity = DefParser.Instance.GetEntityByID(entityInfo.typeId); if (entity != null) { entityInfo.entity = entity; entityInfo.props = new List <KeyValuePair <EntityDefProperties, object> >(); while (unLen < endIdx) {//还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) { entityInfo.props.Add(new KeyValuePair <EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen))); } } } list.Add(entityInfo); } Arguments = new Object[1]; Arguments[0] = list; }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; UInt32 checkFlag = (UInt32)VUInt32.Instance.Decode(data, ref unLen); info.checkFlag = checkFlag; Arguments = new object[1] { info }; }
public byte[] ServerEncode(CellAttachedInfo info) { Push(VUInt16.Instance.Encode(MSGIDType.CLIENT_ENTITY_POS_SYNC)); Push(VUInt8.Instance.Encode(info.face)); Push(VUInt16.Instance.Encode(info.x)); Push(VUInt16.Instance.Encode(info.y)); Push(VUInt16.Instance.Encode(info.z)); var result = new Byte[m_unLen]; Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen); EndPluto(result); return(result); }
protected override void DoDecode(byte[] data, ref int unLen) { /*[UINT16][UINT16][UINT32][UINT8][INT16][INT16] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] ... * 总长度 etype eid face x y 单个aoi长度 etype eid face x y 属性 单个aoi长度 etype eid face x y 属性 */ var list = new List <CellAttachedInfo>(); while (unLen < data.Length) { var entityInfo = new CellAttachedInfo(); var entityLength = (ushort)VUInt16.Instance.Decode(data, ref unLen); //单个entity数据总长度 var endIdx = unLen + entityLength; //结束位置 entityInfo.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); entityInfo.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid entityInfo.face = (byte)VUInt8.Instance.Decode(data, ref unLen); // rotation var entityX = (UInt16)VUInt16.Instance.Decode(data, ref unLen); var entityY = (UInt16)VUInt16.Instance.Decode(data, ref unLen); var entityZ = (UInt16)VUInt16.Instance.Decode(data, ref unLen); entityInfo.x = (short)entityX; entityInfo.y = (short)entityY; entityInfo.z = (short)entityZ; var entity = DefParser.Instance.GetEntityByID(entityInfo.typeId); if (entity != null) { entityInfo.entity = entity; entityInfo.props = new List <EntityPropertyValue>(); while (unLen < endIdx) { //还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) { entityInfo.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen))); } } } list.Add(entityInfo); } Arguments = new Object[1]; Arguments[0] = list; //LoggerHelper.Debug("list: " + list.Count); if (RPCMsgLogManager.IsRecord) { RPCMsgLogManager.Receive(MSGIDType.CLIENT_AOI_ENTITIES, list.PackList()); } }
protected override void DoDecode(byte[] data, ref int unLen) { /*[UINT16][UINT16][UINT32][UINT8][INT16][INT16] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] [UINT16] [UINT16][UINT32][UINT8][INT16][INT16] [....] ... 总长度 etype eid face x y 单个aoi长度 etype eid face x y 属性 单个aoi长度 etype eid face x y 属性 */ var list = new List<CellAttachedInfo>(); var info = new CellAttachedInfo(); //VUInt16.Instance.Decode(data, ref unLen); //总长度 info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //etype info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; //list.Add(info);//暂时忽略自身数据 while (unLen < data.Length) { LoggerHelper.Debug("aois"); var entityInfo = new CellAttachedInfo(); var entityLength = (ushort)VUInt16.Instance.Decode(data, ref unLen); //单个entity数据总长度 var endIdx = unLen + entityLength; //结束位置 entityInfo.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); entityInfo.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //entityInfo.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation UInt16 entityX = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 entityY = (UInt16)VUInt16.Instance.Decode(data, ref unLen); entityInfo.x = (short)entityX; entityInfo.y = (short)entityY; var entity = DefParser.Instance.GetEntityByID(entityInfo.typeId); if (entity != null) { entityInfo.entity = entity; entityInfo.props = new List<KeyValuePair<EntityDefProperties, object>>(); while (unLen < endIdx) {//还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) entityInfo.props.Add(new KeyValuePair<EntityDefProperties, object>(prop, prop.VType.Decode(data, ref unLen))); } } list.Add(entityInfo); } Arguments = new Object[1]; Arguments[0] = list; }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); //info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation //info.x = (short)VInt16.Instance.Decode(data, ref unLen); //x //info.y = (short)VInt16.Instance.Decode(data, ref unLen); //y UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; Arguments = new Object[1]; Arguments[0] = info; }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); //info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation //info.x = (short)VInt16.Instance.Decode(data, ref unLen); //x //info.y = (short)VInt16.Instance.Decode(data, ref unLen); //y UInt16 x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); UInt16 y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (var item in data) { sb.Append(item); } LoggerHelper.Debug("EntityPosTeleportPluto: " + sb.ToString()); Arguments = new Object[1]; Arguments[0] = info; }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); //info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation //info.x = (short)VInt16.Instance.Decode(data, ref unLen); //x //info.y = (short)VInt16.Instance.Decode(data, ref unLen); //y var x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); var y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; Arguments = new Object[1]; Arguments[0] = info; if (RPCMsgLogManager.IsRecord) { RPCMsgLogManager.Receive(MSGIDType.CLIENT_ENTITY_POS_PULL, Arguments); } }
protected override void DoDecode(byte[] data, ref int unLen) { var info = new CellAttachedInfo(); info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid info.face = (byte)VUInt8.Instance.Decode(data, ref unLen); // rotation var x = (UInt16)VUInt16.Instance.Decode(data, ref unLen); var y = (UInt16)VUInt16.Instance.Decode(data, ref unLen); var z = (UInt16)VUInt16.Instance.Decode(data, ref unLen); info.x = (short)x; info.y = (short)y; info.z = (short)z; var entity = DefParser.Instance.GetEntityByID(info.typeId); if (entity != null) { info.entity = entity; info.props = new List <EntityPropertyValue>(); while (unLen < data.Length) { //还有数据就解析 var index = VUInt16.Instance.Decode(data, ref unLen); EntityDefProperties prop; var flag = entity.Properties.TryGetValue((ushort)index, out prop); if (flag) { info.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen))); } } } Arguments = new object[1] { info }; if (RPCMsgLogManager.IsRecord) { RPCMsgLogManager.Receive(MSGIDType.CLIENT_AOI_NEW_ENTITY, Arguments); } }
static private void MainCameraCompleted() { //if (inCity) //{ // MogoUIManager.Instance.ShowMogoNormalMainUI(); //} //else //{ // MogoUIManager.Instance.ShowMogoBattleMainUI(); //} Camera RelatedCam = GameObject.Find("Main_Camera").GetComponentInChildren<Camera>(); Camera ViewCam = GameObject.Find("MogoMainUI/Camera").GetComponentInChildren<Camera>(); Camera renderCam = GameObject.Find("MogoMainUI/BillboardCamera").GetComponentInChildren<Camera>(); ViewCam.GetComponent<BillboardViewManager>().RelatedCamera = RelatedCam; ViewCam.GetComponent<BillboardViewManager>().ViewCamera = renderCam; //通知主角和其他全部实体场景加载完毕 thePlayer.MainCameraCompleted(); mainCameraCompleted = true; if (isReConnect) { if (me != null) { EventDispatcher.TriggerEvent<CellAttachedInfo>(Events.FrameWorkEvent.EntityCellAttached, me); me = null; } foreach (var i in others) { EventDispatcher.TriggerEvent<CellAttachedInfo>(Events.FrameWorkEvent.AOINewEntity, i); } others.Clear(); } if (sceneChanged) {//在加载后判断是否加载中变换了场景ID if (thePlayer != null && !scenesManager.CheckSameScene(thePlayer.sceneId)) { sceneChanged = false; SwitchScene(orgId, thePlayer.sceneId); } } TimerHeap.AddTimer(2000, 0, CityDelayCheck); }
// 协议处理函数, 新的 entity 进入视野 static private void AOINewEntity(CellAttachedInfo info) { // todo: 先硬编码, 以后改成 从 def 中 自动化 EntityParent entity; LoggerHelper.Debug(info.entity.Name); if (isReConnect && !mainCameraCompleted) {//断线重连场景没加载完,缓存起来 others.Add(info); return; } if (Entities.ContainsKey(info.id) || (thePlayer != null && thePlayer.ID == info.id)) { LoggerHelper.Debug("has same id entity in world"); return; } if ((info.entity.Name == "Monster" || info.entity.Name == "Mercenary" || info.entity.Name == "Drop") && inCity) { //主城不出现Monster Mercenary,用于切场景的瞬间收到创建协议 return; } switch (info.entity.Name) { case "Avatar"://对应Avatar.def if (SystemConfig.Instance.PlayerCountInScreen <= playerCount || (MogoWorld.thePlayer != null && MogoWorld.thePlayer.IsNewPlayer)) { LoggerHelper.Debug("EntityPlayer over count: " + playerCount); return; } if (MogoWorld.IsClientMission) { return; } entity = new EntityPlayer(); entity.vocation = Vocation.Warrior; break; case "NPC"://对应NPC.def // entity = new EntityNPC(); entity = new EntityParent(); break; case "Monster": //对应Monster.def entity = new EntityMonster(); break; case "Mercenary": //对应Monster.def entity = new EntityMercenary(); break; case "Drop": //对应Drop.def entity = new EntityDrop(); Vector3 newPosi = MogoWorld.FindEmptyDropPoint(info.position); (entity as EntityDrop).SetTweenTarget(newPosi); //LoggerHelper.Error("f**k end " + info.id + " n " + newPosi.x + " " + newPosi.y + " " + newPosi.z); break; case "TeleportPointSrc": //对应TeleportPointSrc.def entity = new EntityTeleportSrc(); break; case "Dummy": //CMonster.def entity = new EntityDummy(); break; default: entity = new EntityParent(); break; } entity.ID = info.id; entity.entity = info.entity; entity.SetEntityCellInfo(info); entity.OnEnterWorld(); if (!isLoadingScene) entity.CreateModel(); //LoggerHelper.Error("AOINewEntity: etype: " + info.entity.Name + " eid: " + entity.ID + " pos: " + entity.position); OnEnterWorld(entity); EventDispatcher.TriggerEvent(Events.CampaignEvent.SetPlayerMessage, entity); }
static public void CreateDummy(uint eid, int x, int y, int cfgId, int difficulty, int spawnPointCfgId) { //LoggerHelper.Error("CreateDummy difficulty:" + difficulty); if (!MonsterData.dataMap.ContainsKey(cfgId)) { return; } MonsterData m = MonsterData.GetData(cfgId, MogoWorld.thePlayer.ApplyMissionID == Mogo.Game.RandomFB.RAIDID ? MogoWorld.thePlayer.level : difficulty); EntityDummy entity = new EntityDummy(); CellAttachedInfo info = new CellAttachedInfo(); info.x = (short)x; info.y = (short)y; info.id = eid; entity.spawnPointCfgId = spawnPointCfgId; entity.MonsterData = m; entity.ID = eid; entity.clientTrapId = m.clientTrapId; entity.SetEntityCellInfo(info); if (m.clientBoss == 1) {//为体验关特制 entity.stateFlag = 1 << 13; } entity.SetCfg(m); //entity.curHp = (uint)currHp;因为现在不用重新登录刷怪,所以直接前端设一次就够了,现在curHp换成difficulty了,如果大于0则要根据difficulty匹配怪物的能力in MonsterValue entity.OnEnterWorld(); entity.enterX = (short)x; entity.enterZ = (short)y; OnEnterWorld(entity); if (isLoadingScene)//在副本下线重新登录后isLoadingScene没有置回去false 导致dummy刷不出 { //entity.ReadyCreateModel(); } else { TimerHeap.AddTimer(1000, 0, DelayCreateDummy, entity); } }
static public void CreateDrop(uint eid, int x, int y, int gold, int itemId, int belongAvatar) { if (belongAvatar == thePlayer.ID) { EntityDrop entity = new EntityDrop(); CellAttachedInfo info = new CellAttachedInfo(); info.x = (short)x; info.y = (short)y; info.id = eid; Vector3 newPosi = MogoWorld.FindEmptyDropPoint(info.position); entity.SetTweenTarget(newPosi); entity.ID = info.id; entity.entity = info.entity; entity.SetEntityCellInfo(info); entity.gold = gold; entity.itemId = itemId; entity.belongAvatar = belongAvatar; entity.OnEnterWorld(); if (!isLoadingScene) entity.CreateModel(); OnEnterWorld(entity); } }
static private void OnEntityCellAttached(CellAttachedInfo info) { LoggerHelper.Debug("OnEntityCellAttached " + info.position); EntityParent entity = null; var eid = info.id; // entity uniq id if (eid == thePlayer.ID) { if (isReConnect && !mainCameraCompleted) {//断线重连后缓存cellAttachedInfo me = info; return; } entity = thePlayer; thePlayer.SetEntityCellInfo(info); //SwitchScene(thePlayer.sceneId); } else if (eid == theAccount.ID) { entity = theAccount; theAccount.SetEntityCellInfo(info); } //LoadHomeScene(); }