Ejemplo n.º 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 != 17)
        {
            Ex.Logger.Log("ExpandAI.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "expendAiId")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[expendAiId]位置不对应"); return(false);
        }
        if (vecLine[1] != "Comment")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[Comment]位置不对应"); return(false);
        }
        if (vecLine[2] != "aiGroup")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[aiGroup]位置不对应"); return(false);
        }
        if (vecLine[3] != "TriggerType")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[TriggerType]位置不对应"); return(false);
        }
        if (vecLine[4] != "TriggerParameter")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[TriggerParameter]位置不对应"); return(false);
        }
        if (vecLine[5] != "times")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[times]位置不对应"); return(false);
        }
        if (vecLine[6] != "eventRange")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[eventRange]位置不对应"); return(false);
        }
        if (vecLine[7] != "dialogId")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[dialogId]位置不对应"); return(false);
        }
        if (vecLine[8] != "HelpScope")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[HelpScope]位置不对应"); return(false);
        }
        if (vecLine[9] != "HelpMonster")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[HelpMonster]位置不对应"); return(false);
        }
        if (vecLine[10] != "Order")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[Order]位置不对应"); return(false);
        }
        if (vecLine[11] != "UseSkill")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[UseSkill]位置不对应"); return(false);
        }
        if (vecLine[12] != "JumpAI")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[JumpAI]位置不对应"); return(false);
        }
        if (vecLine[13] != "JumpNPC")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[JumpNPC]位置不对应"); return(false);
        }
        if (vecLine[14] != "SpecialEvent")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[SpecialEvent]位置不对应"); return(false);
        }
        if (vecLine[15] != "EventProbability")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[EventProbability]位置不对应"); return(false);
        }
        if (vecLine[16] != "FleeSpeed")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[FleeSpeed]位置不对应"); return(false);
        }

        while (true)
        {
            vecLine = GameAssist.readCsvLine(strContent, ref contentOffset);
            if ((int)vecLine.Count == 0)
            {
                break;
            }
            if ((int)vecLine.Count != (int)17)
            {
                return(false);
            }
            ExpandAIElement member = new ExpandAIElement();
            member.expendAiId       = Convert.ToInt32(vecLine[0]);
            member.Comment          = vecLine[1];
            member.aiGroup          = Convert.ToInt32(vecLine[2]);
            member.TriggerType      = Convert.ToInt32(vecLine[3]);
            member.TriggerParameter = vecLine[4];
            member.times            = Convert.ToInt32(vecLine[5]);
            member.eventRange       = Convert.ToSingle(vecLine[6]);
            member.dialogId         = Convert.ToInt32(vecLine[7]);
            member.HelpScope        = Convert.ToInt32(vecLine[8]);
            member.HelpMonster      = vecLine[9];
            member.Order            = Convert.ToInt32(vecLine[10]);
            member.UseSkill         = Convert.ToInt32(vecLine[11]);
            member.JumpAI           = Convert.ToInt32(vecLine[12]);
            member.JumpNPC          = Convert.ToInt32(vecLine[13]);
            member.SpecialEvent     = vecLine[14];
            member.EventProbability = Convert.ToInt32(vecLine[15]);
            member.FleeSpeed        = Convert.ToInt32(vecLine[16]);

            member.IsValidate = true;
            m_vecAllElements.Add(member);
            m_mapElements[member.expendAiId] = member;
        }
        return(true);
    }
Ejemplo n.º 2
0
 private ExpandAITable()
 {
     m_mapElements    = new Dictionary <int, ExpandAIElement>();
     m_emptyItem      = new ExpandAIElement();
     m_vecAllElements = new List <ExpandAIElement>();
 }
Ejemplo n.º 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 != 17)
        {
            Ex.Logger.Log("ExpandAI.csv中列数量与生成的代码不匹配!");
            return(false);
        }
        if (vecLine[0] != "expendAiId")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[expendAiId]位置不对应"); return(false);
        }
        if (vecLine[1] != "Comment")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[Comment]位置不对应"); return(false);
        }
        if (vecLine[2] != "aiGroup")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[aiGroup]位置不对应"); return(false);
        }
        if (vecLine[3] != "TriggerType")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[TriggerType]位置不对应"); return(false);
        }
        if (vecLine[4] != "TriggerParameter")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[TriggerParameter]位置不对应"); return(false);
        }
        if (vecLine[5] != "times")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[times]位置不对应"); return(false);
        }
        if (vecLine[6] != "eventRange")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[eventRange]位置不对应"); return(false);
        }
        if (vecLine[7] != "dialogId")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[dialogId]位置不对应"); return(false);
        }
        if (vecLine[8] != "HelpScope")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[HelpScope]位置不对应"); return(false);
        }
        if (vecLine[9] != "HelpMonster")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[HelpMonster]位置不对应"); return(false);
        }
        if (vecLine[10] != "Order")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[Order]位置不对应"); return(false);
        }
        if (vecLine[11] != "UseSkill")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[UseSkill]位置不对应"); return(false);
        }
        if (vecLine[12] != "JumpAI")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[JumpAI]位置不对应"); return(false);
        }
        if (vecLine[13] != "JumpNPC")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[JumpNPC]位置不对应"); return(false);
        }
        if (vecLine[14] != "SpecialEvent")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[SpecialEvent]位置不对应"); return(false);
        }
        if (vecLine[15] != "EventProbability")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[EventProbability]位置不对应"); return(false);
        }
        if (vecLine[16] != "FleeSpeed")
        {
            Ex.Logger.Log("ExpandAI.csv中字段[FleeSpeed]位置不对应"); return(false);
        }

        for (int i = 0; i < nRow; i++)
        {
            ExpandAIElement member = new ExpandAIElement();
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.expendAiId);
            readPos += GameAssist.ReadString(binContent, readPos, out member.Comment);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.aiGroup);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.TriggerType);
            readPos += GameAssist.ReadString(binContent, readPos, out member.TriggerParameter);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.times);
            readPos += GameAssist.ReadFloat(binContent, readPos, out member.eventRange);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.dialogId);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.HelpScope);
            readPos += GameAssist.ReadString(binContent, readPos, out member.HelpMonster);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.Order);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.UseSkill);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.JumpAI);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.JumpNPC);
            readPos += GameAssist.ReadString(binContent, readPos, out member.SpecialEvent);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.EventProbability);
            readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.FleeSpeed);

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