public AnimationScreen(string AnimationPath, DeathmatchMap Map, Squad ActiveSquad, Squad EnemySquad, Attack ActiveAttack, BattleMap.SquadBattleResult BattleResult, AnimationUnitStats UnitStats, AnimationBackground ActiveTerrain, string ExtraText, bool IsLeftAttacking) : base(AnimationPath) { RequireFocus = false; RequireDrawFocus = false; IsOnTop = false; Random = new Random(); IsLoaded = false; this.Map = Map; this.AttackingSquad = ActiveSquad; this.EnemySquad = EnemySquad; this.ActiveAttack = ActiveAttack; this.BattleResult = BattleResult; this.UnitStats = UnitStats; ActiveAnimationBackground = ActiveTerrain; this.ExtraText = ExtraText; this.IsLeftAttacking = IsLeftAttacking; RightSquad = ActiveSquad; LeftSquad = EnemySquad; if (IsLeftAttacking) { RightSquad = EnemySquad; LeftSquad = ActiveSquad; } }
public override void Update(Microsoft.Xna.Framework.GameTime gameTime) { if (!IsInit) { IsInit = true; for (int P = 0; P < Map.ListPlayer.Count && (RightSquad == null || LeftSquad == null); P++) { for (int U = 0; U < Map.ListPlayer[P].ListSquad.Count && (RightSquad == null || LeftSquad == null); U++) { if (Map.ListPlayer[P].ListSquad[U].ID == _RightUnitID) { RightSquad = Map.ListPlayer[P].ListSquad[U]; Map.ActivePlayerIndex = P; Map.ActiveSquadIndex = U; } else if (Map.ListPlayer[P].ListSquad[U].ID == _LeftUnitID) { LeftSquad = Map.ListPlayer[P].ListSquad[U]; Map.TargetPlayerIndex = P; Map.TargetSquadIndex = U; } else { continue; } } } if (RightSquad == null || LeftSquad == null) { ExecuteEvent(this, 0); IsEnded = true; return; } BattleMap.SquadBattleResult RightUnitResult = new BattleMap.SquadBattleResult(); BattleMap.SquadBattleResult LeftUnitResult = new BattleMap.SquadBattleResult(); RightUnitResult.ArrayResult = new BattleResult[1] { new BattleResult() }; LeftUnitResult.ArrayResult = new BattleResult[1] { new BattleResult() }; RightUnitResult.ArrayResult[0].AttackDamage = _RightUnitAttackDamage; LeftUnitResult.ArrayResult[0].AttackDamage = _LeftUnitAttackDamage; Squad Attacker = RightSquad; Squad Defender = LeftSquad; //Play battle theme. if (Attacker.CurrentLeader.BattleTheme == null || Attacker.CurrentLeader.BattleThemeName != GameScreen.FMODSystem.sndActiveBGMName) { if (Attacker.CurrentLeader.BattleTheme != null) { GameScreen.FMODSystem.sndActiveBGM.Stop(); Attacker.CurrentLeader.BattleTheme.SetLoop(true); Attacker.CurrentLeader.BattleTheme.PlayAsBGM(); GameScreen.FMODSystem.sndActiveBGMName = Attacker.CurrentLeader.BattleThemeName; } } RightSquad.CurrentLeader.AttackIndex = 0; if (!string.IsNullOrWhiteSpace(AttackingUnitWeaponName)) { for (int A = 0; A < RightSquad.CurrentLeader.ListAttack.Count; ++A) { if (RightSquad.CurrentLeader.ListAttack[A].ItemName == AttackingUnitWeaponName) { RightSquad.CurrentLeader.AttackIndex = A; } } } LeftSquad.CurrentLeader.AttackIndex = 0; if (!string.IsNullOrWhiteSpace(AttackingUnitWeaponName)) { for (int A = 0; A < LeftSquad.CurrentLeader.ListAttack.Count; ++A) { if (LeftSquad.CurrentLeader.ListAttack[A].ItemName == DefendingUnitWeaponName) { LeftSquad.CurrentLeader.AttackIndex = A; } } } SquadBattleResult AttackingResult = Map.CalculateFinalHP(RightSquad, null, 0, FormationChoices.Focused, LeftSquad, null, Map.TargetPlayerIndex, Map.TargetSquadIndex, true, true); AttackingResult.ArrayResult[0].AttackMissed = false; AttackingResult.ArrayResult[0].AttackDamage = AttackingUnitAttackDamage; AttackingResult.ArrayResult[0].SetTarget(Map.TargetPlayerIndex, Map.TargetSquadIndex, 0, Map.TargetSquad.CurrentLeader); AnimationScreen.AnimationUnitStats UnitStats = new AnimationScreen.AnimationUnitStats(RightSquad, LeftSquad, true); if (IsCounterattack) { ListNextAnimationScreen = Map.GenerateNextAnimationScreens(RightSquad, new SupportSquadHolder(), LeftSquad, new SupportSquadHolder(), UnitStats, AnimationScreen.BattleAnimationTypes.RightConteredByLeft, AttackingResult, out _, null, out _, null); } else { ListNextAnimationScreen = Map.GenerateNextAnimationScreens(RightSquad, new SupportSquadHolder(), LeftSquad, new SupportSquadHolder(), UnitStats, AnimationScreen.BattleAnimationTypes.RightAttackLeft, AttackingResult, out _, null, out _, null); } Map.PushScreen(ListNextAnimationScreen[0]); } else { if (!Map.ListGameScreen.Contains(ListNextAnimationScreen[0])) { ListNextAnimationScreen.Remove(ListNextAnimationScreen[0]); if (ListNextAnimationScreen.Count > 0) { Map.PushScreen(ListNextAnimationScreen[0]); } else { ExecuteEvent(this, 0); IsEnded = true; } } } }