Exemple #1
0
    public void Process(MissionEvent ev)
    {
        switch (_currentState)
        {
        case MissionState.LAUNCHING:
            if (ev == MissionEvent.LAUNCHED)
            {
                _currentState = MissionState.SPIN_WHEEL;
                _lightsManager.SetWheelMission();
            }
            break;

        case MissionState.SPIN_WHEEL:
            if (ev == MissionEvent.WHEEL_FILL)
            {
                if (Random.value < 0.5)
                {
                    _currentState = MissionState.TAKE_RAMP;
                    _lightsManager.SetRampMission();
                }
                else
                {
                    _currentState = MissionState.HIT_TARGETS;
                    _lightsManager.SetTargetsMission();
                }
                _scoreManager.AddScore(ScoreManager.MISSION_SCORE);
            }
            if (ev == MissionEvent.BALL_LOST)
            {
                _currentState = MissionState.LAUNCHING;
                _ballManager.LoseBall();
            }
            break;

        case MissionState.TAKE_RAMP:
            if (ev == MissionEvent.RAMP_TAKEN)
            {
                _currentState = MissionState.LOCK_BALL;
                _lightsManager.SetLockMission();
                _scoreManager.AddScore(ScoreManager.MISSION_SCORE);
            }
            if (ev == MissionEvent.BALL_LOST)
            {
                _currentState = MissionState.LAUNCHING;
                _ballManager.LoseBall();
            }
            break;

        case MissionState.HIT_TARGETS:
            if (ev == MissionEvent.TARGET_FILL)
            {
                _currentState = MissionState.LOCK_BALL;
                _lightsManager.SetLockMission();
                _scoreManager.AddScore(ScoreManager.MISSION_SCORE);
            }
            if (ev == MissionEvent.BALL_LOST)
            {
                _currentState = MissionState.LAUNCHING;
                _ballManager.LoseBall();
            }
            break;

        case MissionState.LOCK_BALL:
            if (ev == MissionEvent.BALL_LOCKED)
            {
                _missionCount++;
                if (_missionCount == MissionsRequired)
                {
                    _currentState   = MissionState.MULTIBALL;
                    _multiballCount = 3;
                }
                else
                {
                    _currentState = MissionState.LAUNCHING;
                }
                _scoreManager.AddScore(ScoreManager.MISSION_SCORE);
            }
            if (ev == MissionEvent.BALL_LOST)
            {
                _currentState = MissionState.LAUNCHING;
                _ballManager.LoseBall();
            }
            break;

        case MissionState.MULTIBALL:
            if (ev == MissionEvent.BALL_LOST)
            {
                _multiballCount--;
                if (_multiballCount == 1)
                {
                    _currentState = MissionState.SPIN_WHEEL;
                    _lightsManager.SetWheelMission();
                }
            }
            break;
        }
    }