/// <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; } }
/// <summary> /// Handles swapping Partners. /// </summary> private void SwapPartner() { //Set the new Partner reference OldPartner.BManager.SetPartner(NewPartner); //Remove the old Partner from battle, then add the new Partner to battle OldPartner.BManager.RemoveEntity(OldPartner, false); //Swap Partner badges with the new Partner BattlePartner.SwapPartnerBadges(OldPartner, NewPartner); //Add the new Partner to battle OldPartner.BManager.AddEntity(NewPartner, null); //Position offset Vector2 offset = Vector2.Zero; //If the old Partner was airborne and the new one isn't, move the new one down if (OldPartner.HeightState == HeightStates.Airborne && NewPartner.HeightState != HeightStates.Airborne) { offset.Y += BattleGlobals.AirborneY; } //Otherwise, if the old Partner wasn't airborne and the new one is, move the new one up else if (OldPartner.HeightState != HeightStates.Airborne && NewPartner.HeightState == HeightStates.Airborne) { offset.Y -= BattleGlobals.AirborneY; } //Set positions to the old ones NewPartner.Position = OldPartner.Position; NewPartner.SetBattleIndex(OldPartner.BattleIndex); NewPartner.SetBattlePosition(OldPartner.BattlePosition + offset); //State the old Partner is out of battle OldPartner.SetBattleIndex(BattleGlobals.InvalidBattleIndex); //Set flip state NewPartner.SpriteFlip = OldPartner.SpriteFlip; //Set the new Partner to use the same max number of turns all Partners have this phase cycle //The only exceptions are if the new partner doesn't move at all (Ex. Goompa) or is immobile //In this case, set its max turn count to 0 if (NewPartner.BaseTurns > 0 && NewPartner.IsImmobile() == false) { NewPartner.SetMaxTurns(BattlePartner.PartnerMaxTurns); } else { NewPartner.SetMaxTurns(0); } //If the BattleEntity 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 (OldPartner.IsTurn == true) { NewPartner.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 { NewPartner.SetTurnsUsed(OldPartner.TurnsUsed); } }