Пример #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 != 18)
        {
            Ex.Logger.Log("MissionTiaoJian.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "TiaoJian1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian1]位置不对应"); return(false);
        }
        if (vecLine[2] != "CanShu1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu1]位置不对应"); return(false);
        }
        if (vecLine[3] != "Num1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num1]位置不对应"); return(false);
        }
        if (vecLine[4] != "DaoHang1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang1]位置不对应"); return(false);
        }
        if (vecLine[5] != "XunLu1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu1]位置不对应"); return(false);
        }
        if (vecLine[6] != "TiaoJian2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian2]位置不对应"); return(false);
        }
        if (vecLine[7] != "CanShu2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu2]位置不对应"); return(false);
        }
        if (vecLine[8] != "Num2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num2]位置不对应"); return(false);
        }
        if (vecLine[9] != "DaoHang2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang2]位置不对应"); return(false);
        }
        if (vecLine[10] != "XunLu2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu2]位置不对应"); return(false);
        }
        if (vecLine[11] != "TiaoJian3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian3]位置不对应"); return(false);
        }
        if (vecLine[12] != "CanShu3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu3]位置不对应"); return(false);
        }
        if (vecLine[13] != "Num3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num3]位置不对应"); return(false);
        }
        if (vecLine[14] != "DaoHang3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang3]位置不对应"); return(false);
        }
        if (vecLine[15] != "XunLu3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu3]位置不对应"); return(false);
        }
        if (vecLine[16] != "Finish")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Finish]位置不对应"); return(false);
        }
        if (vecLine[17] != "FinishXianShi")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[FinishXianShi]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)18)
            {
                return(false);
            }
            MissionTiaoJianElement member = new MissionTiaoJianElement();
            member.ID            = Convert.ToInt32(vecLine[0]);
            member.TiaoJian1     = Convert.ToInt32(vecLine[1]);
            member.CanShu1       = Convert.ToInt32(vecLine[2]);
            member.Num1          = Convert.ToInt32(vecLine[3]);
            member.DaoHang1      = vecLine[4];
            member.XunLu1        = vecLine[5];
            member.TiaoJian2     = Convert.ToInt32(vecLine[6]);
            member.CanShu2       = Convert.ToInt32(vecLine[7]);
            member.Num2          = Convert.ToInt32(vecLine[8]);
            member.DaoHang2      = vecLine[9];
            member.XunLu2        = vecLine[10];
            member.TiaoJian3     = Convert.ToInt32(vecLine[11]);
            member.CanShu3       = Convert.ToInt32(vecLine[12]);
            member.Num3          = Convert.ToInt32(vecLine[13]);
            member.DaoHang3      = vecLine[14];
            member.XunLu3        = vecLine[15];
            member.Finish        = vecLine[16];
            member.FinishXianShi = vecLine[17];

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }
Пример #2
0
 private MissionTiaoJianTable()
 {
     m_mapElements    = new Dictionary <int, MissionTiaoJianElement>();
     m_emptyItem      = new MissionTiaoJianElement();
     m_vecAllElements = new List <MissionTiaoJianElement>();
 }
Пример #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 != 18)
        {
            Ex.Logger.Log("MissionTiaoJian.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "TiaoJian1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian1]位置不对应"); return(false);
        }
        if (vecLine[2] != "CanShu1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu1]位置不对应"); return(false);
        }
        if (vecLine[3] != "Num1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num1]位置不对应"); return(false);
        }
        if (vecLine[4] != "DaoHang1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang1]位置不对应"); return(false);
        }
        if (vecLine[5] != "XunLu1")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu1]位置不对应"); return(false);
        }
        if (vecLine[6] != "TiaoJian2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian2]位置不对应"); return(false);
        }
        if (vecLine[7] != "CanShu2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu2]位置不对应"); return(false);
        }
        if (vecLine[8] != "Num2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num2]位置不对应"); return(false);
        }
        if (vecLine[9] != "DaoHang2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang2]位置不对应"); return(false);
        }
        if (vecLine[10] != "XunLu2")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu2]位置不对应"); return(false);
        }
        if (vecLine[11] != "TiaoJian3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[TiaoJian3]位置不对应"); return(false);
        }
        if (vecLine[12] != "CanShu3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[CanShu3]位置不对应"); return(false);
        }
        if (vecLine[13] != "Num3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Num3]位置不对应"); return(false);
        }
        if (vecLine[14] != "DaoHang3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[DaoHang3]位置不对应"); return(false);
        }
        if (vecLine[15] != "XunLu3")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[XunLu3]位置不对应"); return(false);
        }
        if (vecLine[16] != "Finish")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[Finish]位置不对应"); return(false);
        }
        if (vecLine[17] != "FinishXianShi")
        {
            Ex.Logger.Log("MissionTiaoJian.csv中字段[FinishXianShi]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            MissionTiaoJianElement member = new MissionTiaoJianElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TiaoJian1);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.CanShu1);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Num1);
            readPos += GameAssist.ReadString(binContent, readPos, out member.DaoHang1);
            readPos += GameAssist.ReadString(binContent, readPos, out member.XunLu1);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TiaoJian2);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.CanShu2);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Num2);
            readPos += GameAssist.ReadString(binContent, readPos, out member.DaoHang2);
            readPos += GameAssist.ReadString(binContent, readPos, out member.XunLu2);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TiaoJian3);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.CanShu3);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Num3);
            readPos += GameAssist.ReadString(binContent, readPos, out member.DaoHang3);
            readPos += GameAssist.ReadString(binContent, readPos, out member.XunLu3);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Finish);
            readPos += GameAssist.ReadString(binContent, readPos, out member.FinishXianShi);

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