public void CompleteQuest(QuestID questID) { if (!QuestData.IsCompleted(questID)) { QuestChapter currentQuestChapter = IsValidQuestChapterIndex(CurrentQuestChapterIndex) ? QuestBook.QuestChapters[CurrentQuestChapterIndex] : null; if (currentQuestChapter != null && currentQuestChapter.Contains(questID)) { QuestData.CompleteQuest(questID); if (QuestBook.QuestChapters[CurrentQuestChapterIndex].Quests.All((quest) => QuestData.IsCompleted(quest.ID))) { CurrentQuestChapterIndex++; } } } }
void LoadQuestData() { if (File.Exists(QuestDataPath)) { var bytes = File.ReadAllBytes(QuestDataPath); QuestData = SerializationUtility.DeserializeValue <QuestData>(bytes, DataFormat); if (QuestData == null) { ResetQuestData(); } else { CurrentQuestChapterIndex = 0; while (IsValidQuestChapterIndex(CurrentQuestChapterIndex) && QuestBook.QuestChapters[CurrentQuestChapterIndex].Quests.All((quest) => QuestData.IsCompleted(quest.ID))) { CurrentQuestChapterIndex++; } } } else { ResetQuestData(); } }
void ResetQuestData() { QuestData = new QuestData(); CurrentQuestChapterIndex = 0; }