Пример #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 != 10)
        {
            Debug.Log("GodWeaponTuPo.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "ShenQiID")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[ShenQiID]位置不对应"); return(false);
        }
        if (vecLine[2] != "TuPo")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[TuPo]位置不对应"); return(false);
        }
        if (vecLine[3] != "HP")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[4] != "Pattack")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[5] != "Mattack")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[6] != "PDefense")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[7] != "MDefense")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[8] != "JueXing")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[JueXing]位置不对应"); return(false);
        }
        if (vecLine[9] != "Num")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Num]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)10)
            {
                return(false);
            }
            GodWeaponTuPoElement member = new GodWeaponTuPoElement();
            member.ID       = Convert.ToInt32(vecLine[0]);
            member.ShenQiID = Convert.ToInt32(vecLine[1]);
            member.TuPo     = Convert.ToInt32(vecLine[2]);
            member.HP       = Convert.ToInt32(vecLine[3]);
            member.Pattack  = Convert.ToInt32(vecLine[4]);
            member.Mattack  = Convert.ToInt32(vecLine[5]);
            member.PDefense = Convert.ToInt32(vecLine[6]);
            member.MDefense = Convert.ToInt32(vecLine[7]);
            member.JueXing  = Convert.ToInt32(vecLine[8]);
            member.Num      = Convert.ToInt32(vecLine[9]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.ID] = member;
        }
        return(true);
    }
Пример #2
0
 private GodWeaponTuPoTable()
 {
     m_mapElements    = new Dictionary <int, GodWeaponTuPoElement>();
     m_emptyItem      = new GodWeaponTuPoElement();
     m_vecAllElements = new List <GodWeaponTuPoElement>();
 }
Пример #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 != 10)
        {
            Debug.Log("GodWeaponTuPo.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "ID")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[ID]位置不对应"); return(false);
        }
        if (vecLine[1] != "ShenQiID")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[ShenQiID]位置不对应"); return(false);
        }
        if (vecLine[2] != "TuPo")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[TuPo]位置不对应"); return(false);
        }
        if (vecLine[3] != "HP")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[4] != "Pattack")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[5] != "Mattack")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[6] != "PDefense")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[7] != "MDefense")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[8] != "JueXing")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[JueXing]位置不对应"); return(false);
        }
        if (vecLine[9] != "Num")
        {
            Debug.Log("GodWeaponTuPo.csv中字段[Num]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            GodWeaponTuPoElement member = new GodWeaponTuPoElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ShenQiID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TuPo);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.HP);
            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.JueXing);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Num);

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