Beispiel #1
0
 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++;
             }
         }
     }
 }
Beispiel #2
0
 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();
     }
 }