/// <summary> /// function untuk memasukkan quest yang sudah selesai /// </summary> /// <param name="cqc"></param> public void AddCollectionQuestComplete(CollectionQuest cqc) { RemoveQuestList(cqc); collectionQuest.Remove(cqc); bool colQuestExist = false; //karena diperkirakan akan ada repeatable quest for (int k = 0; k < collectionQuestComplete.Count; k++) { //jika quest yang sudah selesai, sudah ada di dalam koleksi quest yang sudah selesai, tidak dimasukkan if (cqc.id == collectionQuestComplete[k].id) { colQuestExist = true; //Debug.Log("Collection Quest Complete Exist"); } } if (colQuestExist == false) { //jika quest yang sudah selesai, tidak ada di dalam koleksi quest yang sudah selesai, masukkan quest tersebut CollectionQuest newQuestCom = ScriptableObject.CreateInstance <CollectionQuest>(); newQuestCom.Duplicate(cqc); collectionQuestComplete.Add(newQuestCom); //AddCompleteQuestList(newQuestCom); Debug.Log("Collection Quest Complete : " + collectionQuestComplete.Count); } }
public void AddQuest(CollectionQuest cq) { CollectionQuest newQuest = ScriptableObject.CreateInstance <CollectionQuest>(); newQuest.Duplicate(cq); //add quest kedalam quest yang player miliki collectionQuest.Add(newQuest); //memasukkan quest list kedalam ui AddNewQuestToUI(newQuest); //mengecek status quest baru CheckNewQuestProgress(newQuest); }
/// <summary> /// lanjutan dari selectquestoption /// function untuk ngecheck quest yang dipilih /// </summary> /// <param name="dialogueQuest">quest yang dipilih</param> void CheckQuest(CollectionQuest dialogueQuest) { bool checkExist = false; for (int j = 0; j < PlayerData.instance.collectionQuest.Count; j++) { if (PlayerData.instance.collectionQuest[j].id == dialogueQuest.id) { checkExist = true; if (PlayerData.instance.collectionQuest[j].isComplete) { Debug.Log("Quest is complete"); SetQuestCompleteDialogue(dialogueQuest); PlayerData.instance.collectionQuest[j].QuestComplete(); Inventory.instance.RefreshInventory(); completedQuest = ScriptableObject.CreateInstance <CollectionQuest>(); completedQuest.Duplicate(PlayerData.instance.collectionQuest[j]); RemoveCompleteQuest(dialogueQuest); RemoveQuestFromNpc(dialogueQuest); PlayerData.instance.AddCollectionQuestComplete(PlayerData.instance.collectionQuest[j]); Quest.instance.ActivateQuest(); break; } else { SetQuestDialogue(dialogueQuest); } break; } else { Debug.Log("gada quest"); checkExist = false; } } if (!checkExist) { PlayerData.instance.AddQuest(dialogueQuest); SetQuestDialogue(dialogueQuest); } }
/// <summary> /// quest untuk mengaktifkan activecollectionquest ke npc agar bisa diambil oleh player /// dipanggil pada saat quest sudah selesai, sehingga muncul quest baru /// </summary> public void ActivateQuest() { npcAvailable = GameObject.FindGameObjectsWithTag("NPC"); for (int i = 0; i < npcAvailable.Length; i++) { npcAvailable[i].GetComponent <NPC>().activeCollectionQuest.Clear(); for (int j = 0; j < collectionQuestActive.Count; j++) { if (collectionQuestActive[j].sourceID == npcAvailable[i].GetComponent <NPC>().sourceID) { CollectionQuest cq = ScriptableObject.CreateInstance <CollectionQuest>(); cq.Duplicate(collectionQuestActive[j]); npcAvailable[i].GetComponent <NPC>().activeCollectionQuest.Add(cq); } } } for (int i = 0; i < npcAvailable.Length; i++) { npcAvailable[i].GetComponent <NPC>().activeCollectionQuestTotal = npcAvailable[i].GetComponent <NPC>().activeCollectionQuest.Count; } }