Exemplo n.º 1
0
        public bool loadReader(EexBinaryReader reader, int group)
        {
            commandList.Clear();
            cmdIndexList.Clear();

            int sectionLen = reader.readUShort();
            int endIndex   = reader.getIndex() + sectionLen;

            int buildTreeCmd = -1;

            while (reader.getIndex() < endIndex)
            {
                int           cmdIndex = reader.getIndex();
                int           cmdId    = reader.readUShort();
                ScriptCommand cmd      = ScriptCommand.createCommand(cmdId);
                try
                {
                    cmd.loadReader(reader, group);
                }
                catch (EexReaderException exception)
                {
                    exception.CommandId = cmdId;
                    throw;
                }
                commandList.Add(cmd);
                cmdIndexList.Add(cmdIndex);

                if (buildTreeCmd != -1)
                {
                    if ((buildTreeCmd == (int)CommandId.CMD_CHILD_INFO_ACTION &&
                         cmdId == (int)CommandId.CMD_ACTION_END) ||
                        (buildTreeCmd == (int)CommandId.CMD_CHILD_ACTION))
                    {
                        buildTreeCmd = -1;
                        cmd.setExtValue(reader.readUShort());
                        continue;
                    }
                }

                switch ((CommandId)cmdId)
                {
                case CommandId.CMD_CHILD_ACTION:      // = 0x1;//子事件设定
                case CommandId.CMD_CHILD_INFO_ACTION: // = 0x2;//子事件设定带信息
                    buildTreeCmd = cmdId;
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool loadJson(JObject jobj)
        {
            commandList.Clear();

            JArray jar = (JArray)jobj["commands"];

            int buildTreeCmd = -1;

            foreach (JObject item in jar)
            {
                int cmdId = ScriptCommand.parseCommandId(item);

                ScriptCommand cmd = ScriptCommand.createCommand(cmdId);
                try
                {
                    cmd.loadJson(item);
                }
                catch (EexReaderException exception)
                {
                    exception.CommandId = cmdId;
                    throw;
                }
                commandList.Add(cmd);

                if (buildTreeCmd != -1)
                {
                    if ((buildTreeCmd == (int)CommandId.CMD_CHILD_INFO_ACTION &&
                         cmdId == (int)CommandId.CMD_ACTION_END) ||
                        (buildTreeCmd == (int)CommandId.CMD_CHILD_ACTION))
                    {
                        buildTreeCmd = -1;
                        cmd.setExtValue(ScriptCommand.parseExtValue(item));
                        continue;
                    }
                }

                switch ((CommandId)cmdId)
                {
                case CommandId.CMD_CHILD_ACTION:      // = 0x1;//子事件设定
                case CommandId.CMD_CHILD_INFO_ACTION: // = 0x2;//子事件设定带信息
                    buildTreeCmd = cmdId;
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 3
0
        public bool loadNewReader(EexBinaryReader reader)
        {
            commandList.Clear();

            int sectionCount = reader.readUShort();

            int buildTreeCmd = -1;

            for (int i = 0; i < sectionCount; i++)
            {
                int           cmdId = reader.readUShort();
                ScriptCommand cmd   = ScriptCommand.createCommand(cmdId);
                try
                {
                    cmd.loadReader(reader, 0);
                }
                catch (EexReaderException exception)
                {
                    exception.CommandId = cmdId;
                    throw;
                }
                commandList.Add(cmd);

                if (buildTreeCmd != -1)
                {
                    if ((buildTreeCmd == (int)CommandId.CMD_CHILD_INFO_ACTION &&
                         cmdId == (int)CommandId.CMD_ACTION_END) ||
                        (buildTreeCmd == (int)CommandId.CMD_CHILD_ACTION))
                    {
                        buildTreeCmd = -1;
                        cmd.setExtValue(reader.readUShort());
                        continue;
                    }
                }

                switch ((CommandId)cmdId)
                {
                case CommandId.CMD_CHILD_ACTION:      // = 0x1;//子事件设定
                case CommandId.CMD_CHILD_INFO_ACTION: // = 0x2;//子事件设定带信息
                    buildTreeCmd = cmdId;
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        private bool CorrectCmdData(bool isEEX) //修正76指令参数错误的问题;返回值bCorrect标记是否做过修正
        {
            bool bCorrect = false;
            int  cmdIndex = 0;

            for (int i = 0; i < sceneList.Count; i++)
            {
                cmdIndex++;
                for (int j = 0; j < sceneList[i].SectionList.Count; j++)
                {
                    cmdIndex++;
                    for (int k = 0; k < sceneList[i].SectionList[j].CommandList.Count; k++)
                    {
                        ScriptCommand curCmd = sceneList[i].SectionList[j].CommandList[k];
                        cmdIndex++;
                        if (curCmd.Id == 0x76)
                        {
                            if (isEEX)
                            {
                                int relaIndex = (int)curCmd.Values[0] + cmdIndexList[cmdIndex];
                                for (int l = 0; l < cmdIndexList.Count; l++)
                                {
                                    if (cmdIndexList[l] == relaIndex)
                                    {
                                        sceneList[i].SectionList[j].CommandList[k].Values[0] = l;
                                        bCorrect = true;
                                    }
                                }
                            }
                            else
                            {
                                int index = (int)sceneList[i].SectionList[j].CommandList[k].Values[0];
                                sceneList[i].SectionList[j].CommandList[k].Values[0] = cmdIndexList[index] - cmdIndexList[cmdIndex];
                                bCorrect = true;
                            }
                        }
                    }
                }
            }

            return(bCorrect);
        }
Exemplo n.º 5
0
        public void computeExValue(EexBinaryWriter writer, int group)
        {
            int writerIndex = writer.getIndex();

            for (int i = 0; i < commandList.Count; i++)
            {
                if (!commandList[i].isExtValueAvailable())
                {
                    continue;
                }

                int level = 1;
                writer.setIndex(writerIndex);
                for (int j = i + 1; j < commandList.Count; j++)
                {
                    ScriptCommand cmd = commandList[j];
                    if (cmd.isExtValueAvailable())
                    {
                        level++;
                    }
                    writer.writeUShort((ushort)cmd.Id);
                    cmd.saveWriter(writer, group);
                    if (cmd.isExtValueAvailable())
                    {
                        writer.writeUShort((ushort)cmd.getExtValue());
                    }

                    if (cmd.Id == (int)CommandId.CMD_ACTION_END)
                    {
                        level--;
                        if (level == 0)
                        {
                            break;
                        }
                    }
                }
                commandList[i].setExtValue(writer.getIndex() - writerIndex);
            }
            writer.setIndex(writerIndex);
        }
Exemplo n.º 6
0
        public void saveNewWriter(EexBinaryWriter writer)
        {
            int sectionStart = writer.getIndex();

            writer.writeUShort(0);

            for (int i = 0; i < commandList.Count; i++)
            {
                ScriptCommand cmd = commandList[i];
                writer.writeUShort((ushort)cmd.Id);
                cmd.saveWriter(writer, 0);

                if (cmd.isExtValueAvailable())
                {
                    writer.writeUShort((ushort)cmd.getExtValue());
                }
            }

            int sectionEnd = writer.getIndex();

            writer.setIndex(sectionStart).writeUShort((ushort)commandList.Count);
            writer.setIndex(sectionEnd);
        }