예제 #1
0
        public void Load(List <Character_quest> quests)
        {
            if (quests == null)
            {
                return;
            }

            foreach (Character_quest quest in quests)
            {
                quest.Quest = QuestService.GetQuest(quest.QuestID);
                if (quest.Quest == null)
                {
                    continue;
                }

                foreach (Character_Objectives obj in quest._Objectives)
                {
                    obj.Objective = QuestService.GetQuestObjective(obj.ObjectiveID);
                }

                // If a quest objective has been deleted in the world db lets remove it from the player
                quest._Objectives = quest._Objectives.FindAll(o => o.Objective != null);

                if (!this.Quests.ContainsKey(quest.QuestID))
                {
                    this.Quests.Add(quest.QuestID, quest);
                }
            }
        }
예제 #2
0
        public void BuildQuest(ushort questID, Player plr)
        {
            Quest q = QuestService.GetQuest(questID);

            if (q == null)
            {
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE, 14);

            Out.WriteByte(1);
            Out.WriteByte(1);

            BuildQuestInteract(Out, q.Entry, _Owner.Oid, plr.Oid); // 10 bytes

            Out.WriteUInt16(0);

            BuildQuestInfo(Out, plr, q);

            plr.SendPacket(Out);
        }
예제 #3
0
 public bool AcceptQuest(ushort questID)
 {
     return(AcceptQuest(QuestService.GetQuest(questID)));
 }
예제 #4
0
        public static List <ParsedProgression <TDefinition> > RetrieveProgressionLockedItems <TDefinition, TReward>(ProgressionUnlockCategory category, Func <List <TReward>, TDefinition[]> getRewards) where TDefinition : StaticGameDataDefinition, IMemberLocked where TReward : AbstractStaticGameDataRewardDefinition <TDefinition>
        {
            ProgressionService progressionService = Service.Get <ProgressionService>();

            TDefinition[]         unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TDefinition>(category);
            HashSet <TDefinition> hashSet = new HashSet <TDefinition>(unlockedDefinitionsForCategory);
            int level = progressionService.Level;
            List <ParsedProgression <TDefinition> > list = new List <ParsedProgression <TDefinition> >();
            int  lastUnlockedIndex   = -1;
            bool isLocalPlayerMember = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember();

            for (int i = 0; i <= progressionService.MaxUnlockLevel; i++)
            {
                TDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, category).Definitions as TDefinition[];
                if (array == null || array.Length <= 0)
                {
                    continue;
                }
                bool flag = i > level;
                for (int j = 0; j < array.Length; j++)
                {
                    if ((UnityEngine.Object)array[j] != (UnityEngine.Object)null)
                    {
                        ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array[j], i, null, flag, progressionLocked: false, array[j].IsMemberOnly);
                        addParsedProgression(list, parsedProgression, flag, isLocalPlayerMember, ref lastUnlockedIndex);
                        if (hashSet.Contains(array[j]))
                        {
                            hashSet.Remove(array[j]);
                        }
                    }
                }
            }
            QuestService questService = Service.Get <QuestService>();
            Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap;

            foreach (QuestDefinition knownQuest in questService.KnownQuests)
            {
                questToMascotMap.TryGetValue(knownQuest.name, out var value);
                if (value == null)
                {
                    continue;
                }
                string name = value.Name;
                questService.GetQuest(knownQuest);
                if (knownQuest.StartReward != null)
                {
                    parseRewardDefinition(list, getRewards(knownQuest.StartReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex);
                }
                if (knownQuest.CompleteReward != null)
                {
                    parseRewardDefinition(list, getRewards(knownQuest.CompleteReward.GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex);
                }
                if (knownQuest.ObjectiveRewards != null)
                {
                    for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++)
                    {
                        parseRewardDefinition(list, getRewards(knownQuest.ObjectiveRewards[j].GetDefinitions <TReward>()), hashSet, progressionService, category, name, ref lastUnlockedIndex);
                    }
                }
            }
            if (hashSet.Count > 0)
            {
                TDefinition[] array2 = new TDefinition[hashSet.Count];
                hashSet.CopyTo(array2);
                for (int j = 0; j < array2.Length; j++)
                {
                    ParsedProgression <TDefinition> parsedProgression = new ParsedProgression <TDefinition>(array2[j], -1, null, levelLocked: false, progressionLocked: false, array2[j].IsMemberOnly);
                    lastUnlockedIndex++;
                    list.Insert(lastUnlockedIndex, parsedProgression);
                }
            }
            return(list);
        }
        private void parseItemGroups()
        {
            progressionService = Service.Get <ProgressionService>();
            TemplateDefinition[] unlockedDefinitionsForCategory = progressionService.GetUnlockedDefinitionsForCategory <TemplateDefinition>(ProgressionUnlockCategory.equipmentTemplates);
            progressionUnlockedRewards = new HashSet <TemplateDefinition>(unlockedDefinitionsForCategory);
            userLevel = progressionService.Level;
            for (int i = 0; i <= progressionService.MaxUnlockLevel; i++)
            {
                TemplateDefinition[] array = progressionService.GetUnlockedDefinitionsForLevel(i, ProgressionUnlockCategory.equipmentTemplates).Definitions as TemplateDefinition[];
                if (array == null || array.Length <= 0)
                {
                    continue;
                }
                bool isProgressionLocked = i > userLevel;
                for (int j = 0; j < array.Length; j++)
                {
                    if (array[j] != null && array[j].IsEditable)
                    {
                        DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array[j], i, null);
                        addRewardTemplate(newDisplayTemplate, isProgressionLocked);
                        if (progressionUnlockedRewards.Contains(array[j]))
                        {
                            progressionUnlockedRewards.Remove(array[j]);
                        }
                    }
                }
            }
            QuestService questService = Service.Get <QuestService>();
            Dictionary <string, Mascot> questToMascotMap = questService.QuestToMascotMap;

            foreach (QuestDefinition knownQuest in questService.KnownQuests)
            {
                questToMascotMap.TryGetValue(knownQuest.name, out var value);
                if (value == null)
                {
                    continue;
                }
                string mascotName = value.Name;
                Quest  quest      = questService.GetQuest(knownQuest);
                if (knownQuest.StartReward != null)
                {
                    if (quest.State == Quest.QuestState.Active || quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0)
                    {
                        mascotName = "";
                    }
                    parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.StartReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName);
                }
                if (knownQuest.CompleteReward != null)
                {
                    if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0)
                    {
                        mascotName = "";
                    }
                    parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.CompleteReward.GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName);
                }
                if (knownQuest.ObjectiveRewards != null)
                {
                    if (quest.State == Quest.QuestState.Completed || quest.TimesCompleted > 0)
                    {
                        mascotName = "";
                    }
                    for (int j = 0; j < knownQuest.ObjectiveRewards.Length; j++)
                    {
                        parseRewardDefinition(AbstractStaticGameDataRewardDefinition <TemplateDefinition> .ToDefinitionArray(knownQuest.ObjectiveRewards[j].GetDefinitions <EquipmentTemplateRewardDefinition>()), mascotName);
                    }
                }
            }
            if (progressionUnlockedRewards.Count <= 0)
            {
                return;
            }
            TemplateDefinition[] array2 = new TemplateDefinition[progressionUnlockedRewards.Count];
            progressionUnlockedRewards.CopyTo(array2);
            for (int j = 0; j < array2.Length; j++)
            {
                if (array2[j].IsEditable)
                {
                    DisplayedTemplate newDisplayTemplate = new DisplayedTemplate(array2[j], -1, null);
                    lastUnlockedIndex++;
                    rewardTemplates.Insert(lastUnlockedIndex, newDisplayTemplate);
                }
            }
        }
예제 #6
0
        public Quest GetNextQuest(Option option)
        {
            player.NextQuest = option.LinkedQuest.Value;

            return(_service.GetQuest(option.QuestId));
        }