private void endPlayTimeout() { //the player ran out of time trying to collect the trophy but has not lost the ball yet. //kill the flippers until we lose the ball. SwitchManager.EnableFlippers(false); _isBonusFailed = true; //no bonus }
/// <summary> /// Singleton pattern /// </summary> /// <returns></returns> protected static SwitchManager getInstance() { if (_instance == null) _instance = new SwitchManager(); return _instance; }
public AttractMode() { _log.Info("Attract Mode Started"); DisplayManager.PlaySequence(DisplayConstants.Modes.AttractMode.ATTRACT); //send high scores DisplayManager.OnAnimationCompleted += new DisplayEventHandler(DisplayManager_OnAnimationCompleted); SwitchManager.RegisterSwitchHandler(handleSwitchChanges); SwitchManager.Reset(); }
public NormalPlayMode() { _log.Info("Normal Play Mode Started"); _instance.ResetForNewPlayer(); DisplayManager.OnAnimationCompleted += new DisplayEventHandler(DisplayManager_OnAnimationCompleted); SwitchManager.RegisterSwitchHandler(handleSwitchChanges); }
/// <summary> /// Award one or more credits. /// </summary> /// <param name="credits"></param> public void AwardFreeCredit(int credits) { //fire knocker SwitchManager.FireKnocker(); for (int i = 0; i < credits; i++) { AddCredit(); } }
} //not used /// <summary> /// The player has lost his ball (there are no more balls on the /// playfield). /// </summary> public void EndOfBall() { _log.Debug("End of Ball for Player " + PlayerStatus.PlayerUp); SwitchManager.EnableFlippers(false); _inputMode = InputMode.NoInput; SoundManager.StopAllMusic(); SoundManager.PlaySfx(SoundConstants.Sfx.Death1); CollectBonus(); }
/// <summary> /// Singleton pattern /// </summary> /// <returns></returns> protected static SwitchManager getInstance() { if (_instance == null) { _instance = new SwitchManager(); } return(_instance); }
private void countBallsOnField() { //now lets count the balls we should have. _isBallInShooterLane = SwitchManager.GetSwitchState(SwitchConstants.Switches.BallShooterLane) == SwitchState.On; int ballsInTrough = SwitchManager.GetSwitchState(SwitchConstants.Switches.RightBallTrough) == SwitchState.On ? 1 : 0; ballsInTrough += SwitchManager.GetSwitchState(SwitchConstants.Switches.RightMidBallTrough) == SwitchState.On ? 1 : 0; ballsInTrough += SwitchManager.GetSwitchState(SwitchConstants.Switches.MidBallTrough) == SwitchState.On ? 1 : 0; ballsInTrough += SwitchManager.GetSwitchState(SwitchConstants.Switches.LeftMidBallTrough) == SwitchState.On ? 1 : 0; ballsInTrough += SwitchManager.GetSwitchState(SwitchConstants.Switches.LeftBallTrough) == SwitchState.On ? 1 : 0; _ballsOnField = TOTALBALLS - ballsInTrough; }
/// <summary> /// Plays the player intro (MAP) and primes the table for the player status. /// </summary> public void StartPlayIntro() { //select user //ask the credit manager if we have credits PlayerStatus.CurrentPlayer.PlayerHealthStatus = "Player " + PlayerStatus.PlayerUp + " is up"; DisplayManager.PlaySequence(DisplayConstants.Modes.ActiveGameMode.ACTIVEGAMEMODE); //Character is selected, now let's show the map. DisplayManager.PlayCutScene(DisplayConstants.CutScenes.MapMode.MAP); SoundManager.PlayMusic(SoundConstants.Music.LevelStart, false); SoundManager.PlayMusic(SoundConstants.Music.Level1Normal, true); //DisplayManager.SetGameStatus(PlayerStatus.CurrentPlayer); SwitchManager.EnableFlippers(true); }
/// <summary> /// This task watches for state changes in the trough switches as well as the shooter lane. /// It generally shouldn't care about what state the game is in because the logic to eject is controlled via /// autoplunge properties, etc. /// </summary> /// <param name="cancellationToken"></param> private void troughWatcherHandler(CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) //change to allow for Task Cancelling { System.Threading.Thread.Sleep(1000); //sleep first, so we can insure a 1 second lapse. //while (GameManager.CurrentInputMode == InputMode.NormalPlay) //{ // //if there any number of auto-plunged balls, start ejecting everything // //if there is a ball in the shooter lane, try to auto-plunge and wait until the lane clears (2s). // //SwitchManager.GetState(SwitchConstants.Switches.BallShooterLane).State = On; // //switchmanager.autoplunge(); // System.Threading.Thread.Sleep(2000); //} if (_isBallInShooterLane) { if (_isAutoPlungeOn) //clear the way if there's a ball waiting. { SwitchManager.Autoplunge(); } } else if (_ballsToEject > 0) { SwitchManager.EjectBall(); _ballsToEject--; if (_ballsToEject > 0) //there is a queue of balls (multiball?) { _isAutoPlungeOn = true; //turn on autoplunging to flush this queue out. } } else //no ball in shooter lane and no balls queued to eject. turning off autoplunge. { //_isAutoPlungeOn = false; //CAN'T DO THIS!!! RACE CONDITION WOULD TURN OFF AUTOPLUNGE, ORPHANING LAST BALL //The only place autoplunge is turned off is in RESET, caused by a new game or player. //we've got nothing to do. lets see if we're stuck. //Switch[] state = SwitchManager.GetSwitches(); //_isBallInShooterLane = state[(int)SwitchConstants.Switches.BallShooterLane].State == SwitchState.On; } //now lets count the balls we should have. countBallsOnField(); } }
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(); }
public TestMode() { //DisplayManager.PlaySequence(DisplayConstants.ATTRACT); //send high scores SwitchManager.RegisterSwitchHandler(handleSwitchChanges); }
private void handleSwitchChanges(Switch changed) { if (_isDisposed) { return; } switch (changed.Id) { case (int)SwitchConstants.Switches.PlumbTilt: _instance.TiltWarning(PlayerStatus.CurrentPlayer.TiltWarnings++); break; case (int)SwitchConstants.Switches.Start: if (changed.State == SwitchState.On) { //can only add a player if the current player is on ball 1 if (PlayerStatus.CurrentPlayer.Ball == 1) { _instance.AddPlayer(); } } break; case (int)SwitchConstants.Switches.Coin: if (changed.State == SwitchState.On) { _instance.AddCredit(); // } break; case (int)SwitchConstants.Switches.SlamTilt: break; case (int)SwitchConstants.Switches.MenuSelect: break; case (int)SwitchConstants.Switches.MenuBack: break; case (int)SwitchConstants.Switches.MenuNext: break; case (int)SwitchConstants.Switches.MenuExit: break; case (int)SwitchConstants.Switches.Outhole: if (CurrentInputMode == InputMode.NormalPlay) { if (changed.State == SwitchState.On) { _instance.BallDrained(); } } break; case (int)SwitchConstants.Switches.RightBallTrough: break; case (int)SwitchConstants.Switches.RightMidBallTrough: break; case (int)SwitchConstants.Switches.MidBallTrough: break; case (int)SwitchConstants.Switches.LeftMidBallTrough: break; case (int)SwitchConstants.Switches.LeftBallTrough: //if (_state[i].State == SwitchState.On) //_instance.KickBack(); break; case (int)SwitchConstants.Switches.BallShooterLane: if (changed.State == SwitchState.Off && CurrentInputMode == InputMode.NormalPlay) { //was on, now is off and we're waiting to start the ball saver timer. if (TroughManager.BallSaverState == BallSaverStates.Waiting) { TroughManager.StartBallSaverTimer(); } } break; case (int)SwitchConstants.Switches.RightFlipperEOS: break; case (int)SwitchConstants.Switches.LeftFlipperEOS: break; case (int)SwitchConstants.Switches.LeftDrain: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { if (!_instance._isTilted) //this might need to be higher up.. maybe an input mode { _instance.AddScore(ScoreConstants.OUTLANE); if (PlayerStatus.CurrentPlayer.HasShield) { //SolenoidManager.FireKickBack(); PlayerStatus.CurrentPlayer.HasShield = false; //decrement } } } break; case (int)SwitchConstants.Switches.LeftReturn: break; case (int)SwitchConstants.Switches.LeftSling: case (int)SwitchConstants.Switches.RightSling: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.RightReturn: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.RightDrain: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { if (!_instance._isTilted) { _instance.AddScore(ScoreConstants.OUTLANE); PlayerStatus.CurrentPlayer.HasCross = false; //decrement } } break; case (int)SwitchConstants.Switches.DraculaD: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(0); } break; case (int)SwitchConstants.Switches.DraculaR: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(1); } break; case (int)SwitchConstants.Switches.DraculaA: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(2); } break; case (int)SwitchConstants.Switches.DraculaC: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(3); } break; case (int)SwitchConstants.Switches.DraculaU: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(4); } break; case (int)SwitchConstants.Switches.DraculaL: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(5); } break; case (int)SwitchConstants.Switches.DraculaA2: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addDraculaLetter(6); } break; case (int)SwitchConstants.Switches.BallPopper: break; case (int)SwitchConstants.Switches.DropTargetA: break; case (int)SwitchConstants.Switches.DropTargetB: break; case (int)SwitchConstants.Switches.DropTargetC: break; //case (int)SwitchConstants.Switches.DropTargetD: // break; case (int)SwitchConstants.Switches.BelmontB: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(0); } break; case (int)SwitchConstants.Switches.BelmontE: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(1); } break; case (int)SwitchConstants.Switches.BelmontL: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(2); } break; case (int)SwitchConstants.Switches.BelmontM: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(3); } break; case (int)SwitchConstants.Switches.BelmontO: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(4); } break; case (int)SwitchConstants.Switches.BelmontN: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(5); } break; case (int)SwitchConstants.Switches.BelmontT: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addBelmontLetter(6); } break; case (int)SwitchConstants.Switches.LeftOuterOrbit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.RampExit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { if (PlayerStatus.CurrentPlayer.Paths.HasFlag(NavigationPaths.Up)) { navigate(NavigationPaths.Up); } else { attack(false, int.MaxValue, false); //kill 1 enemy } } break; case (int)SwitchConstants.Switches.LeftInnerOrbit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.BossTarget: break; case (int)SwitchConstants.Switches.CenterExit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { if (PlayerStatus.CurrentPlayer.Paths.HasFlag(NavigationPaths.Straight)) { navigate(NavigationPaths.Straight); } else { attack(false, int.MaxValue, false); //kill 1 enemy } } break; case (int)SwitchConstants.Switches.CenterScoop: break; case (int)SwitchConstants.Switches.RightInnerOrbit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.CapturedBall: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addItem(); } break; case (int)SwitchConstants.Switches.RightScoop: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { if (PlayerStatus.CurrentPlayer.Paths.HasFlag(NavigationPaths.Down)) { navigate(NavigationPaths.Down); } else { attack(false, int.MaxValue, false); //kill 1 enemy } } break; case (int)SwitchConstants.Switches.RightOuterOrbit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.TopOuterOrbit: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { _instance.AddScore(ScoreConstants.NONTARGET); } break; case (int)SwitchConstants.Switches.LeftPop: case (int)SwitchConstants.Switches.TopPop: case (int)SwitchConstants.Switches.LowerPop: if (changed.State == SwitchState.On && CurrentInputMode == InputMode.NormalPlay) { addHeart(); attack(false, 1, true); } break; case (int)SwitchConstants.Switches.LeftFlipper: case (int)SwitchConstants.Switches.RightFlipper: if (CurrentInputMode == InputMode.SelectPlayer) { if (changed.State == SwitchState.Off) //flip players on buttonUP { if (changed.Id == (int)SwitchConstants.Switches.LeftFlipper) { DisplayManager.CharacterPrevious(); } else { DisplayManager.CharacterNext(); } } else { //find out if both buttons are currently on. Switch left = SwitchManager.GetSwitch(SwitchConstants.Switches.LeftFlipper); Switch right = SwitchManager.GetSwitch(SwitchConstants.Switches.RightFlipper); if (left.State == SwitchState.On && right.State == SwitchState.On) { if (PlayerStatus.CurrentPlayer.PlayerCharacter == Characters.unknown) { string player = DisplayManager.GetCharacterSelection(); switch (player.ToLower()) { case "maria": PlayerStatus.CurrentPlayer.PlayerCharacter = Characters.Maria; break; case "sypha": PlayerStatus.CurrentPlayer.PlayerCharacter = Characters.Sypha; break; case "grant": PlayerStatus.CurrentPlayer.PlayerCharacter = Characters.Grant; break; case "alucard": PlayerStatus.CurrentPlayer.PlayerCharacter = Characters.Alucard; break; case "richter": default: PlayerStatus.CurrentPlayer.PlayerCharacter = Characters.Richter; break; } _instance.StartPlayIntro(); } } } } //else // continue; //TODO: check for long press status update break; default: break; }//end switch }