Beispiel #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 != 13)
        {
            Ex.Logger.Log("Npc.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "NpcID")
        {
            Ex.Logger.Log("Npc.csv中字段[NpcID]位置不对应"); return(false);
        }
        if (vecLine[1] != "ModelID")
        {
            Ex.Logger.Log("Npc.csv中字段[ModelID]位置不对应"); return(false);
        }
        if (vecLine[2] != "ModelScaling")
        {
            Ex.Logger.Log("Npc.csv中字段[ModelScaling]位置不对应"); return(false);
        }
        if (vecLine[3] != "Name")
        {
            Ex.Logger.Log("Npc.csv中字段[Name]位置不对应"); return(false);
        }
        if (vecLine[4] != "Title")
        {
            Ex.Logger.Log("Npc.csv中字段[Title]位置不对应"); return(false);
        }
        if (vecLine[5] != "HeadIcon")
        {
            Ex.Logger.Log("Npc.csv中字段[HeadIcon]位置不对应"); return(false);
        }
        if (vecLine[6] != "Level")
        {
            Ex.Logger.Log("Npc.csv中字段[Level]位置不对应"); return(false);
        }
        if (vecLine[7] != "NpcR")
        {
            Ex.Logger.Log("Npc.csv中字段[NpcR]位置不对应"); return(false);
        }
        if (vecLine[8] != "DialogID")
        {
            Ex.Logger.Log("Npc.csv中字段[DialogID]位置不对应"); return(false);
        }
        if (vecLine[9] != "FunctionID")
        {
            Ex.Logger.Log("Npc.csv中字段[FunctionID]位置不对应"); return(false);
        }
        if (vecLine[10] != "DungeonsID")
        {
            Ex.Logger.Log("Npc.csv中字段[DungeonsID]位置不对应"); return(false);
        }
        if (vecLine[11] != "Dialog")
        {
            Ex.Logger.Log("Npc.csv中字段[Dialog]位置不对应"); return(false);
        }
        if (vecLine[12] != "banjing")
        {
            Ex.Logger.Log("Npc.csv中字段[banjing]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)13)
            {
                return(false);
            }
            NpcElement member = new NpcElement();
            member.NpcID        = Convert.ToInt32(vecLine[0]);
            member.ModelID      = Convert.ToInt32(vecLine[1]);
            member.ModelScaling = Convert.ToSingle(vecLine[2]);
            member.Name         = vecLine[3];
            member.Title        = vecLine[4];
            member.HeadIcon     = vecLine[5];
            member.Level        = Convert.ToInt32(vecLine[6]);
            member.NpcR         = Convert.ToSingle(vecLine[7]);
            member.DialogID     = Convert.ToInt32(vecLine[8]);
            member.FunctionID   = Convert.ToInt32(vecLine[9]);
            member.DungeonsID   = vecLine[10];
            member.Dialog       = vecLine[11];
            member.banjing      = Convert.ToSingle(vecLine[12]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.NpcID] = member;
        }
        return(true);
    }
Beispiel #2
0
 private NpcTable()
 {
     m_mapElements    = new Dictionary <int, NpcElement>();
     m_emptyItem      = new NpcElement();
     m_vecAllElements = new List <NpcElement>();
 }
Beispiel #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 != 13)
        {
            Ex.Logger.Log("Npc.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "NpcID")
        {
            Ex.Logger.Log("Npc.csv中字段[NpcID]位置不对应"); return(false);
        }
        if (vecLine[1] != "ModelID")
        {
            Ex.Logger.Log("Npc.csv中字段[ModelID]位置不对应"); return(false);
        }
        if (vecLine[2] != "ModelScaling")
        {
            Ex.Logger.Log("Npc.csv中字段[ModelScaling]位置不对应"); return(false);
        }
        if (vecLine[3] != "Name")
        {
            Ex.Logger.Log("Npc.csv中字段[Name]位置不对应"); return(false);
        }
        if (vecLine[4] != "Title")
        {
            Ex.Logger.Log("Npc.csv中字段[Title]位置不对应"); return(false);
        }
        if (vecLine[5] != "HeadIcon")
        {
            Ex.Logger.Log("Npc.csv中字段[HeadIcon]位置不对应"); return(false);
        }
        if (vecLine[6] != "Level")
        {
            Ex.Logger.Log("Npc.csv中字段[Level]位置不对应"); return(false);
        }
        if (vecLine[7] != "NpcR")
        {
            Ex.Logger.Log("Npc.csv中字段[NpcR]位置不对应"); return(false);
        }
        if (vecLine[8] != "DialogID")
        {
            Ex.Logger.Log("Npc.csv中字段[DialogID]位置不对应"); return(false);
        }
        if (vecLine[9] != "FunctionID")
        {
            Ex.Logger.Log("Npc.csv中字段[FunctionID]位置不对应"); return(false);
        }
        if (vecLine[10] != "DungeonsID")
        {
            Ex.Logger.Log("Npc.csv中字段[DungeonsID]位置不对应"); return(false);
        }
        if (vecLine[11] != "Dialog")
        {
            Ex.Logger.Log("Npc.csv中字段[Dialog]位置不对应"); return(false);
        }
        if (vecLine[12] != "banjing")
        {
            Ex.Logger.Log("Npc.csv中字段[banjing]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            NpcElement member = new NpcElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.NpcID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.ModelID);
            readPos += GameAssist.ReadFloat(binContent, readPos, out member.ModelScaling);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Name);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Title);
            readPos += GameAssist.ReadString(binContent, readPos, out member.HeadIcon);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Level);
            readPos += GameAssist.ReadFloat(binContent, readPos, out member.NpcR);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.DialogID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.FunctionID);
            readPos += GameAssist.ReadString(binContent, readPos, out member.DungeonsID);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Dialog);
            readPos += GameAssist.ReadFloat(binContent, readPos, out member.banjing);

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