Пример #1
0
        public static Quest GetQuest(WZProperty questWz, int questId)
        {
            QuestRewards[]      rewards      = QuestRewards.Parse(questWz.Resolve($"Act/{questId}")) ?? new QuestRewards[0];
            QuestRequirements[] requirements = QuestRequirements.Parse(questWz.Resolve($"Check/{questId}")) ?? new QuestRequirements[0];
            Quest quest = Quest.Parse(questWz.Resolve($"QuestInfo/{questId}"));

            if (quest == null)
            {
                return(null);
            }

            quest.RequirementToComplete = requirements?.Where(b => b != null && b.State == QuestState.Complete).FirstOrDefault();
            quest.RequirementToStart    = requirements?.Where(b => b != null && b.State == QuestState.Start).FirstOrDefault();
            quest.RewardOnStart         = rewards?.Where(b => b != null && b.State == QuestState.Start).FirstOrDefault();
            quest.RewardOnComplete      = rewards?.Where(b => b != null && b.State == QuestState.Complete).FirstOrDefault();
            if (questWz.FileContainer.Collection is MSPackageCollection)
            {
                MSPackageCollection collection = (MSPackageCollection)questWz.FileContainer.Collection;
                if (collection.AvailableOnCompleteTable.ContainsKey(quest.Id))
                {
                    quest.QuestsAvailableOnComplete = collection.AvailableOnCompleteTable[quest.Id];
                }
            }

            return(quest);
        }
Пример #2
0
        public static QuestRequirements[] Parse(WZProperty data)
        {
            if (data == null)
            {
                return(null);
            }
            int id = int.Parse(data.NameWithoutExtension);
            QuestRequirements onStart    = QuestRequirements.Parse(id, data.Resolve("0"), QuestState.Start);
            QuestRequirements onComplete = QuestRequirements.Parse(id, data.Resolve("1"), QuestState.Complete);

            return(new QuestRequirements[] { onStart, onComplete });
        }