/// <summary> /// Initializes a new instance of the <see cref="GameManager" /> class. /// </summary> /// <param name="backgroundHeight">Height of the background.</param> /// <param name="backgroundWidth">Width of the background.</param> /// <exception cref="ArgumentOutOfRangeException"> /// backgroundHeight <= 0 /// or /// backgroundWidth <= 0 /// </exception> public GameManager(double backgroundHeight, double backgroundWidth) { if (backgroundHeight <= 0) { throw new ArgumentOutOfRangeException(nameof(backgroundHeight)); } if (backgroundWidth <= 0) { throw new ArgumentOutOfRangeException(nameof(backgroundWidth)); } this.backgroundHeight = backgroundHeight; this.backgroundWidth = backgroundWidth; this.soundManager = new SoundManager(); this.gameSettings = new GameSettings(); this.roadManager = new RoadManager((int)this.backgroundWidth, (int)this.backgroundHeight, this.gameSettings.LaneHeight); this.playerManager = new PlayerManager(); this.scoreBoard = new ScoreBoardManager(); this.frogHomeManager = new FrogHomeManager(this.gameSettings.FrogHomeOffset); this.collisionDetection = new CollisionDetection(); this.deathAnimation = new AnimationManager(); this.powerUpManager = new PowerUpManager(this.soundManager, (int)this.backgroundWidth, (int)this.backgroundHeight); this.highScoreContentDialog = new HighScoreContentDialog(); this.addScoreContentDialog = new AddScoreContentDialog(); this.timeLeft = this.gameSettings.InitialTimeLeft; this.vehicleIndex = 0; this.playerMovingFrame = new AnimationFrame(new FrogMovingSprite()); this.setupGameTimer(); this.setupLifeTimer(); this.setupVehicleTimer(); }
/// <summary> /// Initializes a new instance of the <see cref="GameManager" /> class. /// </summary> /// <param name="backgroundHeight">Height of the background.</param> /// <param name="backgroundWidth">Width of the background.</param> /// <exception cref="ArgumentOutOfRangeException"> /// backgroundHeight <= 0 /// or /// backgroundWidth <= 0 /// </exception> public GameManager(double backgroundHeight, double backgroundWidth) { if (backgroundHeight <= 0) { throw new ArgumentOutOfRangeException(nameof(backgroundHeight)); } if (backgroundWidth <= 0) { throw new ArgumentOutOfRangeException(nameof(backgroundWidth)); } this.backgroundHeight = backgroundHeight; this.backgroundWidth = backgroundWidth; this.laneManager = new LaneManager(LaneSettings.MiddleSafeLaneLocation); this.riverManager = new RiverManager(LaneSettings.TopLaneYLocation); this.homeManager = new FrogHomeManager(LaneSettings.TopLaneYLocation); this.deathAnimationManager = new DeathAnimationManager(); this.powerUpManager = new PowerUpManager(); this.playerManager = new PlayerManager(); this.deathAnimationManager.AnimationOver += this.handleDeathAnimationHasEnded; }