protected virtual void endLevel() { MediaSystem.StopSiren(); MediaSystem.PlaySoundEffect(SFXOptions.Win); overlay = new OpeningOverlay(true); results = new ResultsScreen(time, BoxesDestroyed, score, levelNumber, CompletionData); ending = true; color = new Color(0, 0, 0, 0); timer = new Timer(2500, onTimerFired, false); timer.Start(); TemporarilyMuteVoice = false; screenSpace = new Rectangle(0, 0, (int)RenderingDevice.Width, (int)RenderingDevice.Height); }
public virtual void Update(GameTime gameTime) { if(Input.KeyboardState.IsKeyDown(Keys.LeftControl) && Input.CheckKeyboardJustPressed(Keys.F1)) scoreboardOn = !scoreboardOn; updateMachines(gameTime); if(!ending) { if(overlay != null) { overlay.Update(gameTime); if(overlay.Completed && !badEnding) { overlay = null; if(!TemporarilyMuteVoice) #if DEMO if(levelNumber != 4) #endif MediaSystem.PlayVoiceActing(levelNumber); } else if(overlay.Completed && badEnding) { GameManager.State = GameState.GameOver; return; } } #if DEBUG if(!badEnding && !ending) { spawnDebugBox(); if(Input.CheckKeyboardJustPressed(Keys.LeftShift)) { endLevel(); return; } } #endif if(overlay == null) time += gameTime.ElapsedGameTime; for(int i = 0; i < boxesOnscreen.Count; i++) { boxesOnscreen[i].Update(gameTime); if(boxesOnscreen[i].NeedsRemoval && boxesOnscreen[i].Kill) { if(boxesOnscreen[i].BoxColor != Color.Black) DestroyBox(boxesOnscreen[i]); else VanishBox(boxesOnscreen[i] as BlackBox, true); i--; // Need to redo this number so that we don't miss some. } } foreach(Tube t in tubeList) t.Update(gameTime); if(overlay == null) spawnTimer += gameTime.ElapsedGameTime.Milliseconds * (levelNumber != 0 ? (boxesMax == BoxesRemaining ? 11 : 1) : 0); if(!badEnding && overlay == null) { if((spawnTimer >= spawnTime || Input.CheckKeyboardJustPressed(Input.WindowsOptions.QuickBoxKey) || Input.CheckXboxJustPressed(Input.XboxOptions.QuickBoxKey)) && BoxesRemaining > 0) spawnBox(); if(BoxesDestroyed * 1.3 >= boxesMax - boxesNeeded && !MediaSystem.SirenPlaying && levelNumber != 0 && levelNumber != 11) MediaSystem.PlaySoundEffect(SFXOptions.Siren); else if(BoxesDestroyed > boxesMax - boxesNeeded && !Input.WindowsOptions.HighScoreMode) { badEnding = true; overlay = new OpeningOverlay(false); MediaSystem.PlaySoundEffect(SFXOptions.Fail); MediaSystem.StopSiren(); } else if(boxesSaved >= boxesNeeded && !Input.WindowsOptions.HighScoreMode) endLevel(); else if(BoxesRemaining == 0 && boxesOnscreen.Count == 0 && Input.WindowsOptions.HighScoreMode) endLevel(); } } else // is ending { if(overlay != null) { overlay.Update(gameTime); scoreboard.Update(boxesSaved, BoxesDestroyed, BoxesRemaining, score, multiplier, spawnTimer, time); // so that popups can still get removed if(overlay.Completed) overlay = null; else return; } timer.Update(gameTime); if(!drawResults) { if(color.A + 3 >= 255) color.A = 255; else color.A += 3; } else { if(results.Update(gameTime)) loadNextLevel(); } } scoreboard.Update(boxesSaved, BoxesDestroyed, BoxesRemaining, score, multiplier, spawnTimer, time); }
public virtual void ResetLevel() { releaseBoxes(); foreach(OperationalMachine m in MachineList.Keys) m.ResetMachine(); RenderingDevice.Camera.Reset(); boxesSaved = 0; BoxesDestroyed = 0; spawnTimer = 0; score = 0; counter = 0; time = TimeSpan.Zero; BoxesRemaining = boxesMax; badEnding = false; scoreboard.Reset(); ending = false; MediaSystem.StopSiren(); if(results == null) MediaSystem.StopVoiceActing(); MediaSystem.LevelReset(); if(overlay != null) overlay.RemoveThineself(); overlay = new OpeningOverlay(levelNumber < 12 ? levelNumber : levelNumber - 11, levelNumber > 11, levelName); }
public virtual void RemoveFromGame(Space s) { TemporarilyMuteVoice = false; removeModelsFromRenderer(); s.Clear(); MediaSystem.StopSiren(); MediaSystem.StopSFX(); if(overlay != null) overlay.RemoveThineself(); overlay = null; }
public virtual void AddToGame(Space s) { TemporarilyMuteVoice = false; MediaSystem.PlayTrack(levelTheme.Song); overlay = new OpeningOverlay(levelNumber < 12 ? levelNumber : levelNumber - 11, levelNumber > 11, levelName); time = new TimeSpan(); RebuildTiming(); foreach(OperationalMachine m in MachineList.Keys) s.Add(m); s.Add(levelModel); foreach(Tube t in tubeList) s.Add(t); foreach(BaseModel m in glassModels) if(m.Ent.Space == null) s.Add(m); s.Add(dispenser); if(levelTheme.Fluid != null) s.Add(levelTheme.Fluid); addModelsToRenderer(); results = null; ending = badEnding = false; }
public override void AddToGame(BEPUphysics.Space s) { levelTheme.SetUpLighting(); TemporarilyMuteVoice = false; MediaSystem.PlayTrack(levelTheme.Song); overlay = new OpeningOverlay(levelNumber, false, levelName); time = new TimeSpan(); RebuildTiming(); int i = 0; foreach(OperationalMachine m in MachineList.Keys) if(i < 11) { s.Add(m); i++; } else break; s.Add(levelModel); i = 0; foreach(Tube t in tubeList) { if(i < 110) s.Add(t); else break; i++; } i = 0; foreach(BaseModel m in glassModels) if(i < 6) { if(m.Ent.Space == null) s.Add(m); i++; } else break; s.Add(dispenser); if(levelTheme.Fluid != null) s.Add(levelTheme.Fluid); addModelsToRenderer(); results = null; ending = badEnding = false; }