/// <summary> /// Initializes a new instance of the <see cref="GameManager" /> class. /// Sets initial values, sets event handling for gameOver, pointScored, nextLevel, /// newSprite, and powerups /// </summary> public GameManager() { this.IsGameOver = false; this.roadManager = new RoadManager(GameSettings.BackgroundWidth); this.player = new PlayerManager(GameSettings.TopLaneOffset, GameSettings.BackgroundHeight, GameSettings.LeftBorder, GameSettings.BackgroundWidth); this.level = new LevelManager(); this.timeSprite = new TimeExtender(); this.invincibilityStar = new InvincibilityStar(); this.invincibilityTimer = new DispatcherTimer(); this.currentLifeAndPointTime = this.timerLength; this.startTime = DateTime.Now; this.Lives = GameSettings.InitialNumLives; this.player.NewSpriteCreated += this.playerOnNewSpriteCreated; this.LifeLost += this.player.HandleLifeLost; this.PointScored += this.handlePointScored; this.NextLevel += this.moveToNextLevel; this.TimePowerUp += this.onTimeExtension; }