Exemple #1
0
    public bool LoadCsv(string strContent)
    {
        if (strContent.Length == 0)
        {
            return(false);
        }
        m_mapElements.Clear();
        m_vecAllElements.Clear();
        int           contentOffset = 0;
        List <string> vecLine;

        vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
        if (vecLine.Count != 15)
        {
            Ex.Logger.Log("ShimenType.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Ex.Logger.Log("ShimenType.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Lvl")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Lvl]位置不对应"); return(false);
        }
        if (vecLine[2] != "Res")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Res]位置不对应"); return(false);
        }
        if (vecLine[3] != "TypePro1")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro1]位置不对应"); return(false);
        }
        if (vecLine[4] != "Type1")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type1]位置不对应"); return(false);
        }
        if (vecLine[5] != "TypePro2")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro2]位置不对应"); return(false);
        }
        if (vecLine[6] != "Type2")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type2]位置不对应"); return(false);
        }
        if (vecLine[7] != "TypePro3")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro3]位置不对应"); return(false);
        }
        if (vecLine[8] != "Type3")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type3]位置不对应"); return(false);
        }
        if (vecLine[9] != "TypePro4")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro4]位置不对应"); return(false);
        }
        if (vecLine[10] != "Type4")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type4]位置不对应"); return(false);
        }
        if (vecLine[11] != "ExpReward")
        {
            Ex.Logger.Log("ShimenType.csv中字段[ExpReward]位置不对应"); return(false);
        }
        if (vecLine[12] != "MoneyReward")
        {
            Ex.Logger.Log("ShimenType.csv中字段[MoneyReward]位置不对应"); return(false);
        }
        if (vecLine[13] != "SpecialRewardId")
        {
            Ex.Logger.Log("ShimenType.csv中字段[SpecialRewardId]位置不对应"); return(false);
        }
        if (vecLine[14] != "SpecialRewardPro")
        {
            Ex.Logger.Log("ShimenType.csv中字段[SpecialRewardPro]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)15)
            {
                return(false);
            }
            ShimenTypeElement member = new ShimenTypeElement();
            member.ID               = Convert.ToInt32(vecLine[0]);
            member.Lvl              = Convert.ToInt32(vecLine[1]);
            member.Res              = Convert.ToInt32(vecLine[2]);
            member.TypePro1         = Convert.ToInt32(vecLine[3]);
            member.Type1            = vecLine[4];
            member.TypePro2         = Convert.ToInt32(vecLine[5]);
            member.Type2            = vecLine[6];
            member.TypePro3         = Convert.ToInt32(vecLine[7]);
            member.Type3            = vecLine[8];
            member.TypePro4         = Convert.ToInt32(vecLine[9]);
            member.Type4            = vecLine[10];
            member.ExpReward        = Convert.ToInt32(vecLine[11]);
            member.MoneyReward      = Convert.ToInt32(vecLine[12]);
            member.SpecialRewardId  = Convert.ToInt32(vecLine[13]);
            member.SpecialRewardPro = Convert.ToInt32(vecLine[14]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }
Exemple #2
0
 private ShimenTypeTable()
 {
     m_mapElements    = new Dictionary <int, ShimenTypeElement>();
     m_emptyItem      = new ShimenTypeElement();
     m_vecAllElements = new List <ShimenTypeElement>();
 }
Exemple #3
0
    public bool LoadBin(byte[] binContent)
    {
        m_mapElements.Clear();
        m_vecAllElements.Clear();
        int nCol, nRow;
        int readPos = 0;

        readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nCol);
        readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nRow);
        List <string> vecLine     = new List <string>(nCol);
        List <int>    vecHeadType = new List <int>(nCol);
        string        tmpStr;
        int           tmpInt;

        for (int i = 0; i < nCol; i++)
        {
            readPos += GameAssist.ReadString(binContent, readPos, out tmpStr);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out tmpInt);
            vecLine.Add(tmpStr);
            vecHeadType.Add(tmpInt);
        }
        if (vecLine.Count != 15)
        {
            Ex.Logger.Log("ShimenType.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Ex.Logger.Log("ShimenType.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Lvl")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Lvl]位置不对应"); return(false);
        }
        if (vecLine[2] != "Res")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Res]位置不对应"); return(false);
        }
        if (vecLine[3] != "TypePro1")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro1]位置不对应"); return(false);
        }
        if (vecLine[4] != "Type1")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type1]位置不对应"); return(false);
        }
        if (vecLine[5] != "TypePro2")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro2]位置不对应"); return(false);
        }
        if (vecLine[6] != "Type2")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type2]位置不对应"); return(false);
        }
        if (vecLine[7] != "TypePro3")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro3]位置不对应"); return(false);
        }
        if (vecLine[8] != "Type3")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type3]位置不对应"); return(false);
        }
        if (vecLine[9] != "TypePro4")
        {
            Ex.Logger.Log("ShimenType.csv中字段[TypePro4]位置不对应"); return(false);
        }
        if (vecLine[10] != "Type4")
        {
            Ex.Logger.Log("ShimenType.csv中字段[Type4]位置不对应"); return(false);
        }
        if (vecLine[11] != "ExpReward")
        {
            Ex.Logger.Log("ShimenType.csv中字段[ExpReward]位置不对应"); return(false);
        }
        if (vecLine[12] != "MoneyReward")
        {
            Ex.Logger.Log("ShimenType.csv中字段[MoneyReward]位置不对应"); return(false);
        }
        if (vecLine[13] != "SpecialRewardId")
        {
            Ex.Logger.Log("ShimenType.csv中字段[SpecialRewardId]位置不对应"); return(false);
        }
        if (vecLine[14] != "SpecialRewardPro")
        {
            Ex.Logger.Log("ShimenType.csv中字段[SpecialRewardPro]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            ShimenTypeElement member = new ShimenTypeElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Lvl);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Res);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TypePro1);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Type1);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TypePro2);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Type2);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TypePro3);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Type3);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TypePro4);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Type4);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ExpReward);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.MoneyReward);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.SpecialRewardId);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.SpecialRewardPro);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }