/// <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(); }
/// <summary> /// Gets the total Danger status value for Mario and his Partner based on their HealthStates. /// This is factored in when calculating the amount of Crystal Star Star Power gained from an attack. /// </summary> /// <returns>A float of the Danger status value based on the HealthStates of both Mario and his Partner.</returns> public static float GetDangerStatusValue(BattleMario mario, BattlePartner partner) { float marioDangerStatusValue = GetMarioDangerStatusValue(mario); float partnerDangerStatusValue = GetPartnerDangerStatusValue(partner); return(marioDangerStatusValue * partnerDangerStatusValue); }
public void Draw() { //Vector2 hudPivot = HUDTex.GetCenterOrigin(); SpriteRenderer.Instance.DrawUI(HUDTex, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, false, false, .1f, true); BattleMario mario = BattleManager.Instance.GetMario(); BattlePartner partner = BattleManager.Instance.GetPartner(); if (mario != null) { SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{mario.Name} HP: {mario.CurHP}/{mario.BattleStats.MaxHP}", new Vector2(30, 10), Color.White, .2f); } if (partner != null) { SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{partner.Name} HP: {partner.CurHP}/{partner.BattleStats.MaxHP}", new Vector2(30, 30), Color.White, .2f); } if (mario != null) { SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"FP: {mario.CurFP}/{mario.BattleStats.MaxFP}", new Vector2(30, 50), Color.White, .2f); SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"SP: {mario.MStats.SSStarPower.SPU}/{mario.MStats.SSStarPower.MaxSPU}", new Vector2(155, 50), Color.White, .2f); } }
public SwapPartnerBattleEvent(BattlePartner oldPartner, BattlePartner newPartner, double moveTime, double waitTime) { OldPartner = oldPartner; NewPartner = newPartner; MoveTime = moveTime; WaitTime = waitTime; }
public ChangePartnerAction(BattleEntity user, BattlePartner newPartner) : base(user) { NewPartner = newPartner; Name = NewPartner.Name; CroppedTexture2D partnerIcon = null; //Icons exist only for any regular partners //Don't display anything for temporary or unused partners if (NewPartner.PartnerType <= Enumerations.PartnerTypes.MsMowz) { Rectangle sourceRect = new Rectangle(30 + (((int)NewPartner.PartnerType - 1) * 32), 886, 32, 32); //Pretty hackish for now; show the disabled icon instead if the Partner is the current one out if (NewPartner == User.BManager.Partner) { sourceRect.Y += 32; } partnerIcon = new CroppedTexture2D(AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.UIRoot}/Battle/BattleGFX.png"), sourceRect); } MoveInfo = new MoveActionData(partnerIcon, NewPartner.PartnerDescription, Enumerations.MoveResourceTypes.FP, 0, Enumerations.CostDisplayTypes.Hidden, Enumerations.MoveAffectionTypes.None, Enumerations.EntitySelectionType.Single, false, null); SetMoveSequence(new ChangePartnerSequence(this, NewPartner)); }
protected override void OnEnd() { ElapsedTime = 0d; OldPartner = null; NewPartner = null; StartPos = EndPos = Vector2.Zero; }
/// <summary> /// Gets a particular Partner in the party. /// </summary> /// <param name="partnerType">The PartnerType of the Partner.</param> /// <returns>A BattlePartner with the specified PartnerType if it exists in the party, otherwise null.</returns> public BattlePartner GetPartner(PartnerTypes partnerType) { BattlePartner partner = null; Partners.TryGetValue(partnerType, out partner); return(partner); }
protected override void GetCustomAffectedEntities(List <BattleEntity> entityList) { BattlePartner partner = User.BManager.Partner; if (partner != null) { entityList.Add(partner); } }
protected override BattleEntity[] GetCustomAffectedEntities() { BattlePartner partner = BattleManager.Instance.GetPartner(); if (partner == null) { return(null); } return(new BattleEntity[] { partner }); }
public ChangePartner(BattlePartner newPartner) { NewPartner = newPartner; Name = NewPartner.Name; MoveInfo = new MoveActionData(null, NewPartner.PartnerDescription, Enumerations.MoveResourceTypes.FP, 0, Enumerations.CostDisplayTypes.Hidden, Enumerations.MoveAffectionTypes.None, TargetSelectionMenu.EntitySelectionType.Single, false, null); SetMoveSequence(new ChangePartnerSequence(this, NewPartner)); }
/// <summary> /// Removes a Partner from the party. /// </summary> /// <param name="partnerType">The PartnerType of the Partner.</param> public void RemovePartner(PartnerTypes partnerType) { BattlePartner battlePartner = GetPartner(partnerType); if (battlePartner == null) { Debug.LogError($"Mario doesn't have {partnerType} as a Partner, so he/she cannot be removed from the party"); return; } Partners.Remove(partnerType); }
/// <summary> /// Swaps Badges from one Partner to another new Partner to apply the effects to that Partner. /// </summary> /// <param name="partnerEquipped">The Partner currently equipped with the Badges.</param> /// <param name="newPartner">The Partner to equip the Badges to.</param> public static void SwapPartnerBadges(BattlePartner partnerEquipped, BattlePartner newPartner) { Badge[] partnerBadges = partnerEquipped.EntityProperties.GetEquippedBadges(); //Go through all the Badges for (int i = 0; i < partnerBadges.Length; i++) { //Unequip them from the current Partner partnerBadges[i].UnEquip(); //Equip them onto the new Partner partnerBadges[i].Equip(newPartner); } }
/// <summary> /// Adds all Partners in the party to the supplied list. /// </summary> /// <param name="partnerList">The list of Partners to fill.</param> public void GetAllPartners(List <BattlePartner> partnerList) { //Add them in the order they are defined in the PartnerTypes enum PartnerTypes[] partnerTypes = EnumUtility.GetValues <PartnerTypes> .EnumValues; for (int i = 0; i < partnerTypes.Length; i++) { BattlePartner partner = GetPartner(partnerTypes[i]); if (partner != null) { partnerList.Add(partner); } } }
/// <summary> /// Swaps Badges from one Partner to another new Partner to apply the effects to that Partner /// </summary> /// <param name="partnerEquipped">The Partner currently equipped with the Badges</param> /// <param name="newPartner">The Partner to equip the Badges to</param> public static void SwapPartnerBadges(BattlePartner partnerEquipped, BattlePartner newPartner) { List <Badge> partnerBadges = Inventory.Instance.GetActivePartnerBadges(true); //Go through all the Badges for (int i = 0; i < partnerBadges.Count; i++) { //Unequip them from the current Partner partnerBadges[i].UnEquip(); //Equip them onto the new Partner partnerBadges[i].Equip(newPartner); } }
/// <summary> /// Adds a Partner to the party. /// </summary> /// <param name="battlePartner">The BattlePartner to add to the party.</param> public void AddPartner(BattlePartner battlePartner) { if (battlePartner == null) { Debug.LogError($"{nameof(battlePartner)} is null! Partner will not be added as a result"); return; } if (HasPartner(battlePartner.PartnerType) == true) { Debug.LogError($"Mario already has {battlePartner.PartnerType} as a Partner"); return; } Partners.Add(battlePartner.PartnerType, battlePartner); }
/// <summary> /// Removes a Partner from the party. /// </summary> /// <param name="partner">The PartnerType of the Partner.</param> public void RemovePartner(PartnerTypes partner) { if (HasPartner(partner) == false) { Debug.LogError($"Mario doesn't have {partner} as a Partner, so he/she cannot be from the party"); return; } BattlePartner battlePartner = GetPartner(partner); Partners.Remove(partner); ////If the last partner that left the party was the current active one, get another Partner to be active //if (battlePartner == ActivePartner) //{ // SetActivePartner(GetNextPartner()); //} }
public void Draw() { if (BManager == null) { return; } BattleMario mario = BManager.Mario; BattlePartner partner = BManager.Partner; if (mario != null) { SpriteRenderer.Instance.DrawUI(HPBanner.Tex, new Vector2(60, 50), HPBanner.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .1f, true); SpriteRenderer.Instance.DrawUI(MarioHPIcon.Tex, new Vector2(50, 40), MarioHPIcon.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .11f, true); SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{mario.CurHP}/{mario.BattleStats.MaxHP}", new Vector2(120, 54), Color.White, .2f); } if (partner != null) { SpriteRenderer.Instance.DrawUI(HPBanner.Tex, new Vector2(60, 90), HPBanner.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .1f, true); SpriteRenderer.Instance.DrawUI(PartnerHPIcon.Tex, new Vector2(50, 85), PartnerHPIcon.SourceRect, Color.White, 0f, Vector2.Zero, .7f, false, false, .11f, true); SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{partner.CurHP}/{partner.BattleStats.MaxHP}", new Vector2(120, 94), Color.White, .2f); } if (mario != null) { //Draw FP info SpriteRenderer.Instance.DrawUI(FPBanner.Tex, new Vector2(250, 50), FPBanner.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .1f, true); SpriteRenderer.Instance.DrawUI(FPIcon.Tex, new Vector2(240, 45), FPIcon.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .11f, true); SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{mario.CurFP}/{mario.BattleStats.MaxFP}", new Vector2(305, 53), Color.White, .2f); //Draw Star Power info SpriteRenderer.Instance.DrawUI(StarPowerBanner.Tex, new Vector2(250, 90), StarPowerBanner.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .1f, true); SpriteRenderer.Instance.DrawUI(StarPowerIcon.Tex, new Vector2(240, 85), StarPowerIcon.SourceRect, Color.White, 0f, Vector2.Zero, 1f, false, false, .11f, true); SpriteRenderer.Instance.DrawUIText(AssetManager.Instance.TTYDFont, $"{mario.MStats.SSStarPower.SPU}/{mario.MStats.SSStarPower.MaxSPU}", new Vector2(305, 93), Color.White, .2f); } }
//public void SetActivePartner(BattlePartner battlePartner) //{ // ActivePartner = battlePartner; //} /// <summary> /// Adds a Partner to the party. /// </summary> /// <param name="battlePartner">The BattlePartner to add to the party.</param> public void AddPartner(BattlePartner battlePartner) { if (battlePartner == null) { Debug.LogError($"{nameof(battlePartner)} is null! Partner will not be added as a result"); return; } if (HasPartner(battlePartner.PartnerType) == true) { Debug.LogError($"Mario already has {battlePartner.PartnerType} as a Partner"); return; } Partners.Add(battlePartner.PartnerType, battlePartner); ////If no previous Partners exist, the active Partner is the one that was just added //if (Partners.Count == 0) //{ // SetActivePartner(battlePartner); //} }
/// <summary> /// Gets a Partner's Danger status value based on its current HealthState. /// </summary> /// <param name="partner">Mario's Partner.</param> /// <returns>A float of the Partner's Danger status value.</returns> private static float GetPartnerDangerStatusValue(BattlePartner partner) { if (partner == null) { return(NormalMod); } Enumerations.HealthStates partnerHealthState = partner.HealthState; switch (partnerHealthState) { case Enumerations.HealthStates.Normal: return(NormalMod); case Enumerations.HealthStates.Danger: return(PartnerDangerMod); case Enumerations.HealthStates.Peril: case Enumerations.HealthStates.Dead: default: return(PartnerPerilMod); } }
/// <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; } }
private void LoadBattle() { //Initialize core battle properties BattleGlobals.BattleProperties battleProperties = new BattleGlobals.BattleProperties(BattleGlobals.BattleSettings.Normal, true); BattleMario mario = new BattleMario(new MarioStats(1, 10, 5, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal)); List <BattleEntity> enemyList = new List <BattleEntity>(); //Clean up any previous references we may have lightingManager?.CleanUp(); lightingManager = null; battleManager?.CleanUp(); battleManager = null; if (Inventory.HasInstance == true) { Inventory.Instance.CleanUp(); } if (DialogueManager.HasInstance == true) { DialogueManager.Instance.CleanUp(); } //Read from the config //First check if the config is in the same folder as the executable if (ConfigLoader.LoadConfig($"{ContentGlobals.ConfigName}", ref battleProperties, mario, enemyList) == false) { //If it's not here, check in the root of the Content folder if (ConfigLoader.LoadConfig($"{ContentGlobals.ContentRoot}/{ContentGlobals.ConfigName}", ref battleProperties, mario, enemyList) == false) { //If we failed to read from the config, initialize a default battle InitDefaultBattle(mario, enemyList); } } //Initialize the BattleManager battleManager = new BattleManager(); //Send out the first Partner to battle, provided it exists int partnerCount = Inventory.Instance.partnerInventory.GetPartnerCount(); BattlePartner partner = (partnerCount == 0) ? null : Inventory.Instance.partnerInventory.GetAllPartners()[0]; battleManager.Initialize(battleProperties, mario, partner, enemyList); //Initialize helper objects //Check for the battle setting and add darkness if so if (battleManager.Properties.BattleSetting == BattleGlobals.BattleSettings.Dark) { BattleDarknessObj battleDarkness = new BattleDarknessObj(battleManager); //Initialize the lighting manager for dark battles lightingManager = new LightingManager(battleDarkness, AssetManager.Instance.LoadAsset <Effect>($"{ContentGlobals.ShaderRoot}Lighting"), AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.ShaderTextureRoot}LightMask.png")); battleManager.battleObjManager.AddBattleObject(battleDarkness); } //Add the HP bar manager battleManager.battleObjManager.AddBattleObject(new HPBarManagerObj(battleManager)); //If you can't run from battle, show a message at the start saying so if (battleManager.Properties.Runnable == false) { battleManager.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Message, new BattleGlobals.BattleState[] { BattleGlobals.BattleState.Turn }, new MessageBattleEvent(battleManager.battleUIManager, BattleGlobals.NoRunMessage, MessageBattleEvent.DefaultWaitDuration)); } //Start the battle battleManager.StartBattle(); }
public ChangePartnerSequence(MoveAction moveAction, BattlePartner newPartner) : base(moveAction) { NewPartner = newPartner; }
protected override void SequenceMainBranch() { switch (SequenceStep) { case 0: //If, for whatever reason, a Duplighost isn't using this move, then just continue if (DuplighostRef == null) { Debug.LogWarning($"{User.Name} is not a Duplighost, so nothing will happen!"); ChangeSequenceBranch(SequenceBranch.End); break; } BattleEntity entityDisguised = EntitiesAffected[0]; //Copy the animations of the entity DuplighostRef.CopyEntityAnimations(entityDisguised.AnimManager); //See which Partner the Duplighost is disguised as BattlePartner partnerDisguised = entityDisguised as BattlePartner; if (partnerDisguised != null) { DuplighostRef.PartnerTypeDisguise = partnerDisguised.PartnerType; //If disguising as Watt, add Electrified, Watt's light source, and Watt's Payback if (DuplighostRef.PartnerTypeDisguise == Enumerations.PartnerTypes.Watt) { DuplighostRef.EntityProperties.AddPhysAttribute(Enumerations.PhysicalAttributes.Electrified); DuplighostRef.EntityProperties.AddAdditionalProperty(Enumerations.AdditionalProperty.LightSource, partnerDisguised.EntityProperties.GetAdditionalProperty <double>(Enumerations.AdditionalProperty.LightSource)); //Copy Watt's Payback Watt watt = partnerDisguised as Watt; StatusGlobals.PaybackHolder wattPayback = watt.ElectricPayback; DuplighostRef.PaybackCopied = wattPayback; DuplighostRef.EntityProperties.AddPayback(wattPayback); } //Do an Easter Egg by replicating PM's glitchy behavior when Duplighosts disguise as Goompa //Kill off the Duplighost, and set Mario to its position else if (DuplighostRef.PartnerTypeDisguise == Enumerations.PartnerTypes.Goompa) { //Make sure Mario is in battle (he should be!) if (User.BManager.Mario != null) { User.BManager.Mario.Position = DuplighostRef.Position; } DuplighostRef.Die(); } } //If copying a Flippable BattleEntity, copy its Flippable behavior IFlippableEntity flippableEnt = entityDisguised as IFlippableEntity; if (flippableEnt != null) { DuplighostRef.FlippableBehavior = flippableEnt.FlippedBehavior.CopyBehavior(DuplighostRef); } //Copy its Defense and height state DuplighostRef.BattleStats.BaseDefense = entityDisguised.BattleStats.BaseDefense; //Handle marking that it's airborne if (entityDisguised.HeightState == Enumerations.HeightStates.Airborne) { DuplighostRef.ChangeHeightState(entityDisguised.HeightState); DuplighostRef.SetBattlePosition(DuplighostRef.BattlePosition - new Vector2(0f, BattleGlobals.AirborneY)); DuplighostRef.Position = DuplighostRef.BattlePosition; } CurSequenceAction = new WaitSeqAction(DisguiseWaitDur); ChangeSequenceBranch(SequenceBranch.End); break; default: PrintInvalidSequence(); break; } }
/// <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); } }