Пример #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 != 16)
        {
            Debug.Log("Equiptupo.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "TupoID")
        {
            Debug.Log("Equiptupo.csv中字段[TupoID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Grade")
        {
            Debug.Log("Equiptupo.csv中字段[Grade]位置不对应"); return(false);
        }
        if (vecLine[2] != "Item")
        {
            Debug.Log("Equiptupo.csv中字段[Item]位置不对应"); return(false);
        }
        if (vecLine[3] != "Num")
        {
            Debug.Log("Equiptupo.csv中字段[Num]位置不对应"); return(false);
        }
        if (vecLine[4] != "Pattack")
        {
            Debug.Log("Equiptupo.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[5] != "Mattack")
        {
            Debug.Log("Equiptupo.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[6] != "PDefense")
        {
            Debug.Log("Equiptupo.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[7] != "MDefense")
        {
            Debug.Log("Equiptupo.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[8] != "HP")
        {
            Debug.Log("Equiptupo.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[9] != "Baoji")
        {
            Debug.Log("Equiptupo.csv中字段[Baoji]位置不对应"); return(false);
        }
        if (vecLine[10] != "Bisha")
        {
            Debug.Log("Equiptupo.csv中字段[Bisha]位置不对应"); return(false);
        }
        if (vecLine[11] != "MP")
        {
            Debug.Log("Equiptupo.csv中字段[MP]位置不对应"); return(false);
        }
        if (vecLine[12] != "MpHuifu")
        {
            Debug.Log("Equiptupo.csv中字段[MpHuifu]位置不对应"); return(false);
        }
        if (vecLine[13] != "Renxing")
        {
            Debug.Log("Equiptupo.csv中字段[Renxing]位置不对应"); return(false);
        }
        if (vecLine[14] != "Shouhu")
        {
            Debug.Log("Equiptupo.csv中字段[Shouhu]位置不对应"); return(false);
        }
        if (vecLine[15] != "HpHuifu")
        {
            Debug.Log("Equiptupo.csv中字段[HpHuifu]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)16)
            {
                return(false);
            }
            EquiptupoElement member = new EquiptupoElement();
            member.TupoID   = Convert.ToInt32(vecLine[0]);
            member.Grade    = Convert.ToInt32(vecLine[1]);
            member.Item     = Convert.ToInt32(vecLine[2]);
            member.Num      = 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.HP       = Convert.ToInt32(vecLine[8]);
            member.Baoji    = Convert.ToInt32(vecLine[9]);
            member.Bisha    = Convert.ToInt32(vecLine[10]);
            member.MP       = Convert.ToInt32(vecLine[11]);
            member.MpHuifu  = Convert.ToInt32(vecLine[12]);
            member.Renxing  = Convert.ToInt32(vecLine[13]);
            member.Shouhu   = Convert.ToInt32(vecLine[14]);
            member.HpHuifu  = Convert.ToInt32(vecLine[15]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.TupoID] = member;
        }
        return(true);
    }
Пример #2
0
 private EquiptupoTable()
 {
     m_mapElements    = new Dictionary <int, EquiptupoElement>();
     m_emptyItem      = new EquiptupoElement();
     m_vecAllElements = new List <EquiptupoElement>();
 }
Пример #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 != 16)
        {
            Debug.Log("Equiptupo.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "TupoID")
        {
            Debug.Log("Equiptupo.csv中字段[TupoID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Grade")
        {
            Debug.Log("Equiptupo.csv中字段[Grade]位置不对应"); return(false);
        }
        if (vecLine[2] != "Item")
        {
            Debug.Log("Equiptupo.csv中字段[Item]位置不对应"); return(false);
        }
        if (vecLine[3] != "Num")
        {
            Debug.Log("Equiptupo.csv中字段[Num]位置不对应"); return(false);
        }
        if (vecLine[4] != "Pattack")
        {
            Debug.Log("Equiptupo.csv中字段[Pattack]位置不对应"); return(false);
        }
        if (vecLine[5] != "Mattack")
        {
            Debug.Log("Equiptupo.csv中字段[Mattack]位置不对应"); return(false);
        }
        if (vecLine[6] != "PDefense")
        {
            Debug.Log("Equiptupo.csv中字段[PDefense]位置不对应"); return(false);
        }
        if (vecLine[7] != "MDefense")
        {
            Debug.Log("Equiptupo.csv中字段[MDefense]位置不对应"); return(false);
        }
        if (vecLine[8] != "HP")
        {
            Debug.Log("Equiptupo.csv中字段[HP]位置不对应"); return(false);
        }
        if (vecLine[9] != "Baoji")
        {
            Debug.Log("Equiptupo.csv中字段[Baoji]位置不对应"); return(false);
        }
        if (vecLine[10] != "Bisha")
        {
            Debug.Log("Equiptupo.csv中字段[Bisha]位置不对应"); return(false);
        }
        if (vecLine[11] != "MP")
        {
            Debug.Log("Equiptupo.csv中字段[MP]位置不对应"); return(false);
        }
        if (vecLine[12] != "MpHuifu")
        {
            Debug.Log("Equiptupo.csv中字段[MpHuifu]位置不对应"); return(false);
        }
        if (vecLine[13] != "Renxing")
        {
            Debug.Log("Equiptupo.csv中字段[Renxing]位置不对应"); return(false);
        }
        if (vecLine[14] != "Shouhu")
        {
            Debug.Log("Equiptupo.csv中字段[Shouhu]位置不对应"); return(false);
        }
        if (vecLine[15] != "HpHuifu")
        {
            Debug.Log("Equiptupo.csv中字段[HpHuifu]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            EquiptupoElement member = new EquiptupoElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TupoID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Grade);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Item);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Num);
            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);

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