Пример #1
0
    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);
            }
        }
    }
Пример #2
0
    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);
    }