コード例 #1
0
        public void HealHP(int hp)
        {
            BattleStats.HP = UtilityGlobals.Clamp(BattleStats.HP + hp, 0, BattleStats.MaxHP);

            UpdateHealthState();
            Debug.Log($"{Name} healed {hp} HP!");
        }
コード例 #2
0
        /// <summary>
        /// Gets the origin of a Texture2D by ratio instead of specifying width and height
        /// </summary>
        /// <param name="texture2D">The texture to get the origin for</param>
        /// <param name="x">The X ratio of the origin, between 0 and 1</param>
        /// <param name="y">The Y ratio of the origin, between 0 and 1</param>
        /// <returns>A Vector2 with the origin</returns>
        public static Vector2 GetOrigin(this Texture2D texture2D, float x, float y)
        {
            int xVal = (int)(texture2D.Width * UtilityGlobals.Clamp(x, 0f, 1f));
            int yVal = (int)(texture2D.Height * UtilityGlobals.Clamp(y, 0f, 1f));

            return(new Vector2(xVal, yVal));
        }
コード例 #3
0
        protected override void OnStart()
        {
            base.OnStart();

            //In PM, if you're inflicted with Stone, then the Action Command doesn't come up
            //and the number of attacks is halved, rounding down

            //Check if the target is immobile
            if (EntitiesAffected[0].IsImmobile() == true)
            {
                //Disable the action command
                Action.EnableActionCommand = false;

                //Divide the number of attacks by two, clamping at one
                //We clamp because if the Action Command is disabled, an infinite attack would softlock
                //In addition, as the target is immobile, it's not able to Superguard to damage the attacker and end the move
                MaxAttacks = UtilityGlobals.Clamp(MaxAttacks / 2, 1, MaxAttacks);
                NumAttacks = MaxAttacks;

                //Log a message here to indicate it's intentional
                Debug.Log($"{EntitiesAffected[0].Name} is Immobile; ActionCommand disabled and MaxAttacks halved to {MaxAttacks}. This is PM behavior");
            }

            if (Action.CommandEnabled == true && Action.DrawActionCommandInfo == true)
            {
                KissyKissyUI = new FillBarActionCommandUI <MashButtonCommand>(actionCommand as MashButtonCommand, new Vector2(250, 150), new Vector2(100f, 1f), null);
                User.BManager.battleUIManager.AddUIElement(KissyKissyUI);
            }
        }
コード例 #4
0
        protected override void CommandSuccess()
        {
            base.CommandSuccess();

            Bounces++;
            SentRank = (ActionCommand.CommandRank)UtilityGlobals.Clamp((int)HighestCommandRank + 1, (int)ActionCommand.CommandRank.NiceM2, (int)ActionCommand.CommandRank.Excellent);
        }
コード例 #5
0
        //NOTE: For some moves, these only show up when you hit (Ex. Jump, Hammer, Power Shell).
        //Other moves show them as you perform the command, even if they deal damage (Ex. Mini-Egg, Earth Tremor).
        //Find a way to define when to show them in each move
        public void OnCommandRankResult(ActionCommand.CommandRank commandRank)
        {
            //Don't bother if the CommandRank is nothing
            if (commandRank == ActionCommand.CommandRank.None)
            {
                return;
            }

            //Get how many Simplifiers and Unsimplifiers the entity has equipped
            int simplifierCount   = UtilityGlobals.Clamp(User.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.Simplifier), 0, BadgeGlobals.MaxSimplifierCount);
            int unsimplifierCount = UtilityGlobals.Clamp(User.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.Unsimplifier), 0, BadgeGlobals.MaxUnsimplifierCount);

            int rankInt = (int)commandRank;

            //Subtract Simplifier count and add Unsimplifier count to the final rank
            rankInt -= simplifierCount;
            rankInt += unsimplifierCount;

            //Clamp the rank to the final values
            rankInt = UtilityGlobals.Clamp(rankInt, (int)ActionCommand.CommandRank.NiceM2, (int)ActionCommand.CommandRank.Excellent);

            ActionCommand.CommandRank finalRank = (ActionCommand.CommandRank)rankInt;

            //Update the highest command rank
            if (finalRank > HighestCommandRank)
            {
                HighestCommandRank = finalRank;
            }
        }
コード例 #6
0
        /// <summary>
        /// Gets the origin of a Rectangle
        /// </summary>
        /// <param name="rectangle">The Rectangle to get the origin for</param>
        /// <param name="x">The X ratio of the origin, from 0 to 1</param>
        /// <param name="y">The Y ratio of the origin, from 0 to 1</param>
        /// <returns>A Vector2 with the origin</returns>
        public static Vector2 GetOrigin(this Rectangle rectangle, float x, float y)
        {
            int xVal = (int)(rectangle.Width * UtilityGlobals.Clamp(x, 0f, 1f));
            int yVal = (int)(rectangle.Height * UtilityGlobals.Clamp(y, 0f, 1f));

            return(new Vector2(xVal, yVal));
        }
コード例 #7
0
        public override void Update()
        {
            if (CurStarState == StarState.Expanding)
            {
                CurScale.X = UtilityGlobals.Clamp(CurScale.X + ScaleRate, 0f, MaxScale.X);
                CurScale.Y = UtilityGlobals.Clamp(CurScale.Y + ScaleRate, 0f, MaxScale.Y);

                if (CurScale == MaxScale)
                {
                    CurStarState = StarState.Waiting;
                }
            }
            else if (CurStarState == StarState.Waiting)
            {
                //Increment time and check if it should start shrinking
                ElapsedTime += Time.ElapsedMilliseconds;
                if (ElapsedTime >= DisplayTime)
                {
                    CurStarState = StarState.Shrinking;
                }
            }
            else
            {
                //Shrink the star
                CurScale.X = UtilityGlobals.Clamp(CurScale.X - ScaleRate, 0f, MaxScale.X);
                CurScale.Y = UtilityGlobals.Clamp(CurScale.Y - ScaleRate, 0f, MaxScale.Y);

                if (CurScale == Vector2.Zero)
                {
                    ReadyForRemoval = true;
                }
            }
        }
コード例 #8
0
        private void DrawBigCursor(float rotation)
        {
            Vector2 bigOrigin = new Vector2((float)BigCursor.SourceRect.Value.Width, (float)BigCursor.SourceRect.Value.Height);

            //origins are offset instead of position so each piece rotates from the center of the overall big circle they create
            //May need adjusting
            SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, bigOrigin, 1f, false, false, .2f, true);
            SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, new Vector2(-bigOrigin.X, bigOrigin.Y), 1f, true, false, .2f, true);
            SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, new Vector2(bigOrigin.X, 0), 1f, false, true, .2f, true);
            SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, -bigOrigin, 1f, true, true, .2f, true);

            //Draw the middle cursor indicating the small cursor is near
            //It gets smaller the closer the small cursor is to the center
            if (WithinRange == true)
            {
                //Cap the scale so it can be seen clearly at all times
                const float maxScale = .8f;

                //Get the absolute value of the distance from the cursor to the center
                //Divide by half the SuccessRect's width since we're scaling based on how close it is to the center
                float diff  = Math.Abs(SmallCursorPos.X - SuccessRect.Center.X) / (SuccessRect.Width / 2f);
                float scale = UtilityGlobals.Clamp(diff, 0f, maxScale);

                //Draw the middle cursor
                SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, bigOrigin, scale, false, false, .2f, true);
                SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, new Vector2(-bigOrigin.X, bigOrigin.Y), scale, true, false, .2f, true);
                SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, new Vector2(bigOrigin.X, 0), scale, false, true, .2f, true);
                SpriteRenderer.Instance.Draw(BigCursor.Tex, BigCursorPos, BigCursor.SourceRect, Color.White, rotation, -bigOrigin, scale, true, true, .2f, true);
            }
        }
コード例 #9
0
        protected void FillBar(double amount, bool clamp)
        {
            CurBarValue += amount;

            //Clamp the bar
            if (clamp == true)
            {
                CurBarValue = UtilityGlobals.Clamp(CurBarValue, 0d, MaxBarValue);
            }
        }
コード例 #10
0
        protected void UpdateCursor()
        {
            CursorAngle = UtilityGlobals.Clamp(CursorAngle + CursorMoveSpeed, MinCursorAngle, MaxCursorAngle);

            //If it reached its limits, reverse the angle
            if (CursorAngle >= MaxCursorAngle || CursorAngle <= MinCursorAngle)
            {
                CursorMoveSpeed = -CursorMoveSpeed;
            }
        }
コード例 #11
0
        /// <summary>
        /// Calculates the amount of Star Power the Audience gives Mario after either he or his Partner use Appeal.
        /// </summary>
        /// <param name="activeAudienceMembers">The number of active Audience members.</param>
        /// <param name="superAppealCount">The number of Super Appeal or Super Appeal P Badges equipped, depending on who's using Appeal.</param>
        /// <returns>The total amount of Star Power gained from using Appeal.</returns>
        public float CalculateAppealStarPower(int activeAudienceMembers, int superAppealCount)
        {
            int appealValue      = 25 * (superAppealCount + 1);
            int audienceOverFour = activeAudienceMembers / 4;

            //Cap the amount of SPU you can gain to be your max SPU
            float totalSPUGained = UtilityGlobals.Clamp(appealValue + audienceOverFour, 0f, MaxSPU);

            return(totalSPUGained);
        }
コード例 #12
0
        /// <summary>
        /// Calculates the amount of Star Power the Audience give Mario after either he or his Partner attacks.
        /// </summary>
        /// <param name="audienceValue">The total value of the Audience.</param>
        /// <param name="commandRankValue">The CommandRank value earned during the attack. This should also factor whether a Stylish move was performed or not.</param>
        /// <param name="dangerStatus">The Danger status value.</param>
        /// <param name="BINGOStatus">The value of the current BINGO! status. 0 for Poison Shrooms, 2 for Mushrooms, Flowers, and Stars, and 3 for Shine Sprites.</param>
        /// <returns>The total amount of Star Power gained from the attack.</returns>
        public float CalculateStarPowerFromAudience(int audienceValue, float commandRankValue, float dangerStatus, float BINGOStatus)
        {
            float audienceSquared = (float)Math.Sqrt((double)audienceValue);

            float value = audienceSquared * commandRankValue * dangerStatus * BINGOStatus;

            //Cap the amount of SPU you can gain to be your max SPU
            float totalSPUGained = UtilityGlobals.Clamp((float)Math.Floor(value), 0f, MaxSPU);

            return(totalSPUGained);
        }
コード例 #13
0
        public override void Refresh(StatusEffect newStatus)
        {
            ChargedStatus charged = (ChargedStatus)newStatus;

            TotalChargeDamage += charged.TotalChargeDamage;

            //Charge damage is capped at the max damage that can be dealt
            TotalChargeDamage = UtilityGlobals.Clamp(TotalChargeDamage, BattleGlobals.MinDamage, BattleGlobals.MaxDamage);

            EntityAfflicted.EntityProperties.AddAdditionalProperty(Enumerations.AdditionalProperty.ChargedDamage, TotalChargeDamage);
        }
コード例 #14
0
        protected override void SequenceSuccessBranch()
        {
            switch (SequenceStep)
            {
            case 0:
                base.SequenceSuccessBranch();
                break;

            case 1:

                //Check the damage dealt
                InteractionResult[] interactions = AttemptDamage(DamageDealt, EntitiesAffected, Action.DamageProperties, true);

                int damage = 0;
                if (interactions[0] != null)
                {
                    damage = interactions[0].VictimResult.TotalDamage;
                }

                //Show VFX for the highest command rank
                if (interactions[0] != null && interactions[0].WasVictimHit == true && interactions[0].WasAttackerHit == false)
                {
                    ShowCommandRankVFX(HighestCommandRank, CurTarget.Position);
                }

                //If the total damage dealt was 1, stop decreasing the damage to keep it doing 1
                if (StopDecreasing == false && damage == 1)
                {
                    StopDecreasing = true;
                }

                //Only decrease the value if we're not at 1 damage
                if (StopDecreasing == false)
                {
                    DamageValue = UtilityGlobals.Clamp(DamageValue - 1, BattleGlobals.MinDamage, BattleGlobals.MaxDamage);
                }

                //Repeat the sequence if the player is under the Power Bounce cap
                if (Bounces < BattleGlobals.MaxPowerBounces)
                {
                    ChangeSequenceBranch(SequenceBranch.Main);
                }
                else
                {
                    Debug.Log($"Reached Power Bounce limit with {Bounces} and real max is {BattleGlobals.MaxPowerBounces}!");
                    ChangeSequenceBranch(SequenceBranch.End);
                }
                break;

            default:
                PrintInvalidSequence();
                break;
            }
        }
コード例 #15
0
        public void LoseHP(int hp)
        {
            BattleStats.HP = UtilityGlobals.Clamp(BattleStats.HP - hp, 0, BattleStats.MaxHP);
            UpdateHealthState();

            if (IsDead == true)
            {
                Die();
            }

            Debug.Log($"{Name} took {hp} points of damage!");
        }
コード例 #16
0
        /// <summary>
        /// Increases the current number of Star Power units Mario has.
        /// </summary>
        /// <param name="spuGained">The number of Star Power units to add. If negative, this value will be changed to positive.</param>
        public void GainStarPower(float spuGained)
        {
            if (spuGained <= 0)
            {
                Debug.LogError($"{nameof(spuGained)} is less than or equal to 0, which should never happen. Changing to positive");
                spuGained = -spuGained;
            }

            SPU = UtilityGlobals.Clamp(SPU + spuGained, 0f, MaxSPU);

            Debug.Log($"Gained {spuGained} SPU for {StarPowerType} Star Power! Total SPU: {SPU}");
        }
コード例 #17
0
        /// <summary>
        /// Decreases the current number of Star Power units Mario has.
        /// </summary>
        /// <param name="spuLost">The number of Star Power units to subtract. If negative, this value will be changed to positive.</param>
        public void LoseStarPower(float spuLost)
        {
            if (spuLost <= 0)
            {
                Debug.LogError($"{nameof(spuLost)} is less than or equal to 0, which should never happen. Changing to negative");
                spuLost = -spuLost;
            }

            SPU = UtilityGlobals.Clamp(SPU - spuLost, 0f, MaxSPU);

            Debug.Log($"Lost {spuLost} SPU for {StarPowerType} Star Power! Total SPU: {SPU}");
        }
コード例 #18
0
        protected void UpdateCursor()
        {
            CursorAngle = UtilityGlobals.Clamp(CursorAngle + CursorMoveSpeed, MinCursorAngle, MaxCursorAngle);

            //If it reached its limits, reverse the angle
            if (CursorAngle >= MaxCursorAngle || CursorAngle <= MinCursorAngle)
            {
                CursorMoveSpeed = -CursorMoveSpeed;
            }

            Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(StartPosition, CircleRadius), CursorAngle, true);
            Cursor.Rotation = (float)(-ElapsedTime * UtilityGlobals.ToRadians(CursorRotSpeed));
        }
コード例 #19
0
        /// <summary>
        /// Changes the current selection.
        /// </summary>
        /// <param name="amount">The amount to change the selection.</param>
        protected void ChangeSelection(int amount)
        {
            if (WrapCursor == false)
            {
                CurSelection = UtilityGlobals.Clamp(CurSelection + amount, 0, LastSelection);
            }
            else
            {
                CurSelection = UtilityGlobals.Wrap(CurSelection + amount, 0, LastSelection);
            }

            OnSelectionChanged(CurSelection);
        }
コード例 #20
0
        /// <summary>
        /// Gets the origin of a SpriteFont by ratio instead of specifying width and height
        /// </summary>
        /// <param name="spriteFont">The font to get the origin for</param>
        /// <param name="text">The text to be displayed</param>
        /// <param name="x">The X ratio of the origin, between 0 and 1</param>
        /// <param name="y">The Y ratio of the origin, between 0 and 1</param>
        /// <returns>A Vector2 with the origin</returns>
        public static Vector2 GetOrigin(this SpriteFont spriteFont, string text, float x, float y)
        {
            if (string.IsNullOrEmpty(text) == true)
            {
                return(Vector2.Zero);
            }

            Vector2 size = spriteFont.MeasureString(text);

            size.X *= UtilityGlobals.Clamp(x, 0f, 1f);
            size.Y *= UtilityGlobals.Clamp(y, 0f, 1f);

            return(size);
        }
コード例 #21
0
        public DamageStarVFX(int damageDisplayed, Vector2 position)
        {
            DamageDisplayed = UtilityGlobals.Clamp(damageDisplayed, BattleGlobals.MinDamage, BattleGlobals.MaxDamage);
            Position        = position;

            if (DamageDisplayed <= 0)
            {
                MaxScale = new Vector2(.3f, .3f);
            }

            StarHalfLeft = new CroppedTexture2D(AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"),
                                                new Rectangle(305, 809, 31, 58));
            StarHalfRight = StarHalfLeft.Copy();
        }
コード例 #22
0
        //Virtual to account for all types of MoveActions (Ex. Special Moves check for SP instead of FP)
        public virtual void Initialize()
        {
            /*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.GetEquippedBadgeCount(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;
                }
            }

            //If the move targets entities, check if any entities can be targeted
            if (MoveProperties.MoveAffectionType != MoveAffectionTypes.None)
            {
                BattleEntity[] entities = GetEntitiesMoveAffects();//BattleManager.Instance.GetEntities(MoveProperties.EntityType, MoveProperties.HeightsAffected);

                //There are no entities this move can target
                if (entities.Length == 0)
                {
                    Disabled       = true;
                    DisabledString = "There's no one this move can target!";
                    return;
                }
            }
        }
コード例 #23
0
        public override void Draw()
        {
            if (ActionCmd?.AcceptingInput == false)
            {
                return;
            }

            string text  = "NO!";
            Color  color = Color.Red;

            if (ActionCmd.WithinRange == true)
            {
                text  = "OKAY!";
                color = Color.Green;
            }

            SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, text, new Vector2(300, 150), color, .7f);

            BigCursor.Draw();
            SmallCursor.Draw();

            if (ActionCmd.WithinRange == true)
            {
                Vector2 prevScale = BigCursor.Scale;

                //Cap the scale so it can be seen clearly at all times
                const float maxScale = .8f;

                //Get the absolute value of the distance from the cursor to the center
                //Divide by half the SuccessRect's width since we're scaling based on how close it is to the center
                float diff  = Math.Abs(ActionCmd.SmallCursorPos.X - ActionCmd.SuccessRect.Center.X) / (ActionCmd.SuccessRect.Width / 2f);
                float scale = UtilityGlobals.Clamp(diff, 0f, maxScale);

                BigCursor.Scale = new Vector2(scale);
                BigCursor.Draw();

                BigCursor.Scale = prevScale;
            }
        }
コード例 #24
0
        protected override void SequenceSuccessBranch()
        {
            switch (SequenceStep)
            {
            case 0:

                //Check the damage dealt
                int[] damageValues = AttemptDamage(DamageDealt, EntitiesAffected, Action.DamageProperties, true);

                //If the total damage dealt was 1, stop decreasing the damage to keep it doing 1
                if (StopDecreasing == false && damageValues[0] == 1)
                {
                    StopDecreasing = true;
                }

                //Only decrease the value if we're not at 1 damage
                if (StopDecreasing == false)
                {
                    DamageValue = UtilityGlobals.Clamp(DamageValue - 1, BattleGlobals.MinDamage, BattleGlobals.MaxDamage);
                }

                //Repeat the sequence if the player is under the Power Bounce cap
                if (Bounces < BattleGlobals.MaxPowerBounces)
                {
                    ChangeSequenceBranch(SequenceBranch.Main);
                }
                else
                {
                    Debug.Log($"Reached Power Bounce limit with {Bounces} and real max is {BattleGlobals.MaxPowerBounces}!");
                    ChangeSequenceBranch(SequenceBranch.End);
                }
                break;

            default:
                PrintInvalidSequence();
                break;
            }
        }
コード例 #25
0
 /// <summary>
 /// Sets the Speed the animation plays at
 /// </summary>
 /// <param name="newSpeed">The new speed of the animation. This value cannot be lower than 0 as reversed playback is
 /// not supported through the speed</param>
 public void SetSpeed(float newSpeed)
 {
     Speed = UtilityGlobals.Clamp(newSpeed, 0, float.MaxValue);
 }
コード例 #26
0
 public StatusPropertyHolder(double statusPercentage, int additionalTurns)
 {
     StatusPercentage = UtilityGlobals.Clamp(statusPercentage, 0, double.MaxValue);
     AdditionalTurns  = additionalTurns;
     Immunity         = 0;
 }
コード例 #27
0
 /// <summary>
 /// Gives the player a number of Star Pieces.
 /// </summary>
 /// <param name="starPiecesAdded">The number of Star Pieces to give.</param>
 public void AddStarPieces(uint starPiecesAdded)
 {
     StarPieces = UtilityGlobals.Clamp(StarPieces + starPiecesAdded, 0u, MaxStarPieces);
 }
コード例 #28
0
 /// <summary>
 /// Subtracts a number of Star Pieces from the player.
 /// </summary>
 /// <param name="starPiecesSubtracted">The number of Star Pieces to subtract.</param>
 public void SubtractStarPieces(uint starPiecesSubtracted)
 {
     StarPieces = UtilityGlobals.Clamp(StarPieces - starPiecesSubtracted, 0u, MaxStarPieces);
 }
コード例 #29
0
        /// <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;
                }
            }
        }
コード例 #30
0
 /// <summary>
 /// Subtracts a number of coins from the player.
 /// </summary>
 /// <param name="coinsSubtracted">The number of coins to subtract.</param>
 public void SubtractCoins(uint coinsSubtracted)
 {
     Coins = UtilityGlobals.Clamp(Coins - coinsSubtracted, 0u, MaxCoins);
 }