예제 #1
0
        // Spawns the party into battle.
        private void SpawnParty()
        {
            PlayerInventory playerInventory = GameManager.Instance.PlayerReference.GetComponent <PlayerInventory>();

            listOfAllParty = new List <BattleStats>();

            int currLocationIndex = 0;

            for (int currIndex = 0; currIndex < playerInventory.GetPartyInvetorySize(); ++currIndex)
            {
                BattleStats partyMember = Instantiate(characterPrefab, partySpawnLocations[currLocationIndex].position, Quaternion.identity).GetComponent <BattleStats>();
                partyMember.battleData = playerInventory.GetInventoryCharacterAtIndex(currIndex).SpecifiedCharacter;
                partyMember.InitalizeEntity(playerInventory.GetInventoryCharacterAtIndex(currIndex));

                listOfAllParty.Add(partyMember);
                currLocationIndex++;
            }
        }
예제 #2
0
 // Goes through the entire party and damages them by the specified amount
 public override void EventOutcome()
 {
     for (int i = 0; i < playerInventory.GetPartyInvetorySize(); i++)
     {
         InventoryParty currMember = playerInventory.GetInventoryCharacterAtIndex(i);
         currMember.CurrentHealthPoints -= subtractor;
         Debug.Log(currMember.SpecifiedCharacter.characterName + " took " + subtractor + " damage!");
     }
     isFinished = true;
 }
예제 #3
0
 // Goes through the entire party and heals them to the max
 public override void EventOutcome()
 {
     for (int i = 0; i < playerInventory.GetPartyInvetorySize(); i++)
     {
         InventoryParty currMember = playerInventory.GetInventoryCharacterAtIndex(i);
         currMember.CurrentHealthPoints = currMember.ReturnModdedStat("MaxHP");
         currMember.CurrentSkillPoints  = currMember.ReturnModdedStat("MaxSP");
         Debug.Log(currMember.SpecifiedCharacter.characterName + " healed to the max!");
     }
     GameManager.Instance.CurrentState = GameStates.NORMAL;
     isFinished = true;
 }
예제 #4
0
        // This handles EXP/Gold and level up logics after a battle has won
        private IEnumerator PostWinActions()
        {
            // We first display our rewards to the player
            battleUIController.ToggleActionBox(true, "Won " + currentBattleEvent.ExpReward + " EXP and " + currentBattleEvent.GoldReward + " Gold!");
            yield return(new WaitForSeconds(3f));

            PlayerInventory currentParty = GameManager.Instance.PlayerReference.GetComponent <PlayerInventory>();

            foreach (BattleStats currentPartyMember in listOfAllParty)
            {
                CharacterData comparedPartyMember = (CharacterData)currentPartyMember.battleData;
                for (int currPartyIndex = 0; currPartyIndex < currentParty.GetPartyInvetorySize(); currPartyIndex++)
                {
                    // We check if we are looking at the same character
                    InventoryParty currPartyMemberStats = currentParty.GetInventoryCharacterAtIndex(currPartyIndex);
                    if (comparedPartyMember.characterName == currPartyMemberStats.SpecifiedCharacter.characterName)
                    {
                        // We save the HP/SP that the character has to the inventory
                        currentPartyMember.SaveCurrentHPSP(currPartyMemberStats);

                        // We also reward the entity with EXP
                        currPartyMemberStats.CurrentEXP         += currentBattleEvent.ExpReward;
                        currPartyMemberStats.CurrentToNextLevel -= currentBattleEvent.ExpReward;

                        // If we are above a threshold for EXP, we level up
                        while (currPartyMemberStats.CurrentToNextLevel <= 0)
                        {
                            battleUIController.CurrentState = BattleMenuStates.LEVEL_UP;
                            battleUIController.SavePlayerStatsToUI(currentPartyMember, currPartyMemberStats, true);

                            currPartyMemberStats.CharacterLevel++;
                            currentPartyMember.LevelUpStats();
                            currPartyMemberStats.CurrentToNextLevel += (currPartyMemberStats.CharacterLevel * 100);

                            battleUIController.SavePlayerStatsToUI(currentPartyMember, currPartyMemberStats, false);
                            while (battleUIController.CurrentState == BattleMenuStates.LEVEL_UP)
                            {
                                yield return(null);
                            }
                            yield return(null);
                        }
                    }
                }
            }

            // We also reward the player with gold after the fight
            currentParty.CurrentGold += currentBattleEvent.GoldReward;

            // After we finish everything, we end the event
            currentState = BattleStates.PLAYER_WIN;
            currentBattleEvent.EventOutcome();
        }
예제 #5
0
        // Depending on what menu we are in, we update what is currently displayed after we scroll on something
        private void UpdateMenuContext()
        {
            switch (currentState)
            {
            case MenuStates.ITEM:
                // We update the item description
                if (currentSubMenuState == SubMenuStates.HIDDEN)
                {
                    if (currentMenuIndex < playerInventory.GetItemInventorySize())
                    {
                        itemMenuObject.transform.GetChild(2).GetComponentInChildren <TextMeshProUGUI>().text = playerInventory.GetItemAtIndex(currentMenuIndex).SpecifiedItem.itemDescription;
                    }
                }
                else if (currentSubMenuState == SubMenuStates.SUB1)
                {
                    InventoryParty currParty = playerInventory.GetInventoryCharacterAtIndex(currentMenuIndex);
                    itemMenuObject.transform.GetChild(2).GetComponentInChildren <TextMeshProUGUI>().text = "Select a target to use this on.";
                    itemMenuObject.transform.GetChild(3).GetComponentInChildren <TextMeshProUGUI>().text = "HP: " + currParty.CurrentHealthPoints + "/" + currParty.ReturnModdedStat("MaxHP") +
                                                                                                           "\nSP: " + currParty.CurrentSkillPoints + "/" + currParty.ReturnModdedStat("MaxSP");
                }
                break;

            case MenuStates.PARTY:
                // We update the party description
                if (currentMenuIndex < playerInventory.GetPartyInvetorySize())
                {
                    partyMenuObject.transform.GetChild(1).GetComponentInChildren <TextMeshProUGUI>().text = playerInventory.GetInventoryCharacterAtIndex(currentMenuIndex).SpecifiedCharacter.characterName;
                }
                break;

            case MenuStates.GEAR:
                // We update the gear description
                if (currentMenuIndex < playerInventory.GetGearInventorySize())
                {
                    gearMenuObject.transform.GetChild(1).GetComponentInChildren <TextMeshProUGUI>().text = playerInventory.GetGearAtIndex(currentMenuIndex).SpecifiedGear.gearDescription;
                }
                break;

            case MenuStates.LINK:
                // We update the link description
                if (currentMenuIndex < playerInventory.GetLinkInventorySize())
                {
                    linkMenuObject.transform.GetChild(1).GetComponentInChildren <TextMeshProUGUI>().text = playerInventory.GetLinkAtIndex(currentMenuIndex).SpecifiedLink.linkDescription;
                }
                break;
            }
        }