Quest Manager

Presented by IQuestManager interface, this system provides functionality for processing quests.

To use this system, inject IQuestManager interface into your class, as shown below:

[Inject] private IQuestManager questManager;

Parameters in inspector

questsCollection reference to scriptable object which contains quests collection (all available quests and initial quests list, separately).

Available methods

void StartQuest(string questId)

This method starts quest by known questId. If this parameter is not correct or empty, this method will not do anything. questId string should have GUID format.

Example:

questManager.StartQuest("99ec04ae-e322-4e8c-9409-f924aae4150a");

void AddProgress(QuestTaskType questTaskType, int progress)

This method increments progress of all active quests which have a certain task type.

Examples:

questManager.AddProgress(QuestTaskType.GameWon, 1);
questManager.AddProgress(QuestTaskType.EnemiesDefeated, 1);

QuestInfo GetQuestInfo(string questId)

This method returns information about quest with certain ID.

Example:

QuestInfo questInfo = questManager.GetQuestInfo("99ec04ae-e322-4e8c-9409-f924aae4150a");

Debug.Log("Quest title: " + questInfo.Title);
Debug.Log("Quest desc: " + questInfo.Description);

QuestState GetQuestState(string questId)

This method returns current state of quest with certain ID. You can use this to get information about quest progress.

Example:

QuestState questState = questManager.GetQuestState(questId);

Debug.Log($"First task progress: {questState.QuestProgress[0]}");

int GetQuestTaskProgress(string questId, QuestTaskType taskType)

This method returns current progress for task taskType for quest with questId.

Example:

int enemiesDefeated = questManager.GetQuestTaskProgress(questId, QuestTaskType.EnemiesDefeated);

Debug.Log($"Enemies defeated: {enemiesDefeated}");

bool IsQuestCompleted(string questId)

This method returns true, if quest is completed, otherwise it returns false.


bool IsQuestActive(string questId)

This method returns true, if quest was started and is currently running.

Last updated