//When we need to add a quest to the Quest list, we do it here. public void AddQuest(int OverallID) { if (CurrentQuest == null) { //Sets a current quest if we don't have one. for (int i = 0; i < EQList.Count; i++) { if (EQList [i].OverallID == OverallID) { CurrentQuest = EQList [i]; CurrentQuest.CurrentQuest = true; if (OnQuestGet != null) { OnQuestGet (); } UpdateQuest (OverallID); Debug.Log(CurrentQuest.QuestName); return; } } } else { //Else just add the quest to the list/quest log. for (int i = 0; i < EQList.Count; i++) { if (EQList [i].OverallID == OverallID) { QuestList.Add (EQList [i]); return; } } } }
void Start() { //Grabbing our references player = GameObject.FindGameObjectWithTag ("Player"); _Manager = GameObject.FindGameObjectWithTag("EQManager").GetComponent<EasyQuestManager>(); text = GetComponentInChildren<TextMesh>(); //Quest Giver getting the quest needed for(int i = 0; i < _Manager.EQList.Count; i++){ if(_Manager.EQList[i].QuestID == QuestID && _Manager.EQList[i].ProgressionID == ProgressID){ Quest = _Manager.EQList[i]; OverallID = Quest.OverallID; return; } } }
//Checks list to set our next current quest public void CheckList() { //Check that we don't have a current quest. if (CurrentQuest == null) { if(QuestList.Count == 0){ //First, check if a quest was already the current and we forgot to set it //when we loaded our save. for (int i = 0; i < EQList.Count; i++) { if (EQList [i].CurrentQuest == true) { AddQuest(EQList[i].OverallID); return; } } }else{ //Else, set the current one to the first one in the list. int temp = -1; for (int q = 0; q < QuestSaver.qSaver.QuestOverallID.Count; q++) { if (QuestSaver.qSaver.QuestOverallID [q] == QuestList [0].OverallID) { temp = q; break; } } if (temp == -1) { return; } CurrentQuest = QuestList[0]; CurrentQuest.CurrentQuest = true; QuestSaver.qSaver.CurrentQuest[temp] = true; } } }
//Once a quest finishes, it runs this. public void QuestFinish(int OverallID) { //Checking what index the quest is at, since we can't keep track of it normally in a List :( int temp = -1; for(int q = 0; q < QuestSaver.qSaver.QuestOverallID.Count; q++) { if(QuestSaver.qSaver.QuestOverallID[q] == OverallID) { temp = q; break; } } if(temp == -1) { return; } //Finish //Once a quest is finished, add it to the finished quest list and remove it from the current quest list. QuestSaver.qSaver.FinishedQuest [temp] = true; QuestSaver.qSaver.CurrentQuest [temp] = false; CurrentQuest = null; if (OnQuestFinish != null) { OnQuestFinish (); } CheckList (); //Save. for (int i = 0; i < EQList.Count; i++) { UpdateQuest (EQList[i].OverallID); } }
public override void OnInspectorGUI() { EQ = target as EasyQuest; EditorStyles.textField.wordWrap = true; //Quest Name GUILayout.BeginHorizontal (); GUILayout.Label("Quest Name: ", GUILayout.Width(85)); EQ.QuestName = EditorGUILayout.TextField (EQ.QuestName, GUILayout.Width(225)); GUILayout.EndHorizontal (); //Quest ID GUILayout.BeginHorizontal (); GUILayout.Label("Overall ID: ", GUILayout.Width(85)); EQ.OverallID = int.Parse(GUILayout.TextField (EQ.OverallID.ToString(), GUILayout.Width(125))); GUILayout.EndHorizontal (); //Progression ID GUILayout.BeginHorizontal (); GUILayout.Label("Progress ID: ", GUILayout.Width(85)); EQ.ProgressionID = int.Parse(GUILayout.TextField (EQ.ProgressionID.ToString(), GUILayout.Width(125))); GUILayout.EndHorizontal (); //Quest ID GUILayout.BeginHorizontal (); GUILayout.Label("Quest ID: ", GUILayout.Width(85)); EQ.QuestID = int.Parse(GUILayout.TextField (EQ.QuestID.ToString(), GUILayout.Width(125))); GUILayout.EndHorizontal (); //Quest Description GUILayout.BeginVertical (); GUILayout.Label("Quest Description: ", GUILayout.Width(125)); EQ.Description = EditorGUILayout.TextField (EQ.Description, GUILayout.Height(80)); GUILayout.EndVertical (); //Complete Quest GUILayout.BeginVertical (); GUILayout.Label("Complete Quest Message: ", GUILayout.Width(175)); EQ.CompleteQ = EditorGUILayout.TextField (EQ.CompleteQ, GUILayout.Height(20)); GUILayout.EndVertical (); //Player(s) GUILayout.BeginHorizontal (); GUILayout.Label("Player Tag: ", GUILayout.Width(85)); EQ.PlayerT = EditorGUILayout.TextField (EQ.PlayerT, GUILayout.Width(125)); GUILayout.EndHorizontal (); //Exp GUILayout.BeginHorizontal(); GUILayout.Label("Exp to Give: ", GUILayout.Width(85)); EQ.expToGive = int.Parse(GUILayout.TextField(EQ.expToGive.ToString(), GUILayout.Width(125))); GUILayout.EndHorizontal(); //Add/Remove Objectives GUILayout.BeginHorizontal(); if (GUILayout.Button ("Add Objective")) { EQ.AmountOfO += 1; } if (GUILayout.Button ("Remove Objective")) { EQ.AmountOfO -= 1; } GUILayout.EndHorizontal(); if(EQ.Objs.Count < EQ.AmountOfO){ EQ.Objs.Add(new ObjectiveT()); } for(int i = 0; i < EQ.AmountOfO; i++){ //Quest type GUILayout.BeginHorizontal (); GUILayout.Label("Quest Type: ", GUILayout.Width(85)); EQ.Objs[i].qType = (QuestType)EditorGUILayout.EnumPopup(EQ.Objs[i].qType); GUILayout.EndHorizontal (); //World Name GUILayout.BeginHorizontal(); GUILayout.Label("World: "); EQ.Objs[i].World = EditorGUILayout.TextField(EQ.Objs[i].World); GUILayout.EndHorizontal(); //Short Description GUILayout.BeginHorizontal(); GUILayout.Label("Short Summary: ", GUILayout.Width(100)); EQ.Objs[i].sDescript = EditorGUILayout.TextField(EQ.Objs[i].sDescript); GUILayout.EndHorizontal(); GUILayout.Space(2); ShowQuestOpt (i); GUILayout.Space(14); } }