public static void Play() { GetInitialValues(); PrintRow(); DrawUpWallOfTheBridge(); DrawDownWallOfTheBridge(); PrintMessage(); int currentPoint = points; while (true) { if (Console.KeyAvailable) { ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.UpArrow) { horse.MoveUp(area.PositionY); } else if (keyInfo.Key == ConsoleKey.DownArrow) { horse.MoveDown(area.PositionY, area.Height); } else if (keyInfo.Key == ConsoleKey.E) { area.CheckForExit(bonus, horse.Height); } else if (keyInfo.Key == ConsoleKey.Spacebar) { shot.Add(new Shot(horse.Width, horse.PositionY + 1)); } else if (keyInfo.Key == ConsoleKey.Escape) { Pause(); } } CreateMouse(); MoveColumn(); CreateColumn(); RemoveMouseAndShot(); MoveShot(); MoveMouse(); area.Move(); clouds.Move(); river.Move(); CountPoints(); if (CheckForEndOfLevel()) { DrawRiver(); DrawColumn(); DrawLevelUp(); if (area.CheckForArea()) { DrawGameFinish(); break; } GetNewLevel(); } PrintResult(); PrintBonus(); DrawClouds(); DrawArea(); ClearShot(); DrawShot(); ClearMouse(); DrawMouse(); DrawRiver(); ClearColumns(); DrawColumn(); ClearHorse(); if (CheckForAccident()) { DrawWentTheHorseIntoTheRiver(); GameOver(); break; } else { DrawHorse(); } Thread.Sleep(45); } }
public static void Play() { GetInitialValues(); PrintRow(); DrawUpWallOfTheBridge(); DrawDownWallOfTheBridge(); PrintMessage(); horseMove.PlayLooping(); int currentPoint = points; while (true) { while (Console.KeyAvailable) { ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.UpArrow) { horse.MoveUp(area.PositionY); ClearHorse(); } else if (keyInfo.Key == ConsoleKey.DownArrow) { horse.MoveDown(area.PositionY, area.Height); ClearHorse(); } else if (keyInfo.Key == ConsoleKey.E) { if (area.CheckForExit(bonus, horse.Height)) { int position = area.Elements[area.Elements.Count - 1].PositionX - 2; if (position < columns - 4) { for (int part = 0; part < horse.Height; part++) { PrintAtPosition(position, area.Elements[area.Elements.Count - 1].PositionY - part - 1, " ", ConsoleColor.Black, ConsoleColor.Black); } } } } else if (keyInfo.Key == ConsoleKey.Spacebar) { shot.Add(new Shot(horse.Width, horse.PositionY + 1)); } else if (keyInfo.Key == ConsoleKey.Escape) { Pause(); } } CreateMouse(); MoveColumn(); CreateColumn(); RemoveMouseAndShot(); MoveShot(); MoveMouse(); area.Move(); clouds.Move(); river.Move(); CountPoints(); if (CheckForEndOfLevel()) { horseMove.Stop(); DrawRiver(); DrawColumn(); DrawHorse(); DrawLevelUp(); if (area.CheckForArea()) { SoundPlayer gameFinishSound = new SoundPlayer("applause.wav"); gameFinishSound.Play(); Thread.Sleep(2000); DrawGameFinish(); break; } GetNewLevel(); horseMove.PlayLooping(); } PrintResult(); PrintBonus(); DrawClouds(); ClearArea(); CheckElement(); ClearShot(); DrawShot(); ClearMouse(); DrawMouse(); DrawArea(); DrawRiver(); ClearColumns(); DrawColumn(); if (CheckForAccident()) { horseMove.Stop(); DrawWentTheHorseIntoTheRiver(); GameOver(); break; } else { DrawHorse(); } Thread.Sleep(45); } }