/// <summary> /// /// </summary> /// <param name="data"></param> private void OnNavigate(UINavigationData data) { if (_state != State.Selecting) { return; } switch (data.direction) { case UINavigationDirection.Up: _selectedSkinIndex += 1; break; case UINavigationDirection.Down: _selectedSkinIndex -= 1; break; case UINavigationDirection.Right: do { _selectedCharacterIndex += 1; _selectedCharacterIndex = MathExtensions.Mod(_selectedCharacterIndex, Bootstrap.instance.data.characters.Count); } while (!matchSettingsManager.IsCharacterAvailable(characterDescriptor)); _selectedSkinIndex = 0; break; case UINavigationDirection.Left: do { _selectedCharacterIndex -= 1; _selectedCharacterIndex = MathExtensions.Mod(_selectedCharacterIndex, Bootstrap.instance.data.characters.Count); } while (!matchSettingsManager.IsCharacterAvailable(characterDescriptor)); _selectedSkinIndex = 0; break; } while (_selectedSkinIndex < 0) { _selectedSkinIndex = characterDescriptor.skinDescriptors.Count; } _selectedSkinIndex %= characterDescriptor.skinDescriptors.Count; if (data.direction == UINavigationDirection.Up || data.direction == UINavigationDirection.Down) { return; } this.EmitSound(NavigateSoundKey); TweenExtensions.SafeComplete(ref _cycleSequence); _cycleSequence = DOTween.Sequence(); _cycleSequence.Append(transform.DOLocalMoveX(transform.position.x + 3f, 0.05f)); _cycleSequence.Append(transform.DOLocalMoveX(transform.position.x - 3f, 0.05f)); _cycleSequence.Append(transform.DOLocalMoveX(transform.position.x, 0.05f)); _cycleSequence.SetLoops(1); UpdateCharacterInfo(); }
/// <summary> /// /// </summary> private void SettingsTabCycle() { if (InputHelper.AnyAxis(PrevInputName) != 0.0f || (isNavigatingTabs && InputHelper.GetAnyUIHorizontalAxis() < 0.0f)) { if (!_isPrevPressed) { _currentOptionIndex -= 1; _currentOptionIndex = MathExtensions.Mod(_currentOptionIndex, _optionIndex); FocusChanged(); } _isPrevPressed = true; } else { _isPrevPressed = false; } if (InputHelper.AnyAxis(NextInputName) != 0.0f || (isNavigatingTabs && InputHelper.GetAnyUIHorizontalAxis() > 0.0f)) { if (!_isNextPressed) { _currentOptionIndex += 1; _currentOptionIndex = MathExtensions.Mod(_currentOptionIndex, _optionIndex); FocusChanged(); } _isNextPressed = true; } else { _isNextPressed = false; } GameObject selectedPanel = null; _tabsToUnfocus.Clear(); switch (_optionTexts[_currentOptionIndex]) { case "Gameplay": _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>()); _gameplayPanel.SetActive(true); _controlsPanel.SetActive(false); _videoPanel.SetActive(false); _audioPanel.SetActive(false); selectedPanel = _gameplayPanel; break; case "Controls": _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>()); _controlsPanel.SetActive(true); selectedPanel = _controlsPanel; break; case "Video": _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_audioPanel.GetComponent <SettingsTabUINavigation>()); _videoPanel.SetActive(true); selectedPanel = _videoPanel; break; case "Audio": _tabsToUnfocus.Add(_gameplayPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_controlsPanel.GetComponent <SettingsTabUINavigation>()); _tabsToUnfocus.Add(_videoPanel.GetComponent <SettingsTabUINavigation>()); _audioPanel.SetActive(true); selectedPanel = _audioPanel; break; } foreach (var tabToUnfocus in _tabsToUnfocus) { if (tabToUnfocus != null) { tabToUnfocus.Unfocus(true); tabToUnfocus.gameObject.SetActive(false); } } var navigation = selectedPanel?.GetComponent <SettingsTabUINavigation>(); if (navigation != null) { navigation.panelNavigationHandler = this; if (!isNavigatingTabs && !navigation.hasFocus) { navigation.SetLastAxes(Vector2.one); navigation.Focus(); } } }