Пример #1
0
        public override void DoRead(ByteReader BR)
        {
            ActivePlayerIndex  = BR.ReadInt32();
            ActiveSquadIndex   = BR.ReadInt32();
            ActiveSquad        = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            ActiveSquadSupport = new SupportSquadHolder();
            ActiveSquad.CurrentLeader.BattleDefenseChoice = (Unit.BattleDefenseChoices)BR.ReadByte();
            ActiveSquad.CurrentLeader.AttackIndex         = BR.ReadInt32();
            ListAttackActiveSquad = ActiveSquad.CurrentLeader.ListAttack;
            if (ActiveSquadSupport.ActiveSquadSupport != null)
            {
                ListAttackActiveSquadSupport = ActiveSquadSupport.ActiveSquadSupport.CurrentLeader.ListAttack;
            }
            else
            {
                ListAttackActiveSquadSupport = new List <Attack>();
            }

            TargetPlayerIndex  = BR.ReadInt32();
            TargetSquadIndex   = BR.ReadInt32();
            TargetSquad        = Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex];
            TargetSquadSupport = new SupportSquadHolder();
            TargetSquad.CurrentLeader.BattleDefenseChoice = (Unit.BattleDefenseChoices)BR.ReadByte();
            TargetSquad.CurrentLeader.AttackIndex         = BR.ReadInt32();

            Map.BattleMenuStage = (BattleMenuStages)BR.ReadByte();
        }
        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>();

            FinalizeBattle(Attacker, AttackerPlayerIndex, Target, DefenderPlayerIndex, ResultAttack, ListDeadDefender);

            //Counter attack
            if (TargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack && TargetSquad.CurrentLeader.HP > 0)
            {
                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;

                FinalizeBattle(ActiveSquadSupport.ActiveSquadSupport.CurrentLeader, ActiveSquadSupport.ActiveSquadSupport, AttackerPlayerIndex,
                               TargetSquad.CurrentLeader, TargetSquad, DefenderPlayerIndex, ResultAttack.ResultSupportAttack, ListDeadDefender);
            }

            Attacker.UpdateSquad();
            if (ActiveSquadSupport != null && ActiveSquadSupport.ActiveSquadSupport != null)
            {
                ActiveSquadSupport.ActiveSquadSupport.UpdateSquad();
            }
            TargetSquad.UpdateSquad();
            if (TargetSquadSupport != null && TargetSquadSupport.ActiveSquadSupport != null)
            {
                TargetSquadSupport.ActiveSquadSupport.UpdateSquad();
            }

            #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

            UpdateMapEvent(EventTypeOnBattle, 1);
        }
        public void UpdateUnitDisplay()
        {
            if (UnitDisplayCounter < TimeToDisplay)
            {
                ++UnitDisplayCounter;

                if (UnitDisplayCounter == TimeToDisplay)
                {
                    UnitDisplayCounter = 0;
                    int SquadIndex = -1;

                    for (int P = 0; P < Map.ListPlayer.Count && SquadIndex == -1; P++)
                    {
                        SquadIndex = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero);
                        if (SquadIndex >= 0)
                        {
                            if (P == Map.ActivePlayerIndex)
                            {
                                BoxColor = Color.Green;
                            }
                            else
                            {
                                BoxColor = Color.Red;
                            }

                            Squad DefendingSquad = Map.ListPlayer[P].ListSquad[SquadIndex];
                            Map.TargetPlayerIndex = P;
                            Map.TargetSquadIndex  = SquadIndex;

                            if (ActiveAttack != null)
                            {
                                SupportSquadHolder ActiveSquadSupport = new SupportSquadHolder();
                                SupportSquadHolder TargetSquadSupport = new SupportSquadHolder();

                                ActiveSquadSupport.PrepareAttackSupport(Map, PlayerIndex, ActiveSquad, P, SquadIndex);
                                TargetSquadSupport.PrepareDefenceSupport(Map, P, DefendingSquad);

                                BattleResult = Map.CalculateFinalHP(ActiveSquad, ActiveSquadSupport.ActiveSquadSupport, Map.ActivePlayerIndex,
                                                                    FormationChoices.Focused,
                                                                    DefendingSquad, TargetSquadSupport.ActiveSquadSupport,
                                                                    P, SquadIndex, true, false);
                            }
                            else
                            {
                                BattleResult.ArrayResult = new BattleResult[DefendingSquad.UnitsAliveInSquad];
                                for (int U = 0; U < DefendingSquad.UnitsAliveInSquad; ++U)
                                {
                                    BattleResult.ArrayResult[U] = new BattleResult();
                                    BattleResult.ArrayResult[U].SetTarget(P, SquadIndex, U, DefendingSquad[U]);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        int ActiveSquadSupportIndexOld;//Index of the support squad used for reset.

        public ActionPanelHumanAttack(DeathmatchMap Map, Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, int ActivePlayerIndex,
                                      Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int TargetPlayerIndex)
            : base("Human Attack", Map, false)
        {
            this.ActiveSquad        = ActiveSquad;
            this.ActiveSquadSupport = ActiveSquadSupport;
            this.ActivePlayerIndex  = ActivePlayerIndex;
            this.TargetSquad        = TargetSquad;
            this.TargetSquadSupport = TargetSquadSupport;
            this.TargetPlayerIndex  = TargetPlayerIndex;
        }
Пример #5
0
        public override void OnSelect()
        {
            TargetSquad           = Map.ListPlayer[Target.Item1].ListSquad[Target.Item2];
            Map.TargetPlayerIndex = Target.Item1;

            AITimer = AITimerBase;
            PrepareToAttack();

            ActiveSquadSupport = new SupportSquadHolder();
            ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, TargetSquad);
            TargetSquadSupport = new SupportSquadHolder();
            TargetSquadSupport.PrepareDefenceSupport(Map, Target.Item1, TargetSquad);
        }
 public EndBattleAnimationScreen(DeathmatchMap Map, Squad Attacker, SupportSquadHolder ActiveSquadSupport, int AttackerPlayerIndex,
                                 Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int DefenderPlayerIndex, SquadBattleResult ResultAttack, SquadBattleResult ResultDefend)
 {
     this.Map                 = Map;
     this.Attacker            = Attacker;
     this.ActiveSquadSupport  = ActiveSquadSupport;
     this.AttackerPlayerIndex = AttackerPlayerIndex;
     this.TargetSquad         = TargetSquad;
     this.TargetSquadSupport  = TargetSquadSupport;
     this.DefenderPlayerIndex = DefenderPlayerIndex;
     this.ResultAttack        = ResultAttack;
     this.ResultDefend        = ResultDefend;
 }
Пример #7
0
        public override void DoRead(ByteReader BR)
        {
            ActivePlayerIndex = BR.ReadInt32();
            ActiveSquadIndex  = BR.ReadInt32();
            Target            = new Tuple <int, int>(BR.ReadInt32(), BR.ReadInt32());

            ActiveSquad           = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            TargetSquad           = Map.ListPlayer[Target.Item1].ListSquad[Target.Item2];
            Map.TargetPlayerIndex = Target.Item1;

            ActiveSquadSupport = new SupportSquadHolder();
            ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, Target.Item1, Target.Item2);
            TargetSquadSupport = new SupportSquadHolder();
            TargetSquadSupport.PrepareDefenceSupport(Map, Target.Item1, TargetSquad);
        }
Пример #8
0
        public ActionPanelHumanDefend(DeathmatchMap Map, int ActivePlayerIndex, int ActiveSquadIndex, SupportSquadHolder ActiveSquadSupport,
                                      int TargetPlayerIndex, int TargetSquadIndex, SupportSquadHolder TargetSquadSupport)
            : base(PanelName, Map, Map.ListPlayer[Map.TargetPlayerIndex].InputManager, false)
        {
            this.ActivePlayerIndex  = ActivePlayerIndex;
            this.ActiveSquadIndex   = ActiveSquadIndex;
            this.ActiveSquadSupport = ActiveSquadSupport;

            this.TargetPlayerIndex  = TargetPlayerIndex;
            this.TargetSquadIndex   = TargetSquadIndex;
            this.TargetSquadSupport = TargetSquadSupport;

            ActiveSquad           = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            TargetSquad           = Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex];
            ListAttackTargetSquad = TargetSquad.CurrentLeader.ListAttack;
        }
Пример #9
0
        public void InitPlayerDefence(Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, int AttackerPlayerIndex, Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int DefenderPlayerIndex)
        {
            //Play battle theme.
            if (TargetSquad.CurrentLeader.BattleTheme == null || TargetSquad.CurrentLeader.BattleThemeName != FMODSystem.sndActiveBGMName)
            {
                if (TargetSquad.CurrentLeader.BattleTheme != null)
                {
                    if (FMODSystem.sndActiveBGM != null)
                    {
                        FMODSystem.sndActiveBGM.Stop();
                    }

                    TargetSquad.CurrentLeader.BattleTheme.SetLoop(true);
                    TargetSquad.CurrentLeader.BattleTheme.PlayAsBGM();
                    FMODSystem.sndActiveBGMName = TargetSquad.CurrentLeader.BattleThemeName;
                }
            }

            InitPlayerBattle(ActiveSquad, ActiveSquadSupport, AttackerPlayerIndex, TargetSquad, TargetSquadSupport, DefenderPlayerIndex, false);
        }
Пример #10
0
        public void SetBattleContent(bool UpdateBattleEventsOnClose, Squad Attacker, SupportSquadHolder ActiveSquadSupport, int TargetSquadPlayerIndex, Squad TargetSquad, SupportSquadHolder TargetSquadSupport)
        {
            this.UpdateBattleEventsOnClose = UpdateBattleEventsOnClose;
            this.Attacker               = Attacker;
            this.ActiveSquadSupport     = ActiveSquadSupport;
            this.TargetSquadPlayerIndex = TargetSquadPlayerIndex;
            this.TargetSquad            = TargetSquad;
            this.TargetSquadSupport     = TargetSquadSupport;

            Squad Enemy;

            if (OwnerSquad == Attacker)
            {
                Enemy = TargetSquad;
            }
            else
            {
                Enemy = Attacker;
            }

            foreach (string PartDropPath in Enemy.ListParthDrop)
            {
                string[] PartByType = PartDropPath.Split('/');
                ListDropPart.Add(PartByType[PartByType.Length - 1]);
                if (SystemList.ListPart.ContainsKey(PartDropPath))
                {
                    SystemList.ListPart[PartDropPath].Quantity++;
                }
                else
                {
                    if (PartByType[0] == "Standard Parts")
                    {
                        SystemList.ListPart.Add(PartDropPath, new UnitStandardPart("Content/Units/" + PartDropPath + ".pep", Map.DicRequirement, Map.DicEffect, Map.DicAutomaticSkillTarget));
                    }
                    else if (PartByType[0] == "Consumable Parts")
                    {
                        SystemList.ListPart.Add(PartDropPath, new UnitConsumablePart("Content/Units/" + PartDropPath + ".pep", Map.DicRequirement, Map.DicEffect, Map.DicAutomaticSkillTarget, Map.DicManualSkillTarget));
                    }
                }
            }
        }
Пример #11
0
        public ActionPanelStartBattle(DeathmatchMap Map, int ActivePlayerIndex, int ActiveSquadIndex, SupportSquadHolder ActiveSquadSupport,
                                      int TargetPlayerIndex, int TargetSquadIndex, SupportSquadHolder TargetSquadSupport, bool IsDefending)
            : base(PanelName, Map, false)
        {
            this.ActivePlayerIndex  = ActivePlayerIndex;
            this.ActiveSquadIndex   = ActiveSquadIndex;
            this.ActiveSquadSupport = ActiveSquadSupport;

            this.TargetPlayerIndex  = TargetPlayerIndex;
            this.TargetSquadIndex   = TargetSquadIndex;
            this.TargetSquadSupport = TargetSquadSupport;

            this.IsDefending = IsDefending;

            SendBackToSender = true;

            ActiveSquad = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            TargetSquad = Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex];

            ListNextAnimationScreen = new List <GameScreen>();
        }
Пример #12
0
        public void GetLeftRightSquads(bool IsActiveSquadOnRight,
                                       Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, Squad TargetSquad, SupportSquadHolder TargetSquadSupport,
                                       out Squad NonDemoRightSquad, out Squad NonDemoRightSupport,
                                       out Squad NonDemoLeftSquad, out Squad NonDemoLeftSupport)
        {
            NonDemoLeftSupport  = null;
            NonDemoRightSupport = null;

            if (IsActiveSquadOnRight)
            {
                NonDemoRightSquad = ActiveSquad;
                NonDemoLeftSquad  = TargetSquad;

                if (ActiveSquadSupport.ActiveSquadSupport != null)
                {
                    NonDemoRightSupport = ActiveSquadSupport.ActiveSquadSupport;
                }
                if (TargetSquadSupport.ActiveSquadSupport != null)
                {
                    NonDemoLeftSupport = TargetSquadSupport.ActiveSquadSupport;
                }
            }
            else
            {
                NonDemoRightSquad = TargetSquad;
                NonDemoLeftSquad  = ActiveSquad;

                if (TargetSquadSupport != null)
                {
                    NonDemoRightSupport = TargetSquadSupport.ActiveSquadSupport;
                }
                if (ActiveSquadSupport.ActiveSquadSupport != null)
                {
                    NonDemoLeftSupport = ActiveSquadSupport.ActiveSquadSupport;
                }
            }
        }
Пример #13
0
        public ActionPanelHumanAttack(DeathmatchMap Map, int ActivePlayerIndex, int ActiveSquadIndex, SupportSquadHolder ActiveSquadSupport,
                                      int TargetPlayerIndex, int TargetSquadIndex, SupportSquadHolder TargetSquadSupport)
            : base(PanelName, Map, false)
        {
            this.ActivePlayerIndex  = ActivePlayerIndex;
            this.ActiveSquadIndex   = ActiveSquadIndex;
            this.ActiveSquadSupport = ActiveSquadSupport;

            this.TargetPlayerIndex  = TargetPlayerIndex;
            this.TargetSquadIndex   = TargetSquadIndex;
            this.TargetSquadSupport = TargetSquadSupport;

            ActiveSquad           = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            ListAttackActiveSquad = ActiveSquad.CurrentLeader.ListAttack;
            if (ActiveSquadSupport.ActiveSquadSupport != null)
            {
                ListAttackActiveSquadSupport = ActiveSquadSupport.ActiveSquadSupport.CurrentLeader.ListAttack;
            }
            else
            {
                ListAttackActiveSquadSupport = new List <Attack>();
            }
            TargetSquad = Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex];
        }
Пример #14
0
        public override void DoUpdate(GameTime gameTime)
        {
            Map.LayerManager.AddDrawablePoints(ListAttackTerrain, Color.FromNonPremultiplied(255, 0, 0, 190));

            if (ActiveInputManager.InputConfirmPressed())
            {
                int TargetSelect = 0;
                //Verify if the cursor is over one of the possible MV position.
                while ((Map.CursorPosition.X != ListAttackChoice[TargetSelect].X || Map.CursorPosition.Y != ListAttackChoice[TargetSelect].Y) &&
                       ++TargetSelect < ListAttackChoice.Count)
                {
                    ;
                }
                //If nothing was found.
                if (TargetSelect >= ListAttackChoice.Count)
                {
                    return;
                }

                Map.TargetSquadIndex = -1;

                for (int P = 0; P < Map.ListPlayer.Count; P++)
                {
                    //Find if a Unit is under the cursor.
                    TargetSelect = Map.CheckForSquadAtPosition(P, Map.CursorPosition, Vector3.Zero);
                    //If one was found.
                    if (TargetSelect >= 0)
                    {
                        if (Map.ListPlayer[ActivePlayerIndex].Team != Map.ListPlayer[P].Team)//If it's an ennemy.
                        {
                            ActiveSquad.CurrentLeader.CurrentAttack.UpdateAttack(ActiveSquad.CurrentLeader, ActiveSquad.Position, Map.CursorPosition,
                                                                                 ActiveSquad.ArrayMapSize, Map.ListPlayer[P].ListSquad[TargetSelect].CurrentMovement, ActiveSquad.CanMove);

                            if (!ActiveSquad.CurrentLeader.CurrentAttack.CanAttack)
                            {
                                Map.sndDeny.Play();
                                return;
                            }

                            Map.PrepareSquadsForBattle(ActivePlayerIndex, ActiveSquadIndex, P, TargetSelect);

                            SupportSquadHolder ActiveSquadSupport = new SupportSquadHolder();
                            ActiveSquadSupport.PrepareAttackSupport(Map, ActivePlayerIndex, ActiveSquad, P, TargetSelect);

                            SupportSquadHolder TargetSquadSupport = new SupportSquadHolder();
                            TargetSquadSupport.PrepareDefenceSupport(Map, P, Map.ListPlayer[P].ListSquad[TargetSelect]);

                            Map.ComputeTargetPlayerDefence(ActivePlayerIndex, ActiveSquadIndex, ActiveSquadSupport, P, TargetSelect, TargetSquadSupport);

                            break;
                        }
                    }
                }
                Map.sndConfirm.Play();
            }
            else
            {
                bool CursorMoved = Map.UpdateMapNavigation(ActiveInputManager);
                if (CursorMoved)
                {
                    BattlePreview = new BattlePreviewer(Map, ActivePlayerIndex, ActiveSquadIndex, ActiveSquad.CurrentLeader.CurrentAttack);
                }
                BattlePreview.UpdateUnitDisplay();
            }
        }
Пример #15
0
        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);
                    }
                }
            }
        }
Пример #16
0
        public void InitPlayerBattle(Squad ActiveSquad, SupportSquadHolder ActiveSquadSupport, int AttackerPlayerIndex,
                                     Squad TargetSquad, SupportSquadHolder TargetSquadSupport, int DefenderPlayerIndex,
                                     bool IsActiveSquadOnRight)
        {
            if (TargetSquad.CurrentLeader.Boosts.AttackFirstModifier && !ActiveSquad.CurrentLeader.Boosts.AttackFirstModifier)
            {
                Squad ActiveSquadTemp = ActiveSquad;
                SupportSquadHolder ActiveSquadSupportTemp = ActiveSquadSupport;
                int AttackerPlayerIndexTemp = AttackerPlayerIndex;

                ActiveSquad         = TargetSquad;
                ActiveSquadSupport  = TargetSquadSupport;
                AttackerPlayerIndex = DefenderPlayerIndex;

                TargetSquad         = ActiveSquadTemp;
                TargetSquadSupport  = ActiveSquadSupportTemp;
                DefenderPlayerIndex = AttackerPlayerIndexTemp;
            }

            ActivePlayerIndex = AttackerPlayerIndex;
            ActiveSquadIndex  = ListPlayer[AttackerPlayerIndex].ListSquad.IndexOf(ActiveSquad);
            TargetPlayerIndex = DefenderPlayerIndex;
            TargetSquadIndex  = ListPlayer[TargetPlayerIndex].ListSquad.IndexOf(TargetSquad);

            bool ShowAnimation = Constants.ShowAnimation && ActiveSquad.CurrentLeader.CurrentAttack.Animations.Start.AnimationName != null;

            ListNextAnimationScreen.Clear();
            NonDemoScreen.ListNonDemoBattleFrame.Clear();
            ListActionMenuChoice.RemoveAllSubActionPanels();

            SquadBattleResult AttackingResult = CalculateFinalHP(ActiveSquad, ActiveSquadSupport.ActiveSquadSupport, ActivePlayerIndex,
                                                                 BattleMenuOffenseFormationChoice, TargetSquad, TargetSquadSupport.ActiveSquadSupport, TargetPlayerIndex, true, true);

            AnimationScreen.AnimationUnitStats UnitStats = new AnimationScreen.AnimationUnitStats(ActiveSquad, TargetSquad, IsActiveSquadOnRight);
            SquadBattleResult DefendingResult            = new SquadBattleResult(new BattleResult[1] {
                new BattleResult()
            });

            if (ShowAnimation)
            {
                if (IsActiveSquadOnRight)
                {
                    GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.RightAttackLeft, AttackingResult);
                }
                else
                {
                    GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.LeftAttackRight, AttackingResult);
                }
            }

            if (AttackingResult.ArrayResult[0].Target.ComputeRemainingHPAfterDamage(AttackingResult.ArrayResult[0].AttackDamage) > 0)
            {
                //Counter.
                if (TargetSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack)
                {
                    DefendingResult = CalculateFinalHP(TargetSquad, null, TargetPlayerIndex,
                                                       BattleMenuDefenseFormationChoice, ActiveSquad, null, ActivePlayerIndex, true, true);

                    if (ShowAnimation)
                    {
                        if (IsActiveSquadOnRight)
                        {
                            GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.RightConteredByLeft, DefendingResult);
                        }
                        else
                        {
                            GenerateNextAnimationScreens(ActiveSquad, ActiveSquadSupport, TargetSquad, TargetSquadSupport, UnitStats, AnimationScreen.BattleAnimationTypes.LeftConteredByRight, DefendingResult);
                        }
                    }
                }
            }

            if (ShowAnimation)
            {
                PushScreen(ListNextAnimationScreen[0]);
                ListNextAnimationScreen.RemoveAt(0);
                ListNextAnimationScreen.Add(new EndBattleAnimationScreen(this, ActiveSquad, ActiveSquadSupport, AttackerPlayerIndex,
                                                                         TargetSquad, TargetSquadSupport, DefenderPlayerIndex, AttackingResult, DefendingResult));
            }
            else
            {
                NonDemoScreen.InitNonDemo(ActiveSquad, ActiveSquadSupport, AttackerPlayerIndex, AttackingResult, BattleMenuOffenseFormationChoice,
                                          TargetSquad, TargetSquadSupport, DefenderPlayerIndex, DefendingResult, BattleMenuDefenseFormationChoice, IsActiveSquadOnRight);

                NonDemoScreen.Alive = true;
                ListGameScreen.Insert(0, NonDemoScreen);
            }

            //AttackingSquad Activations.
            for (int U = 0; U < ActiveSquad.UnitsAliveInSquad; U++)
            {
                ActiveSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }
            //DefendingSquad Activations.
            for (int U = 0; U < TargetSquad.UnitsAliveInSquad; U++)
            {
                TargetSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeBattle);
            }

            FinalizeMovement(ActiveSquad, (int)GetTerrain(ActiveSquad).MovementCost);
            ActiveSquad.EndTurn();

            bool HasAfterAttack = false;
            ActionPanelDeathmatch AfterAttack = new ActionPanelMainMenu(this, ActiveSquad, AttackerPlayerIndex);

            if (ActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Attack)
            {
                HasAfterAttack = true;
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelAttackPart1(ActiveSquad.CanMove, ActiveSquad, AttackerPlayerIndex, this));
            }

            if (ActiveSquad.CurrentLeader.Boosts.PostAttackModifier.Move)
            {
                HasAfterAttack = true;
                CursorPosition = ActiveSquad.Position;
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelMovePart1(this, ActiveSquad.Position, CameraPosition, ActiveSquad, AttackerPlayerIndex, true));
            }

            if (HasAfterAttack)
            {
                AfterAttack.AddChoiceToCurrentPanel(new ActionPanelWait(this, ActiveSquad));
                ListActionMenuChoice.Add(AfterAttack);
            }
        }
Пример #17
0
        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);
                }
            }
        }
Пример #18
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);
            }
        }
Пример #19
0
        public override void DoRead(ByteReader BR)
        {
            ActivePlayerIndex  = BR.ReadInt32();
            ActiveSquadIndex   = BR.ReadInt32();
            ActiveSquad        = Map.ListPlayer[ActivePlayerIndex].ListSquad[ActiveSquadIndex];
            ActiveSquadSupport = new SupportSquadHolder();
            ActiveSquad.CurrentLeader.BattleDefenseChoice = (Unit.BattleDefenseChoices)BR.ReadByte();
            ActiveSquad.CurrentLeader.AttackIndex         = BR.ReadInt32();

            TargetPlayerIndex  = BR.ReadInt32();
            TargetSquadIndex   = BR.ReadInt32();
            TargetSquad        = Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex];
            TargetSquadSupport = new SupportSquadHolder();
            TargetSquad.CurrentLeader.BattleDefenseChoice = (Unit.BattleDefenseChoices)BR.ReadByte();
            TargetSquad.CurrentLeader.AttackIndex         = BR.ReadInt32();

            IsDefending = BR.ReadBoolean();

            Map.BattleMenuStage = (BattleMenuStages)BR.ReadByte();

            if (Map.IsServer)
            {
            }
            else
            {
                int AttackingResultArrayResultLength = BR.ReadInt32();
                AttackingResult.ArrayResult = new BattleResult[AttackingResultArrayResultLength];

                for (int R = 0; R < AttackingResultArrayResultLength; ++R)
                {
                    AttackingResult.ArrayResult[R]          = new BattleResult();
                    AttackingResult.ArrayResult[R].Accuracy = BR.ReadInt32();
                    AttackingResult.ArrayResult[R].AttackAttackerFinalEN = BR.ReadInt32();
                    AttackingResult.ArrayResult[R].AttackDamage          = BR.ReadInt32();
                    AttackingResult.ArrayResult[R].AttackMissed          = BR.ReadBoolean();
                    AttackingResult.ArrayResult[R].AttackShootDown       = BR.ReadBoolean();
                    AttackingResult.ArrayResult[R].AttackSwordCut        = BR.ReadBoolean();
                    AttackingResult.ArrayResult[R].AttackWasCritical     = BR.ReadBoolean();
                    AttackingResult.ArrayResult[R].Barrier = BR.ReadString();
                    AttackingResult.ArrayResult[R].Shield  = BR.ReadBoolean();

                    int TargetPlayerIndex = BR.ReadInt32();
                    int TargetSquadIndex  = BR.ReadInt32();
                    int TargetUnitIndex   = BR.ReadInt32();

                    AttackingResult.ArrayResult[R].TargetPlayerIndex = TargetPlayerIndex;
                    AttackingResult.ArrayResult[R].TargetSquadIndex  = TargetSquadIndex;
                    AttackingResult.ArrayResult[R].TargetUnitIndex   = TargetUnitIndex;

                    AttackingResult.ArrayResult[R].SetTarget(TargetPlayerIndex, TargetSquadIndex, TargetUnitIndex, Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex][TargetUnitIndex]);
                }

                int DefendingResultArrayResultLength = BR.ReadInt32();
                DefendingResult.ArrayResult = new BattleResult[DefendingResultArrayResultLength];

                for (int R = 0; R < DefendingResultArrayResultLength; ++R)
                {
                    DefendingResult.ArrayResult[R]          = new BattleResult();
                    DefendingResult.ArrayResult[R].Accuracy = BR.ReadInt32();
                    DefendingResult.ArrayResult[R].AttackAttackerFinalEN = BR.ReadInt32();
                    DefendingResult.ArrayResult[R].AttackDamage          = BR.ReadInt32();
                    DefendingResult.ArrayResult[R].AttackMissed          = BR.ReadBoolean();
                    DefendingResult.ArrayResult[R].AttackShootDown       = BR.ReadBoolean();
                    DefendingResult.ArrayResult[R].AttackSwordCut        = BR.ReadBoolean();
                    DefendingResult.ArrayResult[R].AttackWasCritical     = BR.ReadBoolean();
                    DefendingResult.ArrayResult[R].Barrier = BR.ReadString();
                    DefendingResult.ArrayResult[R].Shield  = BR.ReadBoolean();

                    int TargetPlayerIndex = BR.ReadInt32();
                    int TargetSquadIndex  = BR.ReadInt32();
                    int TargetUnitIndex   = BR.ReadInt32();

                    DefendingResult.ArrayResult[R].TargetPlayerIndex = TargetPlayerIndex;
                    DefendingResult.ArrayResult[R].TargetSquadIndex  = TargetSquadIndex;
                    DefendingResult.ArrayResult[R].TargetUnitIndex   = TargetUnitIndex;

                    DefendingResult.ArrayResult[R].SetTarget(TargetPlayerIndex, TargetSquadIndex, TargetUnitIndex, Map.ListPlayer[TargetPlayerIndex].ListSquad[TargetSquadIndex][TargetUnitIndex]);
                }
            }

            if (IsDefending || Map.ListPlayer[TargetPlayerIndex].IsPlayerControlled)
            {
                InitPlayerDefence();
            }
            else
            {
                InitPlayerAttack();
                ActiveSquad.CurrentLeader.UpdateSkillsLifetime(SkillEffect.LifetimeTypeOnAction);
            }
        }
Пример #20
0
        public void BattleSumaryDefenceDraw(CustomSpriteBatch g,
                                            int AttackingPlayerIndex, int AttackingSquadIndex, SupportSquadHolder ActiveSquadSupport,
                                            int DefendingPlayerIndex, int DefendingSquadIndex, List <Attack> ListAttackDefendngSquad, SupportSquadHolder TargetSquadSupport)
        {
            Squad AttackingSquad = ListPlayer[AttackingPlayerIndex].ListSquad[AttackingSquadIndex];
            Squad DefendingSquad = ListPlayer[DefendingPlayerIndex].ListSquad[DefendingSquadIndex];

            g.Draw(sprBattleMenuBackground, new Rectangle(0, 0, Constants.Width, Constants.Height), null, Color.White);
            BattleSumaryDrawSquadLeft(g, AttackingSquad, BattleMenuOffenseFormationChoice, ActiveSquadSupport.ActiveSquadSupport);

            BattleSumaryDrawSquadRight(g, DefendingSquad, BattleMenuDefenseFormationChoice);

            if (DefendingSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack)
            {
                int AttackDamage = DamageFormula(DefendingSquad.CurrentLeader, DefendingSquad, 1f,
                                                 AttackingPlayerIndex, AttackingSquadIndex, 0,
                                                 AttackingSquad.CurrentLeader.BattleDefenseChoice, false)
                                   .AttackDamage;

                g.DrawString(fntFinlanderFont, AttackDamage.ToString() + "( " + (int)(AttackDamage * 1.2) + " )",
                             new Vector2(Constants.Width - 300, 230), Color.White);
            }

            if (AttackingSquad.CurrentLeader.BattleDefenseChoice == Unit.BattleDefenseChoices.Attack)
            {
                int AttackDamage = DamageFormula(AttackingSquad.CurrentLeader, AttackingSquad, 1f,
                                                 DefendingPlayerIndex, DefendingSquadIndex, 0,
                                                 DefendingSquad.CurrentLeader.BattleDefenseChoice, false)
                                   .AttackDamage;

                g.DrawString(fntFinlanderFont, AttackDamage.ToString() + "( " + (int)(AttackDamage * 1.2) + " )",
                             new Vector2(20, 230), Color.White);
            }

            if (TargetSquadSupport.ActiveSquadSupport != null)
            {
                DrawBox(g, new Vector2(325, 370), 70, 65, Color.Blue);
                DrawBox(g, new Vector2(395, 370), 240, 65, Color.Blue);
                g.DrawString(fntFinlanderFont, TargetSquadSupport.ActiveSquadSupport.CurrentLeader.UnitStat.Name, new Vector2(405, 375), Color.White);
                g.DrawString(fntFinlanderFont, "Support Defense", new Vector2(405, 397), Color.White);
                //Draw remaining supports
                g.DrawStringMiddleAligned(fntFinlanderFont, TargetSquadSupport.ActiveSquadSupport.CurrentLeader.Boosts.SupportDefendModifier + "/" + TargetSquadSupport.ActiveSquadSupport.CurrentLeader.Boosts.SupportDefendModifierMax,
                                          new Vector2(353, 390), Color.FromNonPremultiplied(0x00, 0xc6, 0xff, 255));
            }

            //Player side is always on the right.
            BattleSumaryDraw(g, DefendingSquad, ListAttackDefendngSquad);

            switch (BattleMenuStage)
            {
            case BattleMenuStages.ChooseSupport:
                DrawBox(g, new Vector2(0, 0), Constants.Width, 30, Color.Black);
                g.DrawStringMiddleAligned(fntFinlanderFont, "Select Support", new Vector2(Constants.Width / 2, 0), Color.Yellow);
                DrawBox(g, new Vector2(0, 30), Constants.Width, Constants.Height - 30, Color.White);
                DrawBox(g, new Vector2(45, 40), 550, 40, Color.Blue);
                g.DrawStringMiddleAligned(fntFinlanderFont, "No Support", new Vector2(Constants.Width / 2, 45), Color.White);

                int StartY = 90;
                for (int S = 0; S < TargetSquadSupport.Count; S++)
                {
                    Unit ActiveSupportUnit = TargetSquadSupport[S].CurrentLeader;
                    DrawBox(g, new Vector2(35, StartY), 580, 75, Color.Blue);
                    g.DrawString(fntFinlanderFont, "Support", new Vector2(45, StartY + 5), Color.White);
                    g.DrawString(fntFinlanderFont, ActiveSupportUnit.Boosts.SupportDefendModifier + "/" + ActiveSupportUnit.Boosts.SupportDefendModifierMax, new Vector2(45, StartY + 35), Color.White);
                    g.Draw(ActiveSupportUnit.SpriteMap, new Vector2(200, StartY + 10), Color.White);
                    g.DrawString(fntFinlanderFont, ActiveSupportUnit.UnitStat.Name, new Vector2(245, StartY + 5), Color.White);
                    g.DrawString(fntFinlanderFont, ActiveSupportUnit.PilotName, new Vector2(245, StartY + 35), Color.White);
                    g.DrawString(fntFinlanderFont, "LVL", new Vector2(475, StartY + 5), Color.White);
                    g.DrawString(fntFinlanderFont, "Will", new Vector2(475, StartY + 35), Color.White);

                    g.DrawStringRightAligned(fntFinlanderFont, ActiveSupportUnit.PilotLevel.ToString(), new Vector2(600, StartY + 5), Color.White);
                    g.DrawStringRightAligned(fntFinlanderFont, ActiveSupportUnit.PilotMorale.ToString(), new Vector2(600, StartY + 35), Color.White);

                    StartY += 90;
                }
                if (TargetSquadSupport.ActiveSquadSupportIndex >= 0)
                {
                    g.Draw(sprPixel, new Rectangle(35, 90 + 90 * TargetSquadSupport.ActiveSquadSupportIndex, 580, 75), Color.FromNonPremultiplied(255, 255, 255, 127));
                }
                else
                {
                    g.Draw(sprPixel, new Rectangle(45, 40, 550, 40), Color.FromNonPremultiplied(255, 255, 255, 127));
                }
                break;
            }
        }