/// <summary>
        /// Initializes the battle
        /// </summary>
        /// <param name="mario">Mario</param>
        /// <param name="partner">Mario's partner</param>
        /// <param name="enemies">The enemies, in order</param>
        public void Initialize(BattleMario mario, BattlePartner partner, List <BattleEnemy> enemies)
        {
            Mario   = mario;
            Partner = partner;

            //Mario always starts out in the front, and the Partner always starts out in the back
            FrontPlayer = Mario;
            BackPlayer  = Partner;

            Mario.Position = MarioPos;
            Mario.SetBattlePosition(MarioPos);

            //Start battle for Mario
            Mario.OnBattleStart();

            if (Partner != null)
            {
                Partner.Position = PartnerPos;
                Partner.SetBattlePosition(PartnerPos);

                //Start battle for the Partner
                Partner.OnBattleStart();
            }

            //Add and initialize enemies
            AddEnemies(enemies);

            StartBattle();
        }
Exemple #2
0
            public static void TestPAndNoPEquipCount2(BattlePlayer player)
            {
                CloseCallPBadge CCP1 = new CloseCallPBadge();
                CloseCallPBadge CCP2 = new CloseCallPBadge();
                CloseCallPBadge CCP3 = new CloseCallPBadge();
                CloseCallPBadge CCP4 = new CloseCallPBadge();
                CloseCallBadge  CC   = new CloseCallBadge();

                CCP1.Equip(player);
                CCP2.Equip(player);
                CCP3.Equip(player);
                CCP4.Equip(player);
                CC.Equip(player);

                Debug.Assert(player.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.CloseCall) == 1);
                Debug.Assert(player.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.CloseCallP) == 4);
                Debug.Assert(player.GetEquippedNPBadgeCount(BadgeGlobals.BadgeTypes.CloseCall) == 5);
                Debug.Assert(player.GetEquippedNPBadgeCount(BadgeGlobals.BadgeTypes.CloseCallP) == 5);

                CCP1.UnEquip();
                CCP2.UnEquip();
                CCP3.UnEquip();
                CCP4.UnEquip();
                CC.UnEquip();

                Debug.Log("\n");
            }
        /// <summary>
        /// Tells whether Mario and his Partner can switch places with each other.
        /// </summary>
        /// <returns>true if Mario or his Partner hasn't used up all of his or her turns and isn't dead, otherwise false.</returns>
        private bool CanSwitch()
        {
            BattlePlayer otherPlayer = BattleManager.Instance.EntityTurn == BattleManager.Instance.GetFrontPlayer()
                    ? BattleManager.Instance.GetBackPlayer() : BattleManager.Instance.GetFrontPlayer();

            int immobile = otherPlayer.EntityProperties.GetAdditionalProperty <int>(AdditionalProperty.Immobile);

            return(otherPlayer.UsedTurn == false && otherPlayer.IsDead == false && immobile <= 0);
        }
        /// <summary>
        /// Switches Mario and his Partner's battle positions and updates the Front and Back player references.
        /// <para>The actual players' positions are not changed here but in a Battle Event.</para>
        /// <see cref="SwapPositionBattleEvent"/>
        /// </summary>
        /// <param name="frontPlayer"></param>
        /// <param name="backPlayer"></param>
        private void SwitchPlayers(BattlePlayer frontPlayer, BattlePlayer backPlayer)
        {
            Vector2 frontBattlePosition = FrontPlayer.BattlePosition;
            Vector2 backBattlePosition  = BackPlayer.BattlePosition;

            FrontPlayer.SetBattlePosition(backBattlePosition);
            BackPlayer.SetBattlePosition(frontBattlePosition);

            FrontPlayer = frontPlayer;
            BackPlayer  = backPlayer;
        }
        public TacticsSubMenu()
        {
            Position = new Vector2(230, 150);

            BattleEntity entity = BattleManager.Instance.EntityTurn;

            //int quickChangeCount = entity.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.QuickChange);
            //Enumerations.CostDisplayTypes costDisplayType = Enumerations.CostDisplayTypes.Shown;
            //if (quickChangeCount > 0) costDisplayType = Enumerations.CostDisplayTypes.Special;

            BattleActions.Add(new MenuAction("Change Partner", null, "Change your current partner.", //costDisplayType,
                                             new ChangePartnerSubMenu()));


            #region Charge Menu

            BadgeGlobals.BadgeTypes chargeBadgeType = BadgeGlobals.BadgeTypes.Charge;

            //Check for a Player; if the Player is a Partner, check the number of Charge P's instead
            if (entity.EntityType == Enumerations.EntityTypes.Player)
            {
                BattlePlayer player = (BattlePlayer)entity;
                if (player.PlayerType == Enumerations.PlayerTypes.Partner)
                {
                    chargeBadgeType = BadgeGlobals.BadgeTypes.ChargeP;
                }
            }

            //Charge action if the Charge or Charge P Badge is equipped
            int chargeCount = entity.GetEquippedBadgeCount(chargeBadgeType);
            if (chargeCount > 0)
            {
                //Charge starts out at 2 then increases by 1 for each additional Badge
                int chargeAmount = 2 + (chargeCount - 1);

                BattleActions.Add(new MoveAction("Charge", new MoveActionData(null, "Save up strength to power up your next attack",
                                                                              Enumerations.MoveResourceTypes.FP, chargeCount, Enumerations.CostDisplayTypes.Shown, Enumerations.MoveAffectionTypes.None,
                                                                              TargetSelectionMenu.EntitySelectionType.Single, false, null), new ChargeSequence(null, chargeAmount)));
            }

            #endregion

            //Defend action
            BattleActions.Add(new Defend());

            //Do nothing action
            BattleActions.Add(new NoAction());
        }
Exemple #6
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;
            }
        }
        protected override void HandleSelectionInput()
        {
            if (Input.GetKeyDown(Keys.X))
            {
                OnBackOut();
            }
            else if (Input.GetKeyDown(Keys.Z))
            {
                OnConfirm();
            }
            else if (Input.GetKeyDown(Keys.C))
            {
                BattlePlayer otherPlayer = BattleManager.Instance.EntityTurn == BattleManager.Instance.GetFrontPlayer()
                    ? BattleManager.Instance.GetBackPlayer() : BattleManager.Instance.GetFrontPlayer();

                //Don't switch if the back player is dead
                if (CanSwitch() == true)
                {
                    //Switch turns with Mario or the Partner
                    //This updates the front and back player references and their battle positions
                    BattleManager.Instance.SwitchToTurn(PlayerType == PlayerTypes.Partner ? PlayerTypes.Mario : PlayerTypes.Partner);

                    //End the current player's turn. This won't affect the number of turns the
                    //players have, as that is handled in the entity's own EndTurn() method
                    BattleManager.Instance.TurnEnd();

                    //Queue a Battle Event to swap the current positions of Mario and his Partner
                    //Since we updated the references earlier, their new positions are their own battle positions
                    BattleEventManager.Instance.QueueBattleEvent((int)BattleGlobals.StartEventPriorities.Stage,
                                                                 new BattleManager.BattleState[] { BattleManager.BattleState.Turn, BattleManager.BattleState.TurnEnd },
                                                                 new SwapPositionBattleEvent(BattleManager.Instance.GetBackPlayer(), BattleManager.Instance.GetFrontPlayer(),
                                                                                             BattleManager.Instance.GetBackPlayer().BattlePosition, BattleManager.Instance.GetFrontPlayer().BattlePosition, 500f));
                }
                else
                {
                    Debug.LogError($"{otherPlayer.Name} used all of his/her turns or is dead, so turns cannot be swapped with him/her.");
                }
            }
        }
        /// <summary>
        /// Swaps out Mario's current Partner for a different one.
        /// </summary>
        /// <param name="newPartner">The new BattlePartner to take part in battle.</param>
        public void SwapPartner(BattlePartner newPartner)
        {
            BattlePartner oldPartner = Partner;

            Partner          = newPartner;
            Partner.Position = oldPartner.Position;
            Partner.SetBattlePosition(oldPartner.BattlePosition);

            //Set the new Partner to use the same max number of turns all Partners have this phase cycle
            Partner.SetMaxTurns(BattlePartner.PartnerMaxTurns);

            //If the entity swapping out partners is the old one increment the turn count for the new partner,
            //as the old one's turn count will be incremented after the action is finished
            if (EntityTurn == oldPartner)
            {
                Partner.SetTurnsUsed(oldPartner.TurnsUsed + 1);
            }
            //Otherwise, the entity swapping out partners must be Mario, so set the new Partner's turn count to the old one's
            //(or an enemy via an attack, but none of those attacks exist in the PM games...I'm hinting at a new attack idea :P)
            else
            {
                Partner.SetTurnsUsed(oldPartner.TurnsUsed);
            }

            //Swap Partner badges with the new Partner
            BattlePartner.SwapPartnerBadges(oldPartner, Partner);

            //Check if the Partner is in the front or back and set the correct reference
            if (oldPartner == FrontPlayer)
            {
                FrontPlayer = Partner;
            }
            else if (oldPartner == BackPlayer)
            {
                BackPlayer = Partner;
            }
        }