Exemple #1
0
        private List <LevelUpMenu> FinalizeBattle(Squad Attacker, int AttackerPlayerIndex,
                                                  Squad Defender, int DefenderPlayerIndex,
                                                  SquadBattleResult Result, List <Unit> ListDeadDefender)
        {
            List <LevelUpMenu> ListBattleRecap = new List <LevelUpMenu>();

            for (int U = 0; U < Attacker.UnitsAliveInSquad; U++)
            {
                LevelUpMenu BattleRecap = FinalizeBattle(Attacker[U], Attacker, AttackerPlayerIndex, Result.ArrayResult[U].Target, Defender, DefenderPlayerIndex, Result.ArrayResult[U], ListDeadDefender);
                if (BattleRecap != null)
                {
                    ListBattleRecap.Add(BattleRecap);
                }
            }

            if (!Attacker.ListAttackedTeam.Contains(ListPlayer[DefenderPlayerIndex].Team))
            {
                Attacker.ListAttackedTeam.Add(ListPlayer[DefenderPlayerIndex].Team);
            }

            if (!Defender.ListAttackedTeam.Contains(ListPlayer[AttackerPlayerIndex].Team))
            {
                Defender.ListAttackedTeam.Add(ListPlayer[AttackerPlayerIndex].Team);
            }

            return(ListBattleRecap);
        }
Exemple #2
0
        public override void DoUpdate(GameTime gameTime)
        {
            Map.CursorControl(ActiveInputManager);//Move the cursor
            Map.LayerManager.AddDrawablePoints(ListMVChoice, Color.FromNonPremultiplied(0, 128, 0, 190));

            if (ActiveInputManager.InputConfirmPressed())
            {
                //Find if a current player Unit is under the cursor.
                int CursorSelect = Map.CheckForSquadAtPosition(Map.ActivePlayerIndex, Map.CursorPosition, Vector3.Zero);

                if (CursorSelect >= 0 && ListMVPoints.Contains(Map.CursorPosition))
                {
                    bool CanRepair = false;

                    for (int U = Map.ListPlayer[Map.ActivePlayerIndex].ListSquad[CursorSelect].UnitsAliveInSquad - 1; U >= 0; --U)
                    {
                        if (Map.ListPlayer[Map.ActivePlayerIndex].ListSquad[CursorSelect][U].HP < Map.ListPlayer[Map.ActivePlayerIndex].ListSquad[CursorSelect][U].MaxHP)
                        {
                            Map.ListPlayer[Map.ActivePlayerIndex].ListSquad[CursorSelect][U].HealUnit(
                                (ActiveSquad.CurrentLeader.PilotLevel * 100) + (ActiveSquad.CurrentLeader.PilotSKL * 10));

                            CanRepair = true;
                        }
                    }

                    if (CanRepair)
                    {
                        LevelUpMenu BattleRecap = new LevelUpMenu(Map, ActiveSquad.CurrentLeader.Pilot, ActiveSquad.CurrentLeader, ActiveSquad, true);
                        BattleRecap.TotalExpGained += 25;
                        if (Constants.ShowBattleRecap)
                        {
                            Map.PushScreen(BattleRecap);
                        }
                        else
                        {
                            BattleRecap.LevelUp();
                        }
                        ActiveSquad.EndTurn();
                        RemoveAllSubActionPanels();
                    }
                }
            }
        }
Exemple #3
0
        private LevelUpMenu FinalizeBattle(Unit Attacker, Squad AttackerSquad, int AttackerPlayerIndex,
                                           Unit Defender, Squad DefenderSquad, int DefenderPlayerIndex,
                                           BattleResult Result, List <Unit> ListDeadDefender)
        {
            LevelUpMenu BattleRecap = null;

            if (Attacker.CurrentAttack != null && !ListDeadDefender.Contains(Result.Target))
            {
                FinalizeAttack(AttackerSquad, Attacker, Result);

                //Will Gains
                if (Result.Target.HP <= 0)
                {
                    if (AttackerPlayerIndex == 0)
                    {
                        int Money = 500;
                        Constants.Money += (int)(Money * Attacker.Boosts.MoneyMultiplier);
                    }

                    BattleRecap = new LevelUpMenu(this, Attacker.Pilot, Attacker, AttackerSquad, ListPlayer[AttackerPlayerIndex].IsPlayerControlled);
                    BattleRecap.TotalExpGained += (int)((Result.Target.Pilot.EXPValue + Result.Target.UnitStat.EXPValue) * Attacker.Boosts.EXPMultiplier);

                    ListDeadDefender.Add(Result.Target);

                    FinalizeDeath(AttackerSquad, AttackerPlayerIndex, DefenderSquad, DefenderPlayerIndex, Result.Target);
                    Attacker.PilotKills += 1;

                    for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++)
                    {
                        Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainDestroyedEnemy;
                    }

                    for (int U = 0; U < AttackerSquad.UnitsAliveInSquad; U++)
                    {
                        if (Attacker == AttackerSquad[U])
                        {
                            continue;
                        }

                        for (int C = 1; C < AttackerSquad[U].ArrayCharacterActive.Length; C++)
                        {
                            AttackerSquad[U].ArrayCharacterActive[C].Will += 2;
                        }
                    }
                }
                else if (Result.AttackMissed)
                {
                    for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++)
                    {
                        Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainMissedEnemy;
                    }

                    for (int C = 0; C < Result.Target.ArrayCharacterActive.Length; C++)
                    {
                        Result.Target.ArrayCharacterActive[C].Will += Result.Target.ArrayCharacterActive[C].Personality.WillGainEvaded;
                    }
                }
                else if (!Result.AttackMissed)
                {
                    for (int C = 0; C < Attacker.ArrayCharacterActive.Length; C++)
                    {
                        Attacker.ArrayCharacterActive[C].Will += Attacker.ArrayCharacterActive[C].Personality.WillGainHitEnemy;
                    }

                    for (int C = 0; C < Result.Target.ArrayCharacterActive.Length; C++)
                    {
                        Result.Target.ArrayCharacterActive[C].Will += Result.Target.ArrayCharacterActive[C].Personality.WillGainGotHit;
                    }
                }
            }

            return(BattleRecap);
        }
Exemple #4
0
        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);
            }
        }