public sealed override void OnActionStarted()
        {
            base.OnActionStarted();

            //Subtract Star Power if the Special Move costs SP (Focus, Star Beam, and Peach Beam are Special Moves that doesn't cost SP)
            //The BattleEntity must have SP, and enough of it, at this point, as the action is not selectable from the menu otherwise
            if (CostsSP == true)
            {
                //Subtract Star Power
                MarioStats    marioStats = User.BattleStats as MarioStats;
                StarPowerBase starPower  = marioStats.GetStarPowerFromType(SPType);
                starPower.LoseStarPower(SPCost);
            }
        }
示例#2
0
        protected override void SequenceMainBranch()
        {
            switch (SequenceStep)
            {
            case 0:
                if (User.EntityType == Enumerations.EntityTypes.Player)
                {
                    //Increase Star Spirit Star Power
                    BattlePlayer  player    = (BattlePlayer)User;
                    StarPowerBase starPower = player.GetStarPower(StarPowerGlobals.StarPowerTypes.StarSpirit);
                    if (starPower == null)
                    {
                        Debug.LogError($"Somehow, {nameof(starPower)} is null from {nameof(BattlePlayer.GetStarPower)}. Fix this.");
                    }
                    else
                    {
                        //Base gain from Focus
                        float spuGained = StarPowerGlobals.FocusSPUGain;

                        //Check how many Deep Focus badges are equipped
                        int deepFocusEquipped = User.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.DeepFocus);

                        //Add the gain from each Deep Focus badge onto the total gain
                        spuGained += (deepFocusEquipped * StarPowerGlobals.DeepFocusSPUIncrease);

                        //Give Star Power
                        starPower.GainStarPower(spuGained);
                    }
                }
                else
                {
                    Debug.LogWarning($"{User.Name} is not a {nameof(BattlePlayer)} and has no Star Power reference to increase.");
                }

                ChangeSequenceBranch(SequenceBranch.End);
                break;

            default:
                PrintInvalidSequence();
                break;
            }
        }
        /// <summary>
        /// What happens when the MoveAction starts.
        /// This is called immediately before starting the Sequence.
        /// </summary>
        public virtual void OnActionStarted()
        {
            //Subtract FP if the move costs FP. The BattleEntity must have enough FP
            //at this point, as the action is not selectable from the menu if it doesn't have enough
            if (CostsFP == true)
            {
                User.LoseFP((int)MoveProperties.ResourceCost);
            }

            //Subtract SP if the move costs SP. The BattleEntity must have enough SP at this point since the move can't be selected otherwise
            if (CostsSP == true)
            {
                MarioStats mStats = User.BattleStats as MarioStats;
                if (mStats != null)
                {
                    StarPowerBase starPower = null;

                    if (MoveProperties.ResourceType == MoveResourceTypes.SSSP)
                    {
                        starPower = mStats.GetStarPowerFromType(StarPowerGlobals.StarPowerTypes.StarSpirit);
                    }
                    else if (MoveProperties.ResourceType == MoveResourceTypes.CSSP)
                    {
                        starPower = mStats.GetStarPowerFromType(StarPowerGlobals.StarPowerTypes.CrystalStar);
                    }

                    //Decrease SP
                    if (starPower != null)
                    {
                        starPower.LoseStarPower(MoveProperties.ResourceCost);
                    }
                }
            }

            //If it's not an item move, remove the dip item turns property
            //This ensures that no item turns remain if the entity was using Double/Triple Dip but did something else via Confusion
            if (User.EntityProperties.HasAdditionalProperty(AdditionalProperty.DipItemTurns) == true)
            {
                User.EntityProperties.RemoveAdditionalProperty(AdditionalProperty.DipItemTurns);
            }
        }
        /// <summary>
        /// Initializes the MoveAction, checking if it should be disabled or not based on certain conditions.
        /// <para>Common conditions include not having enough FP to perform the move and not being able to reach any BattleEntities with this move.</para>
        /// </summary>
        public virtual void Initialize()
        {
            InitActionCommandSequenceSettings();

            /*Check if the MoveAction should be disabled or not
             * 1. Check the FP cost, if it costs FP
             * 2. Check if the move can hit any BattleEntities it targets
             */

            if (CostsFP == true)
            {
                //Check for the number of Flower Saver Badges on the entity and reduce the FP cost by that amount; minimum of 1
                int flowerSaverCount = User.GetEquippedNPBadgeCount(BadgeGlobals.BadgeTypes.FlowerSaver);
                MoveInfo.ResourceCost = UtilityGlobals.Clamp(MoveInfo.ResourceCost - flowerSaverCount, 1, 99);

                //If there is at least one Flower Saver Badge equipped, display the FP count in a bluish-gray color
                if (flowerSaverCount > 0 && MoveInfo.CostDisplayType != CostDisplayTypes.Hidden)
                {
                    MoveInfo.CostDisplayType = CostDisplayTypes.Special;
                }

                //Disable the move if you don't have enough FP to use it
                if (MoveProperties.ResourceCost > User.CurFP)
                {
                    Disabled       = true;
                    DisabledString = "Not enough FP.";
                    return;
                }
            }
            else if (CostsSP == true)
            {
                MarioStats mStats = User.BattleStats as MarioStats;
                if (mStats == null)
                {
                    Disabled       = true;
                    DisabledString = "No Star Power available to use!";
                    return;
                }

                StarPowerBase starPower = null;

                if (MoveProperties.ResourceType == MoveResourceTypes.SSSP)
                {
                    starPower = mStats.GetStarPowerFromType(StarPowerGlobals.StarPowerTypes.StarSpirit);
                }
                else if (MoveProperties.ResourceType == MoveResourceTypes.CSSP)
                {
                    starPower = mStats.GetStarPowerFromType(StarPowerGlobals.StarPowerTypes.CrystalStar);
                }

                if (starPower == null)
                {
                    Disabled       = true;
                    DisabledString = "No Star Power available to use!";
                    return;
                }

                //Disable the move if you don't have enough SP to use it
                if (starPower.CanUseStarPower(MoveProperties.ResourceCost) == false)
                {
                    Disabled       = true;
                    DisabledString = "Not enough SP.";
                    return;
                }
            }

            //If the move targets entities, check if any entities can be targeted
            if (MoveProperties.MoveAffectionType != MoveAffectionTypes.None)
            {
                List <BattleEntity> entities = new List <BattleEntity>();
                GetEntitiesMoveAffects(entities);

                //There are no entities this move can target
                if (entities.Count == 0)
                {
                    Disabled       = true;
                    DisabledString = "There's no one this move can target!";
                    return;
                }
            }
        }