Example #1
0
        private Action <MenuActionId, Action> CloseMenu(MenuId menuId)
        {
            // Todo: What if we defer handling this to PlayingState?
            return((actionId, onComplete) => {
                // State transition to
                var transitToParachuteEditor = actionId == MenuActionId.ChangeParachute;
                if (actionId == MenuActionId.Back || actionId == MenuActionId.Resume)
                {
                    if (menuId == MenuId.Playing)
                    {
                        Machine.TransitionToParent(Maybe <RespawnRequest> .Nothing, transitToParachuteEditor);
                    }
                    else
                    {
                        Machine.TransitionToParent();
                    }
                }
                else if (actionId == MenuActionId.ChangeParachute)
                {
                    Machine.TransitionToParent(Maybe <RespawnRequest> .Nothing, transitToParachuteEditor);
                }
                else if (actionId == MenuActionId.Restart)
                {
                    Machine.TransitionToParent(Maybe.Just(new RespawnRequest()), transitToParachuteEditor);
                }
                else if (actionId == MenuActionId.StartSelection)
                {
                    Machine.Transition(VoloStateMachine.States.SpawnScreen);
                }
                else if (actionId == MenuActionId.TitleScreen)
                {
                    Machine.Transition(VoloStateMachine.States.TitleScreen);
                }
                else if (actionId == MenuActionId.MainMenu)
                {
                    Machine.Transition(VoloStateMachine.States.MainMenu);
                }
                else if (actionId == MenuActionId.Quit)
                {
                    _data.ApplicationQuitter.RequestQuit();
                }
                else
                {
                    throw new ArgumentException("Cannot handle " + actionId);
                }

                if (onComplete != null)
                {
                    onComplete();
                }
            });
        }
Example #2
0
        private IEnumerator <WaitCommand> OnEnter(MenuId menuId)
        {
            _data.SoundMixer.Pause(SoundLayer.GameEffects);

            Cursor.lockState = CursorLockMode.None;

            // Prevent any input events from another state to leak to
            // the options menu
            yield return(WaitCommand.WaitForNextFrame);

            _data.OptionsMenu.Open(menuId, CloseMenu(menuId));
            RuntimeManager.PlayOneShot("event:/ui/open");

            // Update the game settings with the ecology settings
            var currentSettings = _data.GameSettingsProvider.ActiveSettings;

            currentSettings.Gameplay.Time    = _data.Ecology.Time;
            currentSettings.Gameplay.Weather = _data.Ecology.Weather;
            _data.GameSettingsProvider.UpdateGameSettings(currentSettings);
        }