public Game() { this.mode = GameMode.MainMenu; this.menuItems = ConsoleUI.MainMenuItems; this.menuItemIndex = 0; this.cursorMoved = false; this.keyboard = new KeyboardController(); this.renderer = new Renderer(ConsoleUI.BufferRows, ConsoleUI.BufferCols, new Coordinate(ConsoleUI.BufferPositionRow, ConsoleUI.BufferPositionCol)); this.spaceUnitFactory = new SpaceUnitFactory(); this.gameLogo = new GameObject(new Coordinate(ConsoleUI.LogoPositionRow, ConsoleUI.LogoPositionCol), ConsoleUI.LogoBody); this.bottomWall = new GameObject(new Coordinate(ConsoleUI.BottomWallPositionRow, ConsoleUI.BottomWallPositionCol), ConsoleUI.BottomWallBody); this.cursor = new GameObject(new Coordinate(ConsoleUI.MainMenuCursorPositionRow, ConsoleUI.MainMenuCursorPositionCol), ConsoleUI.CursorBody); this.mainMenu = new GameObject(new Coordinate(ConsoleUI.MainMenuPositionRow, ConsoleUI.MainMenuPositionCol), ConsoleUI.MainMenuBody); this.controlsMenu = new GameObject(new Coordinate(ConsoleUI.ConstrolsMenuPositionRow, ConsoleUI.ConstrolsMenuPositionCol), ConsoleUI.ControlsMenuBody); this.highScoreMenu = new GameObject(new Coordinate(ConsoleUI.HighScoreMenuPositionRow, ConsoleUI.HighScoreMenuPositionCol), ConsoleUI.HighScoreMenuBody); this.gameOverMenu = new GameObject(new Coordinate(ConsoleUI.GameOverMenuPositionRow, ConsoleUI.GameOverMenuPositionCol), ConsoleUI.GameOverMenuBody); this.hittedHighScore = new GameObject(new Coordinate(ConsoleUI.HittedHighScorePositionRow, ConsoleUI.HittedHighScorePositionCol), ConsoleUI.HittedHighScoreBody); this.highScore = FileManager.ParseHighScore(); this.gameEngine = null; this.player = null; }
private void Play() { this.PrintGameLogo(); this.mode = GameMode.Play; SpaceUnitType playerSpaceshipType = SpaceUnitType.Banshee; Coordinate playerSpaceshipPosition = new Coordinate(ConsoleUI.PlayerInitPositionRow, ConsoleUI.PlayerInitPositionCol); Coordinate playerSpaceshipSpeed = new Coordinate(ConsoleUI.PlayerInitSpeedRow, ConsoleUI.PlayerInitSpeedCol); string playerSpacesheepCollisionGroup = "player"; Spaceship playerSpaceship = this.spaceUnitFactory.ProduceSpaceUnit(playerSpaceshipType, playerSpaceshipPosition, playerSpaceshipSpeed, playerSpacesheepCollisionGroup) as Spaceship; this.player = new Player(playerSpaceship); GameObject healthUi = new GameObject(new Coordinate(ConsoleUI.HealthPositionRow, ConsoleUI.HealthPositionCol), ConsoleUI.HealthBody); GameObject scoreUi = new GameObject(new Coordinate(ConsoleUI.ScorePositionRow, ConsoleUI.ScorePositionCol), ConsoleUI.ScoreBody); this.gameEngine = new Engine(this.keyboard, this.renderer, this.spaceUnitFactory, ConsoleUI.CanvasRows - this.gameLogo.BodyHeight, ConsoleUI.CanvasCols); this.gameEngine.AddPlayer(this.player); this.gameEngine.AddHealthUI(healthUi); this.gameEngine.AddScoreUi(scoreUi); this.gameEngine.Run(); this.mode = GameMode.GameOver; }