public void Initialize(ILocalizationManager localizationManager,
                           ICommandDispatcher commandDispatcher,
                           LoadSceneCommandFactory loadSceneCommandFactory,
                           IInputManager inputManager,
                           SetGamePausedCommandFactory setGamePausedCommandFactory,
                           SignalBus signalBus)
    {
        _localizationManager         = localizationManager;
        _commandDispatcher           = commandDispatcher;
        _loadSceneCommandFactory     = loadSceneCommandFactory;
        _inputManager                = inputManager;
        _setGamePausedCommandFactory = setGamePausedCommandFactory;
        _signalBus = signalBus;

        _resumeGameButton.onClick.AddListener(() => _commandDispatcher.ExecuteCommand(_setGamePausedCommandFactory.Create(false)));
        //TODO: Add confirmation menu
        _restartGameButton.onClick.AddListener(() => _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.SinglePlayerSceneIndex, true, true, Constants.SinglePlayerSceneIndex)));
        _settingsButton.onClick.AddListener(() => _signalBus.Fire(new SettingsShouldShowChangedSignal {
            ShowSettings = true
        }));
        _mainMenuButton.onClick.AddListener(() => _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.MainMenuSceneIndex, false, true, Constants.SinglePlayerSceneIndex)));
        //TODO: Add confirmation menu
        _quitGameButton.onClick.AddListener(() => Application.Quit());

        OnLanguageChanged();
    }
Пример #2
0
    public void Start()
    {
        _commandDispatcher.ExecuteCommand(_initializeSettingsCommandFactory.Create());
        _commandDispatcher.ExecuteCommand(_initializeLocationCommandFactory.Create());

        _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.LoginSceneIndex, false, true));
    }
Пример #3
0
        private bool SafeExecuteCommand(ITextView textView, string command, string args = "")
        {
            bool postCommand = false;

            if (textView != null && textView.TextBuffer.ContentType.IsCPlusPlus())
            {
                if (command.Equals(CommandNameGoToDefinition, StringComparison.OrdinalIgnoreCase) ||
                    command.Equals(CommandNameGoToDeclaration, StringComparison.OrdinalIgnoreCase))
                {
                    // C++ commands like 'Edit.GoToDefinition' need to be
                    // posted instead of executed and they need to have a null
                    // argument in order to work like it does when bound to a
                    // keyboard shortcut like 'F12'. Reported in issue #2535.
                    postCommand = true;
                    args        = null;
                }
            }

            try
            {
                return(_commandDispatcher.ExecuteCommand(textView, command, args, postCommand));
            }
            catch
            {
                return(false);
            }
        }
    private void Initialize(ICommandDispatcher commandDispatcher, LoadSceneCommandFactory loadSceneCommandFactory)
    {
        _commandDispatcher       = commandDispatcher;
        _loadSceneCommandFactory = loadSceneCommandFactory;

        _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.MainMenuSceneIndex, false, true));
    }
    public void Initialize(ILocalizationManager localizationManager,
                           ICommandDispatcher commandDispatcher,
                           LoadSceneCommandFactory loadSceneCommandFactory,
                           SignalBus signalBus,
                           LogoutUserCommandFactory logoutUserCommandFactory,
                           SettingsContainer settingsContainer)
    {
        _localizationManager     = localizationManager;
        _commandDispatcher       = commandDispatcher;
        _loadSceneCommandFactory = loadSceneCommandFactory;
        _signalBus = signalBus;
        _logoutUserCommandFactory = logoutUserCommandFactory;
        _settingsContainer        = settingsContainer;

        //TODO: Add difficulty selection
        _startSinglePlayerGameButton.onClick.AddListener(() =>
        {
            _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.SinglePlayerSceneIndex, false, true, Constants.MainMenuSceneIndex));
            SceneManager.UnloadSceneAsync(Constants.MainMenuSceneIndex);
        });
        _startMultiPlayerGameButton.onClick.AddListener(() =>
        {
            _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.MultiPlayerSceneIndex, false, true, Constants.MainMenuSceneIndex));
            SceneManager.UnloadSceneAsync(Constants.MainMenuSceneIndex);
        });
        _openSettingsButton.onClick.AddListener(() =>
        {
            //TODO: Change to command
            _signalBus.Fire(new SettingsShouldShowChangedSignal {
                ShowSettings = true
            });
        });
        //TODO: Make confirmation menu
        _logoutUserButton.onClick.AddListener(() =>
        {
            _commandDispatcher.ExecuteCommand(_logoutUserCommandFactory.Create());
            _commandDispatcher.ExecuteCommand(_loadSceneCommandFactory.Create(Constants.LoginSceneIndex, false, true, Constants.MainMenuSceneIndex));
        });
        _quitGameButton.onClick.AddListener(() => Application.Quit());

        OnLanguageChanged();
    }
    private void Initialize(
        ILocalizationManager localizationManager,
        SignalBus signalBus,
        SettingsContainer settingsContainer,
        ChangeVolumeCommandFactory changeVolumeCommandFactory,
        ChangeLanguageCommandFactory changeLanguageCommandFactory,
        ICommandDispatcher commandDispatcher)
    {
        _localizationManager          = localizationManager;
        _signalbus                    = signalBus;
        _settingsContainer            = settingsContainer;
        _changeVolumeCommandFactory   = changeVolumeCommandFactory;
        _changeLanguageCommandFactory = changeLanguageCommandFactory;
        _commandDispatcher            = commandDispatcher;

        _backButton.onClick.AddListener(OnCloseSettings);

        _masterVolumeSlider.value = _settingsContainer.Settings.MasterVolume;
        _masterVolumeSlider.onValueChanged.AddListener(SetMasterVolume);
        _musicVolumeSlider.value = _settingsContainer.Settings.MusicVolume;
        _musicVolumeSlider.onValueChanged.AddListener(SetMusicVolume);
        _sfxVolumeSlider.value = _settingsContainer.Settings.SFXVolume;
        _sfxVolumeSlider.onValueChanged.AddListener(SetSFXVolume);

        _languageSelectionDropdown.onValueChanged.AddListener(language => _commandDispatcher.ExecuteCommand(_changeLanguageCommandFactory.Create(SupportedLanguages.Languages[language])));
        _languageSelectionDropdown.AddOptions(SupportedLanguages.Languages.Select(language => new TMP_Dropdown.OptionData(Constants.IsoToLocalizedLanguages[language])).ToList());
        _languageSelectionDropdown.value = SupportedLanguages.Languages.Contains(_localizationManager.CurrentLanguage) ? Array.IndexOf(SupportedLanguages.Languages, _localizationManager.CurrentLanguage) : 0;

        _autoSaveToggle.isOn = _settingsContainer.Settings.AutoSave;
        _autoSaveToggle.onValueChanged.AddListener(SetAutoSaveEnabled);

        _autoLoginToggle.isOn = _settingsContainer.Settings.AutoLogin;
        _autoLoginToggle.onValueChanged.AddListener(SetAutoLoginEnabled);

        _saveAndExitButton.onClick.AddListener(() =>
        {
            SaveChanges();
            OnCloseSettings();
        });

        OnLanguageChanged();
    }
Пример #7
0
        public void DequeueAndDispatchCommands()
        {
            var commands = _commandQueue.DeQueueCommands(_queueName);

            foreach (var cmd in commands)
            {
                try
                {
                    _commandDispatcher.ExecuteCommand <TAggregate>(cmd);
                }
                catch (Exception ex)
                {
                    var failureEvent = new EventFailedBase(cmd.AggregateId, ex.Message);
                    failureEvent.Metadata.CausationId   = cmd.Metadata.CausationId;
                    failureEvent.Metadata.CorrelationId = cmd.Metadata.CorrelationId;
                    _eventStore.CommitEvents <TAggregate>(new List <IEvent> {
                        failureEvent
                    });
                }
            }
        }
 private void SpawnBoard()
 {
     _commandDispatcher.ExecuteCommand(_spawnBoardCommandFactory.Create());
 }
 private void SetVolume(SoundType soundType, float volume)
 {
     _commandDispatcher.ExecuteCommand(_changeVolumeCommandFactory.SetVolume(soundType, volume));
 }
 private void OnRegisterUser()
 {
     _commandDispatcher.ExecuteCommand(_registerUserCommandFactory.Create(_username, _userPassword));
 }
Пример #11
0
 private void OnPauseKeyClicked()
 {
     _commandDispatcher.ExecuteCommand(_setGamePausedCommandFactory.Create());
 }