public void AddNewObjective(Objective_Base referenceObjective) { activeObjectives.Add(referenceObjective); questCompletionStates[referenceObjective.QuestEnumeration] = 1; UpdateObjectiveInterface(); SaveQuestLog(); }
private void Update() { if (!questsLoaded) { foreach (UnityEngine.Object obj in Resources.LoadAll <UnityEngine.Object>("ObjectiveQuests")) { Objective_Base temp = (ScriptableObject.CreateInstance(obj.name) as Objective_Base); //Quest In Progress if (questCompletionStates.ContainsKey(temp.QuestEnumeration) && questCompletionStates[temp.QuestEnumeration] == 1) { temp.QuestStage = questProgressStates[temp.QuestEnumeration]; AddNewObjective(temp); } //Quest Not Started else if (!questCompletionStates.ContainsKey(temp.QuestEnumeration)) { questProgressStates.Add(temp.QuestEnumeration, 0); questCompletionStates.Add(temp.QuestEnumeration, 0); } //Quest Completed else if (questCompletionStates.ContainsKey(temp.QuestEnumeration) && questCompletionStates[temp.QuestEnumeration] == 2) { Destroy(temp); temp = null; } } questsLoaded = true; } }
public void LoadQuestLog() { BinaryFormatter bf = new BinaryFormatter(); FileStream ifs = new FileStream("QuestLog.dat", FileMode.Open); QuestLog myLog = (QuestLog)bf.Deserialize(ifs); questCompletionStates = myLog.questCompletionStates; questProgressStates = myLog.questProgressState; ifs.Close(); if (!questsLoaded) { foreach (UnityEngine.Object obj in Resources.LoadAll <UnityEngine.Object>("ObjectiveQuests")) { Objective_Base temp = (ScriptableObject.CreateInstance(obj.name) as Objective_Base); //Quest In Progress if (questCompletionStates.ContainsKey(temp.QuestEnumeration) && questCompletionStates[temp.QuestEnumeration] == 1) { temp.QuestStage = questProgressStates[temp.QuestEnumeration]; AddNewObjective(temp); } //Quest Not Started else if (!questCompletionStates.ContainsKey(temp.QuestEnumeration)) { questProgressStates.Add(temp.QuestEnumeration, 0); questCompletionStates.Add(temp.QuestEnumeration, 0); } //Quest Completed else if (questCompletionStates.ContainsKey(temp.QuestEnumeration) && questCompletionStates[temp.QuestEnumeration] == 2) { Destroy(temp); temp = null; } } questsLoaded = true; } }
public void PlayProgressAnimation(Objective_Base referenceObjective) { transform.Find(referenceObjective.ObjectiveName).GetComponent <Animator>().Play("ProgressAnim"); }
public void RemoveObjective(Objective_Base referenceObjective) { transform.Find(referenceObjective.ObjectiveName).GetComponent <Animator>().Play("CompletedAnim"); activeObjectives.Remove(referenceObjective); Destroy(referenceObjective); }