/// <summary> /// 请求创建对象 /// </summary> void ReqCreateObject(EventArgs args) { EventObjectArgs objectArgs = args as EventObjectArgs; if (objectArgs != null && objectArgs.t != null) { ProtoCreateObject[] list = objectArgs.t as ProtoCreateObject[]; ProtoSyncObjectList createObjectProto = ObjectPool.protoPool.GetOrCreate <ProtoSyncObjectList>(ProtoPool.ProtoRecycleType.CreateObjects); createObjectProto.objList = list; Send(ProtoIDCfg.CREATE_OBJECTS, createObjectProto, ProtoType.Importance); createObjectProto.Recycle(); } }
void OnCreateObjects(byte[] p) { ProtoSyncObjectList list = ObjectPool.protoPool.GetOrCreate <ProtoSyncObjectList>(ProtoPool.ProtoRecycleType.CreateObjects); if (list.Parse(p)) { for (int i = 0; i < list.objList.Length; i++) { if (SyncCreater.instance != null) { SyncCreater.instance.CreateObject(list.objList[i].objectIndex, list.objList[i].serverID, list.objList[i]); } UnityEngine.Debug.Log("生成对象sID+" + list.objList[i].serverID + " index:" + list.objList[i].objectIndex); } } }
void OnMsgCreateObject(TcpHost.SocketAccept socket, byte[] protoData) { ProtoSyncObjectList list = new ProtoSyncObjectList(); if (list.Parse(protoData)) { for (int i = 0; i < list.objList.Length; i++) { SyncObject obj = list.objList[i]; obj.serverID = objectIDCounter; objectIDCounter++; //obj.objectIndex = indexs[i]; //proto.serverIDs[i] = obj.serverID; //proto.objectIndexs[i] = obj.objectIndex; if (!sceneObjes.ContainsKey(obj.serverID)) { sceneObjes.Add(obj.serverID, obj); Debug.LogWarning("创建对象:" + obj.serverID); } } } Broadcast(ProtoIDCfg.CREATE_OBJECTS, list); }