예제 #1
0
    public void CloseRewardScreen()                       // creates function to handle closing of reward screen and application of rewards
    {
        for (int i = 0; i < leveledUp.Length; i++)        // iterates through all elements of leveledUp array
        {
            leveledUp[i]   = false;                       // resets each leveledUp element to false
            apLeveledUp[i] = false;                       // resets each apLeveledUp element to false
            GameMenu.instance.notificationText.text = ""; // resets game notification text
        }

        for (int i = 0; i < GameMenu.instance.activePartyList.Length; i++)                                        // iterates through active party list
        {
            if (GameMenu.instance.activePartyList[i] != "Empty")                                                  // checks if player in list is not empty
            {
                CharStats activePlayer = GameMenu.instance.FindPlayerStats(GameMenu.instance.activePartyList[i]); // pulls reference to active player stats

                if (activePlayer.currentHP > 0)                                                                   // checks if active party member is alive
                {
                    activePlayer.AddExp(xpEarned);                                                                // adds EXP to current player

                    if (activePlayer.leveledUp)                                                                   // checks if player leveled up
                    {
                        leveledUp[i] = true;                                                                      // sets leveledUp array element to true
                        //Debug.Log(activePlayer.charName + " leveled up!"); // prints level up notification to debug log

                        if (GameMenu.instance.notificationText.text.Length == 0)                               // checks if level up notification is empty
                        {
                            GameMenu.instance.notificationText.text += activePlayer.charName + " leveled up!"; // sets player level up notification without line break
                        }
                        else // executes if level up notification is not empty
                        {
                            GameMenu.instance.notificationText.text += "\n" + activePlayer.charName + " leveled up!"; // sets player level up notification with line break
                        }
                    }

                    activePlayer.AddAP(apEarned); // adds AP to current player

                    if (activePlayer.apLeveledUp) // checks if player ability leveled up
                    {
                        apLeveledUp[i] = true;    // sets apLeveledUp array element to true
                        //Debug.Log(activePlayer.charName + " learned new abilities!"); // prints ability level up notification to debug log

                        if (GameMenu.instance.notificationText.text.Length == 0)                                          // checks if level up notification is empty
                        {
                            GameMenu.instance.notificationText.text += activePlayer.charName + " learned new abilities!"; // sets player ability level up notification without line break
                        }
                        else // executes if level up notification is not empty
                        {
                            GameMenu.instance.notificationText.text += "\n" + activePlayer.charName + " learned new abilities!"; // sets player ability level up notification with line break
                        }
                    }
                }
            }
        }

        if (leveledUp[0] || leveledUp[1] || leveledUp[2] || apLeveledUp[0] || apLeveledUp[1] || apLeveledUp[2]) // checks if any characters leveled up (EXP or AP)
        {
            AudioManager.instance.PlaySFX(10);                                                                  // plays level up SFX

            //StartCoroutine(QuestManager.instance.ShowGameNotification(2)); // calls game notification coroutine to show notice for 2 seconds
            QuestManager.instance.ShowReward(); // calls function to show reward game notification
        }

        GameManager.instance.currentGold += rewardGold; // adds reward gold to inventory

        if (foundItems.Count != 0)
        {
            for (int i = 0; i < foundItems.Count; i++)       // iterates through array of found items
            {
                GameManager.instance.AddItem(foundItems[i]); // adds each item in found items array to inventory
            }
        }

        rewardScreen.SetActive(false); // hides reward screen
        GameManager.instance.battleActive = false;

        if (markQuestComplete)                                    // checks if mark quest complete flag is set
        {
            QuestManager.instance.MarkQuestComplete(questToMark); // calls mark quest complete function
        }
    }