Пример #1
0
    protected override void MakeMenuSelection(int menuIndex)
    {
        if (openedFromItemMenu)
        {
            ItemData itemToUse = Inventory.unsortedList[itemToUseUnsortedIndex];
            itemToUse.Effect(BattleManager.hpm.activePartyMembers[menuIndex]);
            bool hasItemStock = GameManager.gm.inventory.DecrementSupply(itemToUseUnsortedIndex);

            if (!hasItemStock)
            {
                CloseMenu();
                PauseMenu.itemMenu.OpenMenu();
            }
            PauseMenu.itemMenu.UpdateItemCounts(false, menuIndex);
        }
    }
Пример #2
0
    // What an attack does after the player has selected all his/her characters' moves and the move is used.
    // If turnList is empty, all turns are over and the player gets to select moves again (assuming the player is alive)
    public override IEnumerator UseAttack(BaseCharacter attacker, BaseCharacter target, List <Turn> turnList)
    {
        // THIS IS THE BASIC OUTLINE FOR A USEATTACK(...) IMPLEMENTATION.
        if (attacker)
        {
            target = CheckTargetAlive(attacker, target);

            if (target)
            {
                // The attack is used within this bracket

                // Calculates damage dealt. The final bool parameter is only true for attacks with a chance of critical hits.
                int damageDealt = CalcAttackDamage(this, target, attacker, false);
                Debug.Log("Attack activated: " + attackName);

                if (itemBeingUsed == null)
                {
                    itemBeingUsed = BattleManager.bManager.itemsToUse[0];
                    BattleManager.bManager.itemsToUse.RemoveAt(0);
                }
                Debug.Log(itemBeingUsed.itemName);

                // Displays appropriate battle message
                string battleMessage = string.Format("{0} uses {2} on {1}!",
                                                     attacker.characterName,
                                                     target.characterName,
                                                     itemBeingUsed.itemName);
                TextBoxManager.tbm.EnableTextBox(battleMessageWindow, battleMessage, false);

                // Gives time for the player to read the message
                while (TextBoxManager.tbm.isTyping)
                {
                    yield return(null);
                }
                yield return(new WaitForSeconds(.3f));

                itemBeingUsed.Effect(new BaseCharacter[] { target });

                battleMessage = string.Format("{0}'s HP was restored by 100!", attacker.characterName, target.characterName);
                TextBoxManager.tbm.EnableTextBox(battleMessageWindow, battleMessage, false);

                // Gives time for the player to read the message
                while (TextBoxManager.tbm.isTyping)
                {
                    yield return(null);
                }
                yield return(new WaitForSeconds(.3f));

                // If a hero was attacked, his/her HeroDisplayPanel is updated so the player can keep track of his/her HP.
                yield return(null);

                if (BattleManager.hpm.activePartyMembers.Contains(target))
                {
                    BattleManager.bManager.battleMenu.UpdatePanel(target);
                }
            }
            else
            {
                Debug.Log("Error!!!");
            }
        }

        // NO NEED TO EDIT CODE FROM HERE TO END OF METHOD
        EndTurnCheck(turnList);
    }
Пример #3
0
    protected override void MakeMenuSelection(int menuIndex)
    {
        if (openedFromItemMenu)
        {
            ItemData itemToUse = Inventory.unsortedList[itemToUseUnsortedIndex];

            if (itemToUse.itemType == ItemTypes.ITEM && itemToUse.usableOutsideBattle)
            {
                itemToUse.Effect(BattleManager.hpm.activePartyMembers[menuIndex]);
                bool hasItemStock = GameManager.gm.inventory.DecrementSupply(itemToUseUnsortedIndex);

                if (!hasItemStock)
                {
                    CloseMenu();
                    PauseMenu.itemMenu.OpenMenu();
                }
                PauseMenu.itemMenu.UpdateItemCounts(false, itemToUseUnsortedIndex);
            }
            else
            {
                Debug.Log("Can't use this item!");
            }
        }
        else if (openedFromEquipMenu)
        {
            ItemData itemToUse = Inventory.equipList[itemToUseUnsortedIndex];
            if (itemToUse.itemType == ItemTypes.EQUIPMENT)
            {
                EquipData newEquip = (EquipData)itemToUse;
                EquipData oldEquip;

                switch (newEquip.equipType)
                {
                case (EquipType.ARMOR):
                    // Remove old armor
                    oldEquip = BattleManager.hpm.activePartyMembers[menuIndex].armor;

                    // add old armor back into inventory
                    if (oldEquip != null)
                    {
                        GameManager.gm.inventory.AddToInventory(oldEquip);
                    }

                    // Equip new armor
                    BattleManager.hpm.activePartyMembers[menuIndex].armor
                        = (EquipData)itemToUse;

                    break;

                case (EquipType.WEAPON):
                    // Remove old weapon
                    oldEquip = BattleManager.hpm.activePartyMembers[menuIndex].weapon;

                    // add old weapon back into inventory
                    if (oldEquip != null)
                    {
                        GameManager.gm.inventory.AddToInventory(oldEquip);
                    }

                    // Equip new weapon
                    BattleManager.hpm.activePartyMembers[menuIndex].weapon
                        = (EquipData)itemToUse;

                    break;

                case (EquipType.HEADGEAR):
                    // Remove old headgear
                    oldEquip = BattleManager.hpm.activePartyMembers[menuIndex].headgear;

                    // add old headgear back into inventory
                    if (oldEquip != null)
                    {
                        GameManager.gm.inventory.AddToInventory(oldEquip);
                    }

                    // Equip new headgear
                    BattleManager.hpm.activePartyMembers[menuIndex].headgear
                        = (EquipData)itemToUse;

                    break;

                case (EquipType.ACCESSORY):
                    // Remove old accessory
                    oldEquip = BattleManager.hpm.activePartyMembers[menuIndex].accessory;

                    // add old accessory back into inventory
                    if (oldEquip != null)
                    {
                        GameManager.gm.inventory.AddToInventory(oldEquip);
                    }

                    // Equip new accessory
                    BattleManager.hpm.activePartyMembers[menuIndex].accessory
                        = (EquipData)itemToUse;

                    break;
                }

                // Subtract from inventory
                int hasItemStock = GameManager.gm.inventory.DecrementSupply(itemToUse);

                if (hasItemStock == 0)
                {
                    // no more of this item
                }
                PauseMenu.pauseMenu.equipMenu
                .UpdateItemCounts(true);

                CloseMenu();
                PauseMenu.pauseMenu.equipMenu.OpenMenu();
            }
            else
            {
                Debug.Log("Can't use this item!");
            }
        }
    }