Пример #1
0
    public byte   Grade;       //难度等级

    public byte[] ToArray()
    {
        using (MMoMemorySteam ms = new MMoMemorySteam())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteInt(GameLevelId);
            ms.WriteByte(Grade);
            return(ms.ToArray());
        }
    }
Пример #2
0
    public static GameLevel_EnterProto GetProto(byte[] buffer)
    {
        GameLevel_EnterProto proto = new GameLevel_EnterProto();

        using (MMoMemorySteam ms = new MMoMemorySteam(buffer))
        {
            ms.ReadUShort();
            proto.GameLevelId = ms.ReadInt();
            proto.Grade       = (byte)ms.ReadByte();
        }
        return(proto);
    }
Пример #3
0
    public short  MessageId; //错误编号

    public byte[] ToArray()
    {
        using (MMoMemorySteam ms = new MMoMemorySteam())
        {
            ms.WriteUShort(ProtoCode);
            ms.WriteBool(IsSuccess);
            if (!IsSuccess)
            {
                ms.WriteShort(MessageId);
            }
            return(ms.ToArray());
        }
    }
Пример #4
0
    public static GameLevel_EnterReturnProto GetProto(byte[] buffer)
    {
        GameLevel_EnterReturnProto proto = new GameLevel_EnterReturnProto();

        using (MMoMemorySteam ms = new MMoMemorySteam(buffer))
        {
            proto.IsSuccess = ms.ReadBool();
            if (!proto.IsSuccess)
            {
                proto.MessageId = ms.ReadShort();
            }
        }
        return(proto);
    }
Пример #5
0
    private byte[] xorScale = new byte[] { 45, 66, 38, 55, 23, 251, 9, 166, 90, 19, 41, 45, 201, 58, 55, 37, 254, 185, 165, 169, 19, 171 };    //.data文件的xor加解密因子
    #endregion

    #region GameDataTableParser 构造函数
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="path"></param>
    public ReadExcelAndParss(string path)
    {
        m_FieldNameDic = new Dictionary <string, int>();
        byte[] buffer = null;

        //------------------
        //第1步:读取文件
        //------------------
        using (FileStream fs = new FileStream(path, FileMode.Open))
        {
            buffer = new byte[fs.Length];
            fs.Read(buffer, 0, buffer.Length);
        }

        //------------------
        //第2步:解压缩
        //------------------
        buffer = ZlibHelper.DeCompressBytes(buffer);

        //------------------
        //第3步:xor解密
        //------------------
        int iScaleLen = xorScale.Length;

        for (int i = 0; i < buffer.Length; i++)
        {
            buffer[i] = (byte)(buffer[i] ^ xorScale[i % iScaleLen]);
        }

        //------------------
        //第4步:解析数据到数组
        //------------------
        using (MMoMemorySteam ms = new MMoMemorySteam(buffer))
        {
            m_Row    = ms.ReadInt();
            m_Column = ms.ReadInt();

            m_GameData  = new String[m_Row, m_Column];
            m_FieldName = new string[m_Column];

            for (int i = 0; i < m_Row; i++)
            {
                for (int j = 0; j < m_Column; j++)
                {
                    string str = ms.ReadString();

                    if (i == 0)
                    {
                        //表示读取的是字段
                        m_FieldName[j]      = str;
                        m_FieldNameDic[str] = j;
                    }
                    else if (i > 2)
                    {
                        //表示读取的是内容
                        m_GameData[i, j] = str;
                    }
                }
            }
        }
    }