public static void EndPlayerPhase(DeathmatchMap Map)
        {
            //Reset the cursor.
            Map.ActiveSquadIndex = -1;

            if (Map.IsClient && GameScreen.FMODSystem.sndActiveBGMName != Map.sndBattleThemeName && !string.IsNullOrEmpty(Map.sndBattleThemeName))
            {
                Map.sndBattleTheme.Stop();
                Map.sndBattleTheme.SetLoop(true);
                Map.sndBattleTheme.PlayAsBGM();
                GameScreen.FMODSystem.sndActiveBGMName = Map.sndBattleThemeName;
            }

            do
            {
                Map.ActivePlayerIndex++;
                UpdateDelayedAttacks(Map, Map.ActivePlayerIndex);
                UpdatePERAttacks(Map, Map.ActivePlayerIndex);

                if (Map.ActivePlayerIndex >= Map.ListPlayer.Count)
                {
                    Map.OnNewTurn();
                    UpdateDelayedAttacks(Map, Map.ActivePlayerIndex);
                    UpdatePERAttacks(Map, Map.ActivePlayerIndex);
                }

                foreach (Player ActivePlayer in Map.ListPlayer)
                {
                    for (int S = 0; S < ActivePlayer.ListSquad.Count; S++)
                    {
                        Squad ActiveSquad = ActivePlayer.ListSquad[S];

                        for (int U = ActiveSquad.UnitsAliveInSquad - 1; U >= 0; --U)
                        {
                            ActiveSquad[U].UpdateSkillsLifetime(SkillEffect.LifetimeTypeTurns + Map.ActivePlayerIndex);
                            Map.ActivateAutomaticSkills(ActiveSquad, ActiveSquad[U], null, ActiveSquad, ActiveSquad[U]);
                        }
                    }
                }
            }while (!Map.ListPlayer[Map.ActivePlayerIndex].IsAlive);

            for (int S = 0; S < Map.ListPlayer[Map.ActivePlayerIndex].ListSquad.Count; S++)
            {
                Squad ActiveSquad = Map.ListPlayer[Map.ActivePlayerIndex].ListSquad[S];

                for (int U = ActiveSquad.UnitsAliveInSquad - 1; U >= 0; --U)
                {
                    Map.ActivateAutomaticSkills(ActiveSquad, ActiveSquad[U], "Player Phase Start Requirement", ActiveSquad, ActiveSquad[U]);

                    //Repair passive bonus.
                    if (ActiveSquad[U].Boosts.RepairModifier)
                    {
                        for (int U2 = ActiveSquad.UnitsAliveInSquad - 1; U2 >= 0; --U2)
                        {
                            ActiveSquad[U2].HealUnit((int)(ActiveSquad[U2].MaxHP * 0.05));
                        }
                    }

                    //Resupply passive bonus.
                    if (ActiveSquad[U].Boosts.ResupplyModifier)
                    {
                        for (int U2 = ActiveSquad.UnitsAliveInSquad - 1; U2 >= 0; --U2)
                        {
                            ActiveSquad[U2].RefillEN((int)(ActiveSquad[U2].MaxEN * 0.05));
                        }
                    }

                    ActiveSquad[U].OnPlayerPhaseStart(Map.ActivePlayerIndex, ActiveSquad);
                }
            }
        }