public static void GameOver(UIfunctions UI, MainShip ship, List <Enemies> enemies, int score, ref int missed)
        {
            Console.Clear();
            var toBeDeleted = new List <Enemies>();

            foreach (var enemy in enemies)
            {
                toBeDeleted.Add(enemy);
            }
            ship.DeleteEnemies(toBeDeleted);


            ship.position.x = Constants.MainShipSpawnPositionX;
            ship.position.y = Constants.MainShipSpawnPositionY;
            if (missed >= 3)
            {
                Console.SetCursorPosition(40, 20);
                Console.WriteLine($"You missed {missed} enemies!");
                missed = Constants.MissedShips;
            }
            else
            {
                Console.SetCursorPosition(40, 20);
                Console.WriteLine("You got hit!");
            }
            Thread.Sleep(2000);
            Console.SetCursorPosition(40, 22);
            Console.Write("Press any key to continue");
            Console.ReadKey();
            Console.Clear();
            ship.lives--;


            UI.DrawFrame(ship.lives, score, missed);
        }
        public void UpdateBullets(ref int score)
        {
            var Removed = new List <Bullet>();

            for (int i = 0; i < Bullets.Count; i++)
            {
                var bul = Bullets[i];
                if (bul.y > 1)
                {
                    int prev = bul.y;
                    bul.y--;
                    var c = ReadCharacterAt(bul.x, bul.y);
                    if (c != ' ')
                    {
                        Removed.Add(bul);
                        Console.SetCursorPosition(bul.x, prev);
                        Console.WriteLine(' ');
                        CheckForDeadEnemiesAndDelete(bul.x, bul.y);
                        UpdateEnemies();
                        UIfunctions.UpdateScore(ref score);
                    }
                    else
                    {
                        Console.SetCursorPosition(bul.x, bul.y);
                        Console.WriteLine('*');
                        Console.SetCursorPosition(bul.x, prev);
                        Console.WriteLine(' ');
                    }
                }
                else
                {
                    Bullets.Remove(bul);
                    Console.SetCursorPosition(bul.x, bul.y);
                    Console.WriteLine(' ');
                }
            }
            foreach (var bulet in Removed)
            {
                Bullets.Remove(bulet);
                UpdateBullets(ref score);
            }
        }
        public void MoveShip(ConsoleKeyInfo KeyInfo, MainShip ship, ref Coordinates coords)
        {
            var UI = new UIfunctions();

            switch (KeyInfo.Key)
            {
            case ConsoleKey.RightArrow:
                DeleteShip();
                if (coords.x < Constants.PlayBoxWidth - Constants.MainShipWidth)
                {
                    if (coords.x + Constants.MainShipSpeedX <= Constants.PlayBoxWidth - Constants.MainShipWidth)
                    {
                        coords.x += Constants.MainShipSpeedX;
                    }
                    coords.x++;
                }
                ship.DrawShip();
                break;

            case ConsoleKey.LeftArrow:
                DeleteShip();
                if (coords.x - 1 > Constants.FrameWidth)
                {
                    if (coords.x - Constants.MainShipSpeedX > Constants.FrameWidth)
                    {
                        coords.x -= Constants.MainShipSpeedX;
                    }
                    coords.x--;
                }
                ship.DrawShip();
                break;

            case ConsoleKey.UpArrow:
                DeleteShip();
                if (coords.y - 1 > Constants.FrameWidth)
                {
                    if (coords.y - Constants.MainShipSpeedY > Constants.FrameWidth)
                    {
                        coords.y -= Constants.MainShipSpeedY;
                    }
                    coords.y--;
                }
                ship.DrawShip();

                break;

            case ConsoleKey.DownArrow:
                DeleteShip();
                if (coords.y < Constants.PlayBoxHeight - Constants.MainShipHeight)
                {
                    if (coords.y + Constants.MainShipSpeedY <= Constants.PlayBoxHeight - Constants.MainShipHeight)
                    {
                        coords.y += Constants.MainShipSpeedY;
                    }
                    coords.y++;
                }
                ship.DrawShip();
                break;

            case ConsoleKey.Spacebar:
                Bullets.Add(new Bullet(ship.position.x + 3, ship.position.y - 1));

                Console.Beep(500, 50);
                ship.DrawShip();
                break;

            default:
                ship.DrawShip();
                break;
            }
        }