Exemplo n.º 1
0
        public Condition Clone()
        {
            byte[] data = StructWriter.Convert(this);
            object obj  = QuestFile.CreateObject(this.getConditionType());

            StructReader.Convert(data, ref obj);
            return((Condition)obj);
        }
Exemplo n.º 2
0
        public Reward Clone()
        {
            byte[] data = StructWriter.Convert(this);
            object obj  = QuestFile.CreateObject(this.getRewardType());

            StructReader.Convert(data, ref obj);
            return((Reward)obj);
        }
Exemplo n.º 3
0
        public void Load(string Filename)
        {
            this.FileName = Filename;

            FileHandler fh = new FileHandler(Filename, FileHandler.FileOpenMode.Reading, Encoding.GetEncoding("EUC-KR"));

            Version = fh.Read <int>();
            int blockCount = fh.Read <int>();

            Title = fh.Read <string>(fh.Read <short>()).Trim('\0');

            for (int i = 0; i < blockCount; i++)
            {
                QuestBlock block = new QuestBlock();

                int triggersCount = fh.Read <int>();
                block.Name = fh.Read <string>(fh.Read <short>()).Trim('\0');

                for (int j = 0; j < triggersCount; j++)
                {
                    QuestTrigger trigger = new QuestTrigger();
                    trigger.CheckNext = (fh.Read <byte>() != 0);
                    int ConditionsCount = fh.Read <int>();
                    int RewardsCount    = fh.Read <int>();
                    trigger.Name = fh.Read <string>(fh.Read <short>()).Trim('\0');

                    for (int c = 0; c < ConditionsCount; c++)
                    {
                        int    size = fh.Read <int>();
                        int    type = fh.Read <int>();
                        byte[] data = fh.Read <byte[]>(size - 8);

                        try
                        {
                            object obj = CreateObject((ConditionType)type);
                            StructReader.Convert(data, ref obj);

                            Condition condition = (Condition)obj;
                            condition.setOriginalData(data);
                            trigger.Conditions.Add(condition);
                        }
                        catch
                        {
                            object    obj       = CreateObject(ConditionType.COND000);
                            Condition condition = (Condition)obj;
                            condition.setOriginalData(data);
                            trigger.Conditions.Add(condition);
                        }
                    }

                    for (int c = 0; c < RewardsCount; c++)
                    {
                        int    size = fh.Read <int>();
                        int    type = fh.Read <int>() & 0x0ffff;
                        byte[] data = fh.Read <byte[]>(size - 8);

                        try
                        {
                            object obj = CreateObject((RewardType)type);
                            StructReader.Convert(data, ref obj);
                            Reward reward = (Reward)obj;
                            reward.setOriginalData(data);
                            trigger.Rewards.Add(reward);
                        }
                        catch
                        {
                            object obj    = CreateObject(RewardType.REWD000);
                            Reward reward = (Reward)obj;
                            reward.setOriginalData(data);
                            trigger.Rewards.Add(reward);
                        }
                    }
                    block.Triggers.Add(trigger);
                }
                this.Blocks.Add(block);
            }
            fh.Close();
        }