public void ActivateAutomaticSkills(Squad ActiveSquad, Unit ActiveUnit, string SkillRequirementToActivate, Squad TargetSquad = null, Unit TargetUnit = null) { Character TargetPilot; if (TargetUnit != null) { TargetPilot = TargetUnit.Pilot; } else { TargetPilot = null; } GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, null, TargetSquad, TargetUnit, TargetPilot); // Character Skills for (int C = 0; C < ActiveUnit.ArrayCharacterActive.Length; C++) { GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, ActiveUnit.ArrayCharacterActive[C], TargetSquad, TargetUnit, TargetPilot); for (int S = 0; S < ActiveUnit.ArrayCharacterActive[C].ArrayPilotSkill.Length; S++) { BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayCharacterActive[C].ArrayPilotSkill[S]; ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate); } for (int S = 0; S < ActiveUnit.ArrayCharacterActive[C].ArrayRelationshipBonus.Length; S++) { BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayCharacterActive[C].ArrayRelationshipBonus[S]; ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate); } } GlobalBattleContext.SetContext(ActiveSquad, ActiveUnit, ActiveUnit.Pilot, TargetSquad, TargetUnit, TargetPilot); // Unit Abilities for (int S = 0; S < ActiveUnit.ArrayUnitAbility.Length; S++) { BaseAutomaticSkill ActiveSkill = ActiveUnit.ArrayUnitAbility[S]; ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate); } // Attack Attributes if (ActiveUnit.CurrentAttack != null) { for (int S = 0; S < ActiveUnit.CurrentAttack.ArrayAttackAttributes.Length; S++) { BaseAutomaticSkill ActiveSkill = ActiveUnit.CurrentAttack.ArrayAttackAttributes[S]; ActiveSkill.AddSkillEffectsToTarget(SkillRequirementToActivate); } } //Reset active effects in case an effect was removed. ActiveUnit.ExecuteSkillsEffects(); GlobalBattleContext.SetContext(null, null, null, TargetSquad, TargetUnit, TargetPilot); }
public void FinalizeBattle(Squad Attacker, SupportSquadHolder ActiveSquadSupport, int AttackerPlayerIndex, Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int DefenderPlayerIndex, SquadBattleResult ResultAttack, SquadBattleResult ResultDefend) { Squad Target = TargetSquad; if (TargetSquadSupport.ActiveSquadSupport != null) { Target = TargetSquadSupport.ActiveSquadSupport; //Remove 1 Support Defend. --TargetSquadSupport.ActiveSquadSupport.CurrentLeader.Boosts.SupportDefendModifier; } List <Unit> ListDeadDefender = new List <Unit>(); List <LevelUpMenu> ListBattleRecap = new List <LevelUpMenu>(); ListBattleRecap.AddRange(FinalizeBattle(Attacker, AttackerPlayerIndex, Target, DefenderPlayerIndex, ResultAttack, ListDeadDefender)); //Counter attack if (TargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack && TargetSquad.CurrentLeader.HP > 0) { ListBattleRecap.AddRange(FinalizeBattle(TargetSquad, DefenderPlayerIndex, Attacker, AttackerPlayerIndex, ResultDefend, new List <Unit>())); } //Support Attack if (ActiveSquadSupport.ActiveSquadSupport != null && Attacker.CurrentLeader.HP > 0 && TargetSquad.CurrentLeader.HP > 0) { //Remove 1 Support Defend. --ActiveSquadSupport.ActiveSquadSupport.CurrentLeader.Boosts.SupportAttackModifier; LevelUpMenu BattleRecap = FinalizeBattle(ActiveSquadSupport.ActiveSquadSupport.CurrentLeader, ActiveSquadSupport.ActiveSquadSupport, AttackerPlayerIndex, TargetSquad.CurrentLeader, TargetSquad, DefenderPlayerIndex, ResultAttack.ResultSupportAttack, ListDeadDefender); if (BattleRecap != null) { ListBattleRecap.Add(BattleRecap); } } #region Explosions //Explosion of death cutscene if (Attacker.CurrentLeader == null) { PushScreen(new BattleMapScreen.ExplosionCutscene(CenterCamera, this, Attacker)); } if (TargetSquad.CurrentLeader == null) { PushScreen(new BattleMapScreen.ExplosionCutscene(CenterCamera, this, TargetSquad)); } #endregion bool HasRecap = false; for (int R = ListBattleRecap.Count - 1; R >= 0; --R) { if (Constants.ShowBattleRecap && ListBattleRecap[R].IsHuman) { PushScreen(ListBattleRecap[R]); if (!HasRecap) { ListBattleRecap[R].SetBattleContent(true, Attacker, ActiveSquadSupport, DefenderPlayerIndex, TargetSquad, TargetSquadSupport); } else { ListBattleRecap[R].SetBattleContent(false, Attacker, ActiveSquadSupport, DefenderPlayerIndex, TargetSquad, TargetSquadSupport); } HasRecap = true; } else { ListBattleRecap[R].LevelUp(); } } if (!HasRecap) { GlobalBattleContext.SetContext(ActiveSquad, ActiveSquad.CurrentLeader, ActiveSquad.CurrentLeader.Pilot, TargetSquad, TargetSquad.CurrentLeader, TargetSquad.CurrentLeader.Pilot, ActiveParser); UpdateMapEvent(EventTypeOnBattle, 1); GlobalBattleContext.SetContext(null, null, null, null, null, null, ActiveParser); //Don't update the leader until after the events are processed. (If a battle map event try to read the leader of a dead unit it will crash on a null pointer as dead units have no leader) Attacker.UpdateSquad(); if (ActiveSquadSupport != null && ActiveSquadSupport.ActiveSquadSupport != null) { ActiveSquadSupport.ActiveSquadSupport.UpdateSquad(); } TargetSquad.UpdateSquad(); if (TargetSquadSupport != null && TargetSquadSupport.ActiveSquadSupport != null) { TargetSquadSupport.ActiveSquadSupport.UpdateSquad(); } GameRule.OnSquadDefeated(DefenderPlayerIndex, TargetSquad); } }