public void SetStageVariables() { CurrentStage.Restart(); notesMissed = 0; piggyBankSpawner.Stop(); if (CurrentStage.HasFlag(Stage.StageFlags.PigsEnabled)) { piggyBankSpawner.Start(); } vacuumSpawner.Stop(); if (CurrentStage.HasFlag(Stage.StageFlags.VacuumsEnabled)) { vacuumSpawner.Interval = CurrentStage.VacuumSpawnTime; vacuumSpawner.Start(); } noteSpawner.Stop(); if (CurrentStage.HasFlag(Stage.StageFlags.NotesEnabled)) { noteSpawner.Interval = CurrentStage.NoteSpawnTime; noteSpawner.Start(); } if (!CurrentStage.HasFlag(Stage.StageFlags.LaserPlayerEnabled)) { laserPlayer.FiringLaser = false; SoundController.StopAllLoops(); } }
// Completely clears the level (ready to play from scratch). public void ResetContent() { RemoveStageContent(); currentCoinScore = 0; ReadyToSpawnPiggyBank = false; ReadyToSpawnVacuum = false; ReadyToSpawnNote = false; coinBackgroundController.Reset(); graphicsController.ResetCoinBuffers(); laserPlayer.FiringLaser = false; SoundController.StopAllLoops(); }
public GameController(ChangeGame gameIn, GraphicsController graphicsControllerIn, InputController inputControllerIn) { // Set references. game = gameIn; graphicsController = graphicsControllerIn; inputController = inputControllerIn; // Add reference to graphics controller. graphicsController.SetGameControllerReference(this); // Define state definitions (with references to this GameController instance's content). #region State definitions GameState.Title = new GameState("title") { OnEnterState = ResetContent, OnStateUpdate = UpdateMainMenu }; GameState.MapControls = new GameState("mapcontrols") { OnEnterState = StartMappingControls, OnStateUpdate = UpdateMapControls }; GameState.Playing = new GameState("playing") { OnEnterState = OnStartPlaying, OnStateUpdate = UpdatePlay }; GameState.BetweenStages = new GameState("betweenstages") { OnEnterState = () => { }, OnStateUpdate = (GameTime gameTime) => { UpdatePlay(gameTime); UpdateBetweenStages(gameTime); } }; GameState.GameOver = new GameState("gameover") { OnEnterState = () => { gameOverMenu.Drop(); bestCoinScore = Math.Max(bestCoinScore, currentCoinScore); laserPlayer.FiringLaser = false; SoundController.StopAllLoops(); }, OnStateUpdate = UpdateGameOverMenu }; #endregion // Set up controllers. coinBackgroundController = new CoinBackgroundController(); // Set up menus. mainMenu = new MainMenu(game, this); gameOverMenu = new GameOverMenu(this); stageCompleteMenu = new StageCompleteMenu(); // Set up players. laserPlayer = new LaserPlayer(this); paddlePlayer = new PaddlePlayer(); // Define collections. enemies = new List <Enemy>(); corpses = new List <EnemyCorpse>(); notes = new List <Note>(); notesOnFire = new List <NoteOnFire>(); // Define timers. piggyBankSpawner = new Timer(30000); piggyBankSpawner.Elapsed += (a, b) => ReadyToSpawnPiggyBank = true; vacuumSpawner = new Timer(); vacuumSpawner.Elapsed += (a, b) => ReadyToSpawnVacuum = true; noteSpawner = new Timer(); noteSpawner.Elapsed += (a, b) => ReadyToSpawnNote = true; }