public void GenerateNextAnimationScreens(Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, Squad TargetSquad, SupportSquadHolder TargetSquadSupport, AnimationScreen.AnimationUnitStats UnitStats, AnimationScreen.BattleAnimationTypes BattleAnimationType, SquadBattleResult AttackingResult) { bool IsActiveSquadOnRight = BattleAnimationType == AnimationScreen.BattleAnimationTypes.RightAttackLeft || BattleAnimationType == AnimationScreen.BattleAnimationTypes.LeftConteredByRight; bool HorionztalMirror = BattleAnimationType == AnimationScreen.BattleAnimationTypes.RightConteredByLeft || BattleAnimationType == AnimationScreen.BattleAnimationTypes.LeftAttackRight; Squad NonDemoRightSquad; Squad NonDemoRightSupport; Squad NonDemoLeftSquad; Squad NonDemoLeftSupport; GetLeftRightSquads(IsActiveSquadOnRight, ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, out NonDemoRightSquad, out NonDemoRightSupport, out NonDemoLeftSquad, out NonDemoLeftSupport); Squad AttackingSquad = NonDemoRightSquad; Squad ActiveUnitSupport = NonDemoRightSupport; Attack ActiveAttack = AttackingSquad.CurrentLeader.CurrentAttack; string ActiveTerrain = NonDemoRightSquad.CurrentMovement; SquadBattleResult BattleResult = AttackingResult; Squad EnemySquad = NonDemoLeftSquad; Squad EnemySupport = NonDemoLeftSupport; if (BattleAnimationType == AnimationScreen.BattleAnimationTypes.LeftAttackRight || BattleAnimationType == AnimationScreen.BattleAnimationTypes.LeftConteredByRight) { AttackingSquad = NonDemoLeftSquad; ActiveUnitSupport = NonDemoLeftSupport; ActiveAttack = AttackingSquad.CurrentLeader.CurrentAttack; ActiveTerrain = NonDemoLeftSquad.CurrentMovement; EnemySquad = NonDemoRightSquad; EnemySupport = NonDemoRightSupport; } string ExtraTextIntro = AttackingSquad.CurrentLeader.FullName + " Attacks!"; string ExtraTextHit = AttackingSquad.CurrentLeader.FullName + " hits! " + EnemySquad.CurrentLeader.FullName + " takes " + BattleResult.ArrayResult[0].AttackDamage + " damage!"; string ExtraTextMiss = AttackingSquad.CurrentLeader.FullName + " misses! " + EnemySquad.CurrentLeader.FullName + " takes 0 damage!"; string ExtraTextKill = EnemySquad.CurrentLeader.FullName + " is destroyed!"; AnimationBackground ActiveAnimationBackground = new AnimationBackground2D("Backgrounds 2D/Ground", Content, GraphicsDevice); CreateAnimation(AttackingSquad.CurrentLeader.Animations.MoveFoward, this, AttackingSquad, EnemySquad, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); CreateAnimation(ActiveAttack.Animations.Start, this, AttackingSquad, EnemySquad, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, ExtraTextIntro, HorionztalMirror); if (BattleResult.ArrayResult[0].AttackMissed) { CreateAnimation(ActiveAttack.Animations.EndMiss, this, AttackingSquad, EnemySquad, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, ExtraTextMiss, HorionztalMirror); } else { // Check for support if (EnemySupport != null) { CreateAnimation("Default Animations/Support In", this, EnemySquad, EnemySupport, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); if (BattleResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(BattleResult.ArrayResult[0].AttackDamage) > 0) { CreateAnimation(ActiveAttack.Animations.EndHit, this, AttackingSquad, EnemySupport, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); CreateAnimation("Default Animations/Support Out", this, EnemySquad, EnemySupport, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); } else { CreateAnimation(ActiveAttack.Animations.EndDestroyed, this, AttackingSquad, EnemySupport, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); CreateAnimation("Default Animations/Support Destroyed", this, EnemySquad, EnemySupport, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, "", HorionztalMirror); } } else { if (BattleResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(BattleResult.ArrayResult[0].AttackDamage) <= 0) { CreateAnimation(ActiveAttack.Animations.EndDestroyed, this, AttackingSquad, EnemySquad, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, ExtraTextKill, HorionztalMirror); } else { CreateAnimation(ActiveAttack.Animations.EndHit, this, AttackingSquad, EnemySquad, ActiveAttack, BattleResult, UnitStats, ActiveAnimationBackground, ExtraTextHit, HorionztalMirror); } } } }
public void InitPlayerBattle(bool IsActiveSquadOnRight) { int FinalActivePlayerIndex = ActivePlayerIndex; int FinalActiveSquadIndex = ActiveSquadIndex; Squad FinalActiveSquad = ActiveSquad; SupportSquadHolder FinalActiveSquadSupport = ActiveSquadSupport; int FinalTargetPlayerIndex = TargetPlayerIndex; int FinalTargetSquadIndex = TargetSquadIndex; Squad FinalTargetSquad = TargetSquad; SupportSquadHolder FinalTargetSquadSupport = TargetSquadSupport; if (TargetSquad.CurrentLeader.Boosts.AttackFirstModifier && !ActiveSquad.CurrentLeader.Boosts.AttackFirstModifier) { FinalActivePlayerIndex = TargetPlayerIndex; FinalActiveSquadIndex = TargetSquadIndex; FinalActiveSquad = TargetSquad; FinalActiveSquadSupport = TargetSquadSupport; FinalTargetPlayerIndex = ActivePlayerIndex; FinalTargetSquadIndex = ActiveSquadIndex; FinalTargetSquad = ActiveSquad; FinalTargetSquadSupport = ActiveSquadSupport; } bool ShowAnimation = Constants.ShowAnimation && FinalActiveSquad.CurrentLeader.CurrentAttack.GetAttackAnimations(Map.ActiveParser).Start.AnimationName != null; ListNextAnimationScreen.Clear(); Map.NonDemoScreen.ListNonDemoBattleFrame.Clear(); if (Map.IsOfflineOrServer) { AttackingResult = Map.CalculateFinalHP(FinalActiveSquad, FinalActiveSquadSupport.ActiveSquadSupport, FinalActivePlayerIndex, Map.BattleMenuOffenseFormationChoice, FinalTargetSquad, FinalTargetSquadSupport.ActiveSquadSupport, FinalTargetPlayerIndex, FinalTargetSquadIndex, true, true); DefendingResult = new SquadBattleResult(new BattleResult[1] { new BattleResult() }); } else { Map.CalculateFinalHP(FinalActiveSquad, FinalActiveSquadSupport.ActiveSquadSupport, FinalActivePlayerIndex, Map.BattleMenuOffenseFormationChoice, FinalTargetSquad, FinalTargetSquadSupport.ActiveSquadSupport, FinalTargetPlayerIndex, FinalTargetSquadIndex, true, true); } AnimationScreen.AnimationUnitStats UnitStats = new AnimationScreen.AnimationUnitStats(FinalActiveSquad, FinalTargetSquad, IsActiveSquadOnRight); AnimationBackground TargetSquadBackground = null; AnimationBackground TargetSquadForeground = null; if (ShowAnimation) { AnimationScreen.BattleAnimationTypes BattleAnimationType = AnimationScreen.BattleAnimationTypes.LeftAttackRight; if (IsActiveSquadOnRight) { BattleAnimationType = AnimationScreen.BattleAnimationTypes.RightAttackLeft; } ListNextAnimationScreen.AddRange(Map.GenerateNextAnimationScreens(FinalActiveSquad, FinalActiveSquadSupport, FinalTargetSquad, FinalTargetSquadSupport, UnitStats, BattleAnimationType, AttackingResult, out TargetSquadBackground, null, out TargetSquadForeground, null)); } if (AttackingResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(AttackingResult.ArrayResult[0].AttackDamage) > 0) { //Counter. if (FinalTargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack) { if (Map.IsOfflineOrServer) { DefendingResult = Map.CalculateFinalHP(FinalTargetSquad, null, FinalTargetPlayerIndex, Map.BattleMenuDefenseFormationChoice, FinalActiveSquad, null, FinalActivePlayerIndex, FinalActiveSquadIndex, true, true); } else { Map.CalculateFinalHP(FinalTargetSquad, null, FinalTargetPlayerIndex, Map.BattleMenuDefenseFormationChoice, FinalActiveSquad, null, FinalActivePlayerIndex, FinalActiveSquadIndex, true, true); } if (ShowAnimation) { AnimationScreen.BattleAnimationTypes BattleAnimationType = AnimationScreen.BattleAnimationTypes.LeftConteredByRight; if (IsActiveSquadOnRight) { BattleAnimationType = AnimationScreen.BattleAnimationTypes.RightConteredByLeft; } ListNextAnimationScreen.AddRange(Map.GenerateNextAnimationScreens(FinalActiveSquad, FinalActiveSquadSupport, FinalTargetSquad, FinalTargetSquadSupport, UnitStats, BattleAnimationType, DefendingResult, out _, TargetSquadBackground, out _, TargetSquadForeground)); } } } if (Map.IsClient) { if (ShowAnimation) { Map.PushScreen(ListNextAnimationScreen[0]); ListNextAnimationScreen.RemoveAt(0); ListNextAnimationScreen.Add(new EndBattleAnimationScreen(Map, FinalActiveSquad, FinalActiveSquadSupport, FinalActivePlayerIndex, FinalTargetSquad, FinalTargetSquadSupport, FinalTargetPlayerIndex, AttackingResult, DefendingResult)); } else { Map.NonDemoScreen.InitNonDemo(FinalActiveSquad, FinalActiveSquadSupport, FinalActivePlayerIndex, AttackingResult, Map.BattleMenuOffenseFormationChoice, FinalTargetSquad, FinalTargetSquadSupport, FinalTargetPlayerIndex, DefendingResult, Map.BattleMenuDefenseFormationChoice, IsActiveSquadOnRight); Map.NonDemoScreen.Alive = true; Map.ListGameScreen.Insert(0, Map.NonDemoScreen); } } //AttackingSquad Activations. for (int U = 0; U < FinalActiveSquad.UnitsAliveInSquad; U++) { FinalActiveSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle); } //DefendingSquad Activations. for (int U = 0; U < FinalTargetSquad.UnitsAliveInSquad; U++) { FinalTargetSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle); } Map.FinalizeMovement(FinalActiveSquad, (int)Map.GetTerrain(FinalActiveSquad).MovementCost); FinalActiveSquad.EndTurn(); if (Map.IsClient) { bool HasAfterAttack = false; ActionPanelDeathmatch AfterAttack = new ActionPanelMainMenu(Map, FinalActivePlayerIndex, FinalActiveSquadIndex); if (FinalActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Attack) { HasAfterAttack = true; AfterAttack.AddChoiceToCurrentPanel(new ActionPanelAttackPart1(Map, FinalActivePlayerIndex, FinalActiveSquadIndex, FinalActiveSquad.CanMove)); } if (FinalActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Move) { HasAfterAttack = true; Map.CursorPosition = FinalActiveSquad.Position; AfterAttack.AddChoiceToCurrentPanel(new ActionPanelMovePart1(Map, FinalActivePlayerIndex, FinalActiveSquadIndex, FinalActiveSquad.Position, Map.CameraPosition, true)); } if (HasAfterAttack) { AfterAttack.AddChoiceToCurrentPanel(new ActionPanelWait(Map, FinalActiveSquad)); ListActionMenuChoice.Add(AfterAttack); } } }