Esempio n. 1
0
    /// <summary>
    /// TDData序列化
    /// </summary>
    private byte[] TDDataSerialize(TDData tDData)
    {
        ProtocolBytes protocol = new ProtocolBytes();

        protocol.AddString(tDData.name);
        protocol.AddVector3(tDData.terrainPos);
        protocol.AddFloatArray2(tDData.heightMap);

        protocol.AddInt32(tDData.detailMap.Length);
        for (int i = 0; i < tDData.detailMap.Length; i++)
        {
            protocol.AddIntArray2(tDData.detailMap[i]);
        }
        protocol.AddFloatArray3(tDData.alphaMap);

        protocol.AddInt32(tDData.treePoses.Length);
        for (int i = 0; i < tDData.treePoses.Length; i++)
        {
            protocol.AddInt32(tDData.treePoses[i].Length);
            for (int j = 0; j < tDData.treePoses[i].Length; j++)
            {
                protocol.AddVector3(tDData.treePoses[i][j]);
            }
        }
        return(protocol.Encode());
    }