Exemplo n.º 1
0
    //Gives the reward for completing a quest
    public void GiveItem()
    {
        //Gives a weapon
        if (currentQuest.giveWeapon == true)
        {
            GameObject      questDrop        = Instantiate(Resources.Load("Loot Drop"), player.transform.position, Quaternion.identity) as GameObject;
            LootDropMonitor questDropMonitor = questDrop.GetComponent <LootDropMonitor>();

            questDropMonitor.type      = 0;
            questDropMonitor.itemStats = LootManager.GenerateSpecificWeapon(currentQuest.weaponType, currentQuest.weaponValue);
        }
        //Give an Item
        if (currentQuest.giveItem == true)
        {
            GameObject      questDrop        = Instantiate(Resources.Load("Loot Drop"), player.transform.position, Quaternion.identity) as GameObject;
            LootDropMonitor questDropMonitor = questDrop.GetComponent <LootDropMonitor>();

            questDropMonitor.type = 2;
            questDropMonitor.item = currentQuest.itemName;
        }
        //Gives Xp for quest
        PersistantGameManager.Instance.playerStats.playerExperience += currentQuest.questExperience;
        //Removes item from inventory
        if (!currentQuest.instantComplete && currentQuest.returnItem)
        {
            PersistantGameManager.Instance.itemInventory[currentQuest.questItemName]--;
        }
        //Tells PGM to move onto the next quest
        PersistantGameManager.Instance.characterQuests[nameOfNpc]++;

        //Removes quest from PGM
        PersistantGameManager.Instance.activeQuests.Remove(currentQuest.questKey);
        PersistantGameManager.Instance.possibleQuests.Remove(currentQuest.questKey);
        PersistantGameManager.Instance.completedQuests.Add(currentQuest.questKey);

        //Tells player they have completed the quest
        TextMeshProUGUI text = GameObject.FindGameObjectWithTag("Updates").GetComponent <TextMeshProUGUI>();

        if (!currentQuest.instantComplete)
        {
            text.text = "Completed " + currentQuest.questName;
        }

        hasTalkedBefore = false;
        currentQuest    = null;
        EndDialogue();

        //If instant complete then loop to next dialogue
        if (mGiveItem)
        {
            StartCoroutine(CreateDialogueBox());
            mGiveItem = false;
        }
    }