Beispiel #1
0
    public override void OnOperationResponse(OperationResponse operationResponse)
    {
        byte[]        SyncPlayerListBytes = (byte[])DictTool.GetValue(operationResponse.Parameters, (byte)ParameterCode.SyncPlayerList);
        List <string> usernameDict        = ProtobufTool.Deserialize <List <string> >(SyncPlayerListBytes);

        player.OnSyncPlayer(usernameDict);
    }
Beispiel #2
0
    public override void OnEvent(EventData eventData)
    {
        byte[] SyncPositionByte = (byte[])DictTool.GetValue(eventData.Parameters, (byte)ParameterCode.SyncPositionList);
        List <PlayerPosition> playPositionList = (List <PlayerPosition>)ProtobufTool.Deserialize <List <PlayerPosition> >(SyncPositionByte);


        player.OnSyncPositionEvent(playPositionList);
    }
    // Start is called before the first frame update
    void Start()
    {
        //1.序列化
        StoreRequest storeRequest = new StoreRequest();

        storeRequest.Name   = "goods";
        storeRequest.Num    = -50;
        storeRequest.Result = -1;
        for (int i = 0; i < 50; i++)
        {
            string str = $"str{i + 1}";
            storeRequest.MyList.Add(str);
        }
        byte[] bytes = ProtobufTool.Serialize(storeRequest);
        //2.反序列化
        StoreRequest storeRequestUnSer = ProtobufTool.Deserialize <StoreRequest>(bytes);

        byte[] maBytes = DeSerialize.Serialize(storeRequest);
        //2.反序列化
        StoreRequest maStoreRequestUnSer = DeSerialize.Serialization <StoreRequest>(maBytes);
    }