示例#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 != 23)
        {
            Debug.Log("GodWeapon.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Debug.Log("GodWeapon.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Name")
        {
            Debug.Log("GodWeapon.csv中字段[Name]位置不对应"); return(false);
        }
        if (vecLine[2] != "NameJuexing")
        {
            Debug.Log("GodWeapon.csv中字段[NameJuexing]位置不对应"); return(false);
        }
        if (vecLine[3] != "SourceID")
        {
            Debug.Log("GodWeapon.csv中字段[SourceID]位置不对应"); return(false);
        }
        if (vecLine[4] != "SourceJuexing")
        {
            Debug.Log("GodWeapon.csv中字段[SourceJuexing]位置不对应"); return(false);
        }
        if (vecLine[5] != "Hero")
        {
            Debug.Log("GodWeapon.csv中字段[Hero]位置不对应"); return(false);
        }
        if (vecLine[6] != "Attr")
        {
            Debug.Log("GodWeapon.csv中字段[Attr]位置不对应"); return(false);
        }
        if (vecLine[7] != "Pattack")
        {
            Debug.Log("GodWeapon.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[8] != "Mattack")
        {
            Debug.Log("GodWeapon.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[9] != "PDefense")
        {
            Debug.Log("GodWeapon.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[10] != "MDefense")
        {
            Debug.Log("GodWeapon.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[11] != "HP")
        {
            Debug.Log("GodWeapon.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[12] != "Baoji")
        {
            Debug.Log("GodWeapon.csv中字段[Baoji]位置不对应"); return(false);
        }
        if (vecLine[13] != "Bisha")
        {
            Debug.Log("GodWeapon.csv中字段[Bisha]位置不对应"); return(false);
        }
        if (vecLine[14] != "MP")
        {
            Debug.Log("GodWeapon.csv中字段[MP]位置不对应"); return(false);
        }
        if (vecLine[15] != "MpHuifu")
        {
            Debug.Log("GodWeapon.csv中字段[MpHuifu]位置不对应"); return(false);
        }
        if (vecLine[16] != "Renxing")
        {
            Debug.Log("GodWeapon.csv中字段[Renxing]位置不对应"); return(false);
        }
        if (vecLine[17] != "Shouhu")
        {
            Debug.Log("GodWeapon.csv中字段[Shouhu]位置不对应"); return(false);
        }
        if (vecLine[18] != "HpHuifu")
        {
            Debug.Log("GodWeapon.csv中字段[HpHuifu]位置不对应"); return(false);
        }
        if (vecLine[19] != "Attr1")
        {
            Debug.Log("GodWeapon.csv中字段[Attr1]位置不对应"); return(false);
        }
        if (vecLine[20] != "Attr2")
        {
            Debug.Log("GodWeapon.csv中字段[Attr2]位置不对应"); return(false);
        }
        if (vecLine[21] != "Attr3")
        {
            Debug.Log("GodWeapon.csv中字段[Attr3]位置不对应"); return(false);
        }
        if (vecLine[22] != "Attr4")
        {
            Debug.Log("GodWeapon.csv中字段[Attr4]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)23)
            {
                return(false);
            }
            GodWeaponElement member = new GodWeaponElement();
            member.ID            = Convert.ToInt32(vecLine[0]);
            member.Name          = vecLine[1];
            member.NameJuexing   = vecLine[2];
            member.SourceID      = vecLine[3];
            member.SourceJuexing = vecLine[4];
            member.Hero          = Convert.ToInt32(vecLine[5]);
            member.Attr          = vecLine[6];
            member.Pattack       = Convert.ToInt32(vecLine[7]);
            member.Mattack       = Convert.ToInt32(vecLine[8]);
            member.PDefense      = Convert.ToInt32(vecLine[9]);
            member.MDefense      = Convert.ToInt32(vecLine[10]);
            member.HP            = Convert.ToInt32(vecLine[11]);
            member.Baoji         = Convert.ToInt32(vecLine[12]);
            member.Bisha         = Convert.ToInt32(vecLine[13]);
            member.MP            = Convert.ToInt32(vecLine[14]);
            member.MpHuifu       = Convert.ToInt32(vecLine[15]);
            member.Renxing       = Convert.ToInt32(vecLine[16]);
            member.Shouhu        = Convert.ToInt32(vecLine[17]);
            member.HpHuifu       = Convert.ToInt32(vecLine[18]);
            member.Attr1         = Convert.ToInt32(vecLine[19]);
            member.Attr2         = Convert.ToInt32(vecLine[20]);
            member.Attr3         = Convert.ToInt32(vecLine[21]);
            member.Attr4         = Convert.ToInt32(vecLine[22]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }
示例#2
0
 private GodWeaponTable()
 {
     m_mapElements    = new Dictionary <int, GodWeaponElement>();
     m_emptyItem      = new GodWeaponElement();
     m_vecAllElements = new List <GodWeaponElement>();
 }
示例#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 != 23)
        {
            Debug.Log("GodWeapon.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Debug.Log("GodWeapon.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Name")
        {
            Debug.Log("GodWeapon.csv中字段[Name]位置不对应"); return(false);
        }
        if (vecLine[2] != "NameJuexing")
        {
            Debug.Log("GodWeapon.csv中字段[NameJuexing]位置不对应"); return(false);
        }
        if (vecLine[3] != "SourceID")
        {
            Debug.Log("GodWeapon.csv中字段[SourceID]位置不对应"); return(false);
        }
        if (vecLine[4] != "SourceJuexing")
        {
            Debug.Log("GodWeapon.csv中字段[SourceJuexing]位置不对应"); return(false);
        }
        if (vecLine[5] != "Hero")
        {
            Debug.Log("GodWeapon.csv中字段[Hero]位置不对应"); return(false);
        }
        if (vecLine[6] != "Attr")
        {
            Debug.Log("GodWeapon.csv中字段[Attr]位置不对应"); return(false);
        }
        if (vecLine[7] != "Pattack")
        {
            Debug.Log("GodWeapon.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[8] != "Mattack")
        {
            Debug.Log("GodWeapon.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[9] != "PDefense")
        {
            Debug.Log("GodWeapon.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[10] != "MDefense")
        {
            Debug.Log("GodWeapon.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[11] != "HP")
        {
            Debug.Log("GodWeapon.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[12] != "Baoji")
        {
            Debug.Log("GodWeapon.csv中字段[Baoji]位置不对应"); return(false);
        }
        if (vecLine[13] != "Bisha")
        {
            Debug.Log("GodWeapon.csv中字段[Bisha]位置不对应"); return(false);
        }
        if (vecLine[14] != "MP")
        {
            Debug.Log("GodWeapon.csv中字段[MP]位置不对应"); return(false);
        }
        if (vecLine[15] != "MpHuifu")
        {
            Debug.Log("GodWeapon.csv中字段[MpHuifu]位置不对应"); return(false);
        }
        if (vecLine[16] != "Renxing")
        {
            Debug.Log("GodWeapon.csv中字段[Renxing]位置不对应"); return(false);
        }
        if (vecLine[17] != "Shouhu")
        {
            Debug.Log("GodWeapon.csv中字段[Shouhu]位置不对应"); return(false);
        }
        if (vecLine[18] != "HpHuifu")
        {
            Debug.Log("GodWeapon.csv中字段[HpHuifu]位置不对应"); return(false);
        }
        if (vecLine[19] != "Attr1")
        {
            Debug.Log("GodWeapon.csv中字段[Attr1]位置不对应"); return(false);
        }
        if (vecLine[20] != "Attr2")
        {
            Debug.Log("GodWeapon.csv中字段[Attr2]位置不对应"); return(false);
        }
        if (vecLine[21] != "Attr3")
        {
            Debug.Log("GodWeapon.csv中字段[Attr3]位置不对应"); return(false);
        }
        if (vecLine[22] != "Attr4")
        {
            Debug.Log("GodWeapon.csv中字段[Attr4]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            GodWeaponElement member = new GodWeaponElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ID);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Name);
            readPos += GameAssist.ReadString(binContent, readPos, out member.NameJuexing);
            readPos += GameAssist.ReadString(binContent, readPos, out member.SourceID);
            readPos += GameAssist.ReadString(binContent, readPos, out member.SourceJuexing);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Hero);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Attr);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Pattack);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Mattack);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.PDefense);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.MDefense);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.HP);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Baoji);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Bisha);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.MP);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.MpHuifu);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Renxing);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Shouhu);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.HpHuifu);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Attr1);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Attr2);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Attr3);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Attr4);

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