/// <summary> /// Timer handler to manage ball state, lights, sound, etc. /// </summary> /// <param name="state"></param> private void collectBonusTimerHandler(object state) { //this is called every second. //check if we've collected already(race condition with switches) if (_isBonusCollected || _isBonusFailed) { //do we turn off the timer or just let it dispose? return; } //check how much time is remaining long timeleft = BONUSCOLLECTTIMEOUTMS - _timeStarted.ElapsedMilliseconds; //if > 10 seconds, do nothing if (timeleft > 10000) { return; } else if (timeleft > 9050) //leave some jitter time (or just put in a _soundPlayed flag?) { //if = 10 seconds, start panic song and lighting SoundManager.PlaySfx(SoundConstants.Sfx.HurryUp); LightManager.PlaySequence(LightingConstants.Lfx.CollectTrophyFast); } else if (timeleft <= 0 && !_isBonusFailed) { endPlayTimeout(); } }
private void handleScoreChanged(int points, SoundConstants.Sfx sound, LightingConstants.Lfx lightEffect) { if (points > 0) { GameManager.getInstance().AddScore(points); } if (sound != SoundConstants.Sfx.None) { SoundManager.PlaySfx(sound); } if (lightEffect != LightingConstants.Lfx.None) { LightManager.PlaySequence(lightEffect); } }
public TrophyRoomMode() { _log.Info("Trophy Room Mode Started"); DisplayManager.OnAnimationCompleted += new DisplayEventHandler(DisplayManager_OnAnimationCompleted); SwitchManager.RegisterSwitchHandler(handleSwitchChanges); //Rotate Playfield to CenterScoop position SwitchManager.RotateStage(SwitchConstants.StagePositions.TrophyScoop); SwitchManager.RotateCross(false); //Play "Collect Trophy" instructional video DisplayManager.PlayCutScene(DisplayConstants.CutScenes.ActiveGameMode.COLLECTTROPHY); LightManager.PlaySequence(LightingConstants.Lfx.CollectTrophySlow); _collectBonusTimer = new Timer(new TimerCallback(collectBonusTimerHandler), null, 1000, 1000); //ticks every second _timeStarted = new System.Diagnostics.Stopwatch(); _timeStarted.Start(); }