public void ProcessActiveObjectMessage(uint type, byte[] data) { switch (type) { case (uint)ActiveObjectMessage.GENERIC_CMD_SET_PROPERTIES: { proto_server.s2c_object_properties pack = ProtoBuf.Serializer.Deserialize <proto_server.s2c_object_properties>(new MemoryStream(data)); if (!_ActiveObjectMap.ContainsKey(pack.aid)) { LogHelper.ERROR("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_SET_PROPERTIES aid={0} not exist!", pack.aid); return; } _ObjectMessageHandler.ProcessProperty(_ActiveObjectMap[pack.aid], pack); //LogHelper.DEBUG("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_SET_PROPERTIES aid={0} size={1}", pack.aid, data.Length); } break; case (uint)ActiveObjectMessage.GENERIC_CMD_UPDATE_MOVEMENT: { proto_server.s2c_object_movemont pack = ProtoBuf.Serializer.Deserialize <proto_server.s2c_object_movemont>(new MemoryStream(data)); if (!_ActiveObjectMap.ContainsKey(pack.aid)) { LogHelper.ERROR("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_MOVEMENT aid={0} not exist!", pack.aid); return; } _ObjectMessageHandler.ProcessMovemont(_ActiveObjectMap[pack.aid], pack); //LogHelper.DEBUG("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_MOVEMENT aid={0} size={1}", pack.aid, data.Length); } break; case (uint)ActiveObjectMessage.GENERIC_CMD_UPDATE_YAW_PITCH: { proto_server.s2c_object_yaw_and_picth pack = ProtoBuf.Serializer.Deserialize <proto_server.s2c_object_yaw_and_picth>(new MemoryStream(data)); if (!_ActiveObjectMap.ContainsKey(pack.aid)) { LogHelper.ERROR("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_YAW_PITCH aid={0} not exist!", pack.aid); return; } _ObjectMessageHandler.ProcessYawPitch(_ActiveObjectMap[pack.aid], pack); //LogHelper.DEBUG("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_YAW_PITCH aid={0} size={1}", pack.aid, data.Length); } break; case (uint)ActiveObjectMessage.GENERIC_CMD_UPDATE_CONTROL: { proto_server.s2c_object_control_bits pack = ProtoBuf.Serializer.Deserialize <proto_server.s2c_object_control_bits>(new MemoryStream(data)); if (!_ActiveObjectMap.ContainsKey(pack.aid)) { LogHelper.ERROR("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_CONTROL aid={0} not exist!", pack.aid); return; } _ObjectMessageHandler.ProcesssControlBits(_ActiveObjectMap[pack.aid], pack); //LogHelper.DEBUG("ActiveObjectManager", "ProcessActiveObjectMessage GENERIC_CMD_UPDATE_CONTROL aid={0} size={1}", pack.aid, data.Length); } break; default: break; } }
public void ProcessMovemont(ActiveObject obj, proto_server.s2c_object_movemont movement) { if (obj is Player) { if (obj._GameObject != null && movement.aid != obj._World._LocalPlayerServerID) // 只处理其它人 { //obj._GameObject.transform.position = new Vector3(movement.pos.x / 10, movement.pos.y / 10, movement.pos.z / 10); (obj as Player)._Component.SetTargetPos(new Vector3(movement.pos.x / 10, movement.pos.y / 10, movement.pos.z / 10)); (obj as Player)._Component.SetTargetDir(new Vector3(movement.speed.x, movement.speed.y, movement.speed.z).normalized); } } }
private void HandleMsgPlayerPos(int protocol, MemoryStream ms) { proto_server.s2c_object_movemont pack = ProtoBuf.Serializer.Deserialize <proto_server.s2c_object_movemont>(ms); //LogHelper.DEBUG("HandleMsgPlayerPos", "pack.pos.x={0} pack.pos.y={1} pack.pos.z={2}", pack.pos.x, pack.pos.y, pack.pos.z); }