private void QuestUpdate(QuestTaskTypes eventType, int targetId, int amount = 1) { foreach (var quest in GetByTaskType(eventType)) { foreach (var task in quest.Tasks) { if (task.Type != eventType || task.TargetId != targetId) { continue; } if (!task.IsCompleted) { task.AddAmount(amount); } if (task.IsCompleted) { CompletedTasks.Add(task.Id); } if (task.IsOptional) { IsOptionalTasks.Add(task.Id); } #if UNITY_EDITOR Debug.Log($"QuestLogController>>> Task ID:[{task.Id}] ({quest.Tasks.IndexOf(task) + 1} out of {quest.Tasks.Count}) [{task.CurrentAmount} out of {task.NeededAmount}] from quest ID:[{quest.Id}] updated"); #endif } if (quest.IsComplete) { if (!AllTaskCompletedInQuestsWithOptional.Contains(quest.Id) & quest.HasOptionalTasks) { AllTaskCompletedInQuestsWithOptional.Add(quest.Id); } if (!AllTaskCompletedInQuests.Contains(quest.Id) & !quest.HasOptionalTasks) { AllTaskCompletedInQuests.Add(quest.Id); } Services.SharedInstance.EventManager.TriggerEvent(GameEventTypes.QuestCompleted, new IdArgs(quest.Id)); Services.SharedInstance.EventManager.TriggerEvent(GameEventTypes.QuestUpdated, null); #if UNITY_EDITOR Debug.Log($"QuestLogController>>> Quest ID:[{quest.Id}] Complete"); #endif } } }
/// <summary> /// updates status of quests /// </summary> /// <param name="eventType">Which event triggered (task type)</param> /// <param name="targetId">Id of target</param> /// <param name="amount">Amount of targets</param> private void QuestUpdate(QuestTaskTypes eventType, int targetId, int amount = 1) { foreach (var quest in GetByTaskType(eventType)) { foreach (var task in quest.Tasks) { if (task.Type != eventType || task.TargetId != targetId) { continue; } task.AddAmount(amount); #if UNITY_EDITOR Debug.Log($"QuestLogController>>> Task [{task.Id}] from quest [{quest.Id}] updated"); #endif } if (quest.IsComplete) { EventManager.TriggerEvent(GameEventTypes.QuestCompleted, new IdArgs(quest.Id)); Debug.Log($"QuestLogController>>> Quest [{quest.Id}] Complete"); } } }
public List <Quest> GetByTaskType(QuestTaskTypes type) { return(_quests.FindAll(x => x.Tasks.Any(y => y.Type == type))); }