Exemplo n.º 1
0
 public void Clone(ScriptCommand cmd)
 {
     id     = cmd.id;
     values = new Object[cmd.values.Length];
     for (int i = 0; i < cmd.values.Length; i++)
     {
         values[i] = cmd.values[i];
     }
 }
Exemplo n.º 2
0
        public int addCode(int id, int index, bool ext = false)
        {
            ScriptCommand cmd = ScriptCommand.createCommand(id);

            if (ext)
            {
                cmd.setExtValue(2);
            }
            commandList.Insert(index, cmd);
            return(index);
        }
Exemplo n.º 3
0
        public bool loadReader(EexBinaryReader reader)
        {
            commandList.Clear();

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

            int buildTreeCmd = -1;

            while (reader.getIndex() < endIndex)
            {
                int           cmdId = reader.readUShort();
                ScriptCommand cmd   = ScriptCommand.createCommand(cmdId);
                try
                {
                    cmd.loadReader(reader);
                }
                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
        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.º 5
0
        public void computeExValue(EexBinaryWriter writer)
        {
            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);
                    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);

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

            int sectionEnd = writer.getIndex();

            writer.setIndex(sectionStart).writeUShort((ushort)commandList.Count);
            writer.setIndex(sectionEnd);
        }
Exemplo n.º 7
0
 public void removeCode(ScriptCommand cmd)
 {
     removeCode(commandList.IndexOf(cmd));
 }
Exemplo n.º 8
0
 public void CobyCode(int id, ScriptCommand cmd)
 {
     commandList.Insert(commandList.IndexOf(cmd) + 1, cmd);
 }
Exemplo n.º 9
0
 public int FindCommand(ScriptCommand cmd)
 {
     return(commandList.IndexOf(cmd));
 }
Exemplo n.º 10
0
 public int addCode(int id, ScriptCommand cmd, bool ext = false)
 {
     return(addCode(id, FindCommand(cmd) + 1, ext));
 }
Exemplo n.º 11
0
 public void addCmd(int index, ScriptCommand cmd)
 {
     commandList.Insert(index, cmd);
 }
Exemplo n.º 12
0
        public static String getNodeText(ScriptCommand cmd)
        {
            CommandConfig cfg = ScriptConfig.Instance.getCommandConfig(cmd.id);
            String        ret = String.Format("{0:x}:{1}", cmd.id, cfg.Name);

            switch (cmd.id)
            {
            case 0x5:
            {
                ushort[] true_list  = (ushort[])cmd.values[0];
                ushort[] false_list = (ushort[])cmd.values[1];
                int      n          = true_list.Length;
                ret += "   ";
                for (int i = 0; i < n; i++)
                {
                    ret += "Var" + true_list[i];
                    ret += " ";
                }
                ret += "; ";
                n    = false_list.Length;
                for (int i = 0; i < n; i++)
                {
                    ret += "Var" + false_list[i];
                    ret += " ";
                }
            }
            break;

            case 0x46:
            case 0x47:
                break;

            default:
            {
                for (int i = 0; i < cmd.keys.Length; i++)
                {
                    int key = cmd.keys[i];
                    ret += (" ");
                    //EexType etype = ScriptConfig.Instance.getEexType(key);
                    switch (key)
                    {
                    case 4:
                        //TempStr += ReadLong_Str();
                        ret += cmd.values[i].ToString();
                        break;

                    case 0x102:
                        ret += "Var" + cmd.values[i].ToString();
                        //tt.Format(("Var{0}"), ReadLong());
                        //TempStr += tt;
                        break;

                    case 5:
                        ret += cmd.values[i].ToString();
                        //tt = ReadStr(true);
                        //tt.Replace(("\r\n"), ("\\n"));
                        //TempStr += tt;
                        break;

                    case 0x100:
                        ret += cmd.values[i].ToString();
                        //TempStr += ReadPos(true);
                        break;

                    case 0x101:
                        ret += cmd.values[i].ToString();
                        //TempStr += ReadArea(true);
                        break;

                    case 0x103:
                        ret += cmd.values[i].ToString();
                        //TempStr += GetParameterName_Int(ParameterInfo[i], ReadInt(3), Code, i - CodeInfo[Code].ParameterIndex);
                        break;

                    default:
                        string aaa = cmd.values[i].ToString();
                        ret += GetParameterName_Int(key, Convert.ToInt32(cmd.values[i]), cmd.id, 0 /*i - CodeInfo[Code].ParameterIndex*/);
                        break;
                    }
                }
            }
            break;
            }

            return(ret);
        }