예제 #1
0
        /// <summary>
        /// Player lost a ball.  This is where we decrement the number of
        /// balls on the playfield and test for end of game or end of ball.
        /// </summary>
        public void BallDrained()
        {
            bool ballLost = TroughManager.BallDrained(_isTilted);

            //check if that's the last ball
            if (ballLost) //that last outlane counted.
            {
                //time to check the trough if it's full
                Task.Factory.StartNew(() =>
                {
                    int counter = 2;
                    bool isTroughFull;
                    do
                    {
                        isTroughFull = TroughManager.WaitForAllBalls(300, false);
                        counter--;
                    } while (!isTroughFull || counter >= 0);
                    if (isTroughFull)
                    {
                        EndOfBall();
                    }
                });
            }
            else //ball was saved.  play animation
            {
                DisplayManager.PlayCutScene(DisplayConstants.CutScenes.Bonuses.SHOOTAGAIN);
            }
        }
            private void beginPlay()
            {
                enterRoom();

                TroughManager.BallSaverState = BallSaverStates.Waiting; //waiting for ejection
                TroughManager.EjectBall();
            }
예제 #3
0
 /// <summary>
 /// Reinitialize the Table for a new ball (either a new ball after
 /// the player has lost one or we have moved onto the next player.
 /// </summary>
 public void ResetForNewPlayer()
 {
     TroughManager.Reset();
     _isTilted = false;
     Task.Factory.StartNew(() =>
     {
         if (PlayerStatus.CurrentPlayer.PlayerCharacter == Characters.unknown)
         {
             _inputMode = InputMode.SelectPlayer;
             DisplayManager.PlaySequence(DisplayConstants.Modes.ActiveGameMode.SubModes.CharacterSelectMode.CHARSELECT); //send high scores
         }
         else
         {
             //Need to task this out otherwise we get a AccessViolation and currupt memory.  unknown
             StartPlayIntro();
         }
     });
 }
예제 #4
0
        /// <summary>
        /// Initialize the table for a new game.
        /// </summary>
        public void ResetForNewGame()
        {
            PlayerStatus.Reset();
            AddPlayer();

            //TroughManager.CheckForStuckBall()
            //check quickly
            if (!TroughManager.WaitForAllBalls(5, false))
            {
                DisplayManager.PlayCutScene(DisplayConstants.CutScenes.Test.BALLSEARCH);
            }
            //ok, we've got a stuck ball somewhere.
            int attempts = 0;

            while (attempts < 5 && !TroughManager.WaitForAllBalls(5000, true))
            {
                DisplayManager.PlayCutScene(DisplayConstants.CutScenes.Test.BALLSEARCH);
                attempts++;
            }

            _isTilted = false;
        }
            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
            }