Ejemplo n.º 1
0
 public void AddToInventory(InventoryParty newCharacter)
 {
     if (!listOfPartyMembers.Contains(newCharacter))
     {
         listOfPartyMembers.Add(newCharacter);
     }
 }
Ejemplo n.º 2
0
        // Upon being enabled, this event will grant the player the specific object
        public override void EventOutcome()
        {
            if (itemToGive is ItemData)
            {
                // We add the new item to the player inventory.
                // Depending on the amount of said item, we will increment or decrement from the player's inventory.
                InventoryItem newItem = new InventoryItem((ItemData)itemToGive, quantity);
                if (Mathf.Sign(quantity) < 0)
                {
                    Debug.Log("Took away " + newItem.SpecifiedItem.itemName + " from player.");
                    playerInventory.RemoveItemFromInventory(newItem, quantity);
                }
                else
                {
                    Debug.Log("Gave player " + newItem.SpecifiedItem.itemName);
                    playerInventory.AddToInventory(newItem);
                }
                isFinished = true;
            }
            else if (itemToGive is GearData)
            {
                // We add the new gear to the inventory
                // Depending on the amount of said item, we will increment or decrement from the player's inventory.
                InventoryGear newGear = new InventoryGear((GearData)itemToGive, quantity);
                if (Mathf.Sign(quantity) < 0)
                {
                    Debug.Log("Took away " + newGear.SpecifiedGear.gearName + " from player.");
                    playerInventory.RemoveGearFromInventory(newGear, quantity);
                }
                else
                {
                    Debug.Log("Gave player " + newGear.SpecifiedGear.gearName);
                    playerInventory.AddToInventory(newGear);
                }
                isFinished = true;
            }
            else if (itemToGive is CharacterData)
            {
                // We add the new party member to the player's inventory
                InventoryParty newCharacter = new InventoryParty((CharacterData)itemToGive);
                Debug.Log("Added " + newCharacter.SpecifiedCharacter.characterName + " to party.");
                playerInventory.AddToInventory(newCharacter);
                isFinished = true;
            }
            else if (itemToGive is LinkData)
            {
                // We add the new link to the player's inventory
                InventoryLink newLink = new InventoryLink((LinkData)itemToGive);
                Debug.Log("Added " + newLink.SpecifiedLink.linkName + " to inventory.");
                playerInventory.AddToInventory(newLink);
                isFinished = true;
            }

            if (canResetItself == true)
            {
                Invoke("ResetEvent", 0.5f);
            }
        }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
        // This definition is used for players
        public void InitalizeEntity(InventoryParty partyMember)
        {
            modifierValuesForStats = partyMember.GetModifierValuesForStats;
            keyArray = new string[modifierValuesForStats.Keys.Count];
            modifierValuesForStats.Keys.CopyTo(keyArray, 0);

            currentHP = partyMember.CurrentHealthPoints;
            currentSP = partyMember.CurrentSkillPoints;
            maxHP     = ReturnModdedStat("MaxHP");
            maxSP     = ReturnModdedStat("MaxSP");
        }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        // A helper method that depending on what is passed in will determine what UI wil be updated
        public void SavePlayerStatsToUI(BattleStats currentPartyMember, InventoryParty currentPartyMemberStats, bool isOriginal)
        {
            // Displays the character that is levling up
            levelUpMenu.transform.GetChild(2).GetComponent <Image>().sprite = currentPartyMember.gameObject.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite;

            // If true, we are going to modify the slider value that represnts the original player stats
            if (isOriginal)
            {
                // The base player
                levelUpMenu.transform.GetChild(4).GetChild(0).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("MaxHP");
                levelUpMenu.transform.GetChild(4).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("MaxSP");
                levelUpMenu.transform.GetChild(4).GetChild(2).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("BaseAttack");
                levelUpMenu.transform.GetChild(4).GetChild(3).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("BaseDefense");

                // The Demon Stats
                levelUpMenu.transform.GetChild(5).GetChild(0).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("PhysicalAttack");
                levelUpMenu.transform.GetChild(5).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("PhysicalDefense");
                levelUpMenu.transform.GetChild(5).GetChild(2).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("SpecialAttack");
                levelUpMenu.transform.GetChild(5).GetChild(3).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("SpecialDefense");
                levelUpMenu.transform.GetChild(5).GetChild(4).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("Speed");
                levelUpMenu.transform.GetChild(5).GetChild(5).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("Luck");
            }
            else
            {
                // The base player
                levelUpMenu.transform.GetChild(4).GetChild(0).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("MaxHP");
                levelUpMenu.transform.GetChild(4).GetChild(1).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("MaxSP");
                levelUpMenu.transform.GetChild(4).GetChild(2).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("BaseAttack");
                levelUpMenu.transform.GetChild(4).GetChild(3).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("BaseDefense");

                // The Demon Stats
                levelUpMenu.transform.GetChild(5).GetChild(0).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("PhysicalAttack");
                levelUpMenu.transform.GetChild(5).GetChild(1).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("PhysicalDefense");
                levelUpMenu.transform.GetChild(5).GetChild(2).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("SpecialAttack");
                levelUpMenu.transform.GetChild(5).GetChild(3).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("SpecialDefense");
                levelUpMenu.transform.GetChild(5).GetChild(4).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("Speed");
                levelUpMenu.transform.GetChild(5).GetChild(5).GetChild(1).GetComponent <Slider>().value = currentPartyMember.ReturnModdedStat("Luck");
            }

            levelUpMenu.transform.GetChild(3).GetComponentInChildren <TextMeshProUGUI>().text = currentPartyMemberStats.SpecifiedCharacter.characterName + " leveled up! Now at level " + currentPartyMemberStats.CharacterLevel + "!";
        }
Ejemplo n.º 9
0
 // Using the passed in party member, we save the current HP/SP to the party member
 public void SaveCurrentHPSP(InventoryParty savedPartyMenber)
 {
     savedPartyMenber.CurrentHealthPoints = currentHP;
     savedPartyMenber.CurrentHealthPoints = currentSP;
 }