Ejemplo n.º 1
0
    /// <summary>
    /// 激活场景对象
    /// </summary>
    void ActiveSceneObject(int[] indexs)
    {
        if (indexs == null || indexs.Length < 1)
        {
            return;
        }
        ProtoActiveObjects proto = new ProtoActiveObjects();

        proto.objectIndexs = new int[indexs.Length];
        proto.serverIDs    = new int[indexs.Length];
        for (int i = 0; i < indexs.Length; i++)
        {
            SyncObject obj = new SyncObject();
            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.ACTIVE_OBJECTS, proto);
    }
Ejemplo n.º 2
0
 void OnActiveObject(byte[] p)
 {
     if (activeProto == null)
     {
         activeProto = new ProtoActiveObjects();
     }
     if (activeProto.Parse(p))
     {
         for (int i = 0; i < activeProto.serverIDs.Length; i++)
         {
             if (SyncCreater.instance != null)
             {
                 SyncCreater.instance.ActiveObject(activeProto.objectIndexs[i], activeProto.serverIDs[i]);
             }
             UnityEngine.Debug.Log("激活对象sID+" + activeProto.serverIDs[i] + " index:" + activeProto.objectIndexs[i]);
         }
     }
 }