Beispiel #1
0
 private FBDialogTable()
 {
     m_mapElements    = new Dictionary <int, FBDialogElement>();
     m_emptyItem      = new FBDialogElement();
     m_vecAllElements = new List <FBDialogElement>();
 }
Beispiel #2
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 != 7)
        {
            Ex.Logger.Log("FBDialog.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "DialogID")
        {
            Ex.Logger.Log("FBDialog.csv中字段[DialogID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Name1")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Name1]位置不对应"); return(false);
        }
        if (vecLine[2] != "Dialog1")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Dialog1]位置不对应"); return(false);
        }
        if (vecLine[3] != "BanShen")
        {
            Ex.Logger.Log("FBDialog.csv中字段[BanShen]位置不对应"); return(false);
        }
        if (vecLine[4] != "Set")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Set]位置不对应"); return(false);
        }
        if (vecLine[5] != "Next")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Next]位置不对应"); return(false);
        }
        if (vecLine[6] != "Time")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Time]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            FBDialogElement member = new FBDialogElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.DialogID);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Name1);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Dialog1);
            readPos += GameAssist.ReadString(binContent, readPos, out member.BanShen);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Set);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Next);
            readPos += GameAssist.ReadFloat(binContent, readPos, out member.Time);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.DialogID] = member;
        }
        return(true);
    }
Beispiel #3
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 != 7)
        {
            Ex.Logger.Log("FBDialog.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "DialogID")
        {
            Ex.Logger.Log("FBDialog.csv中字段[DialogID]位置不对应"); return(false);
        }
        if (vecLine[1] != "Name1")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Name1]位置不对应"); return(false);
        }
        if (vecLine[2] != "Dialog1")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Dialog1]位置不对应"); return(false);
        }
        if (vecLine[3] != "BanShen")
        {
            Ex.Logger.Log("FBDialog.csv中字段[BanShen]位置不对应"); return(false);
        }
        if (vecLine[4] != "Set")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Set]位置不对应"); return(false);
        }
        if (vecLine[5] != "Next")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Next]位置不对应"); return(false);
        }
        if (vecLine[6] != "Time")
        {
            Ex.Logger.Log("FBDialog.csv中字段[Time]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)7)
            {
                return(false);
            }
            FBDialogElement member = new FBDialogElement();
            member.DialogID = Convert.ToInt32(vecLine[0]);
            member.Name1    = Convert.ToInt32(vecLine[1]);
            member.Dialog1  = vecLine[2];
            member.BanShen  = vecLine[3];
            member.Set      = Convert.ToInt32(vecLine[4]);
            member.Next     = Convert.ToInt32(vecLine[5]);
            member.Time     = Convert.ToSingle(vecLine[6]);

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