protected void SwitchSelectedModifier(int newIndex, EditorTileModifierCategory currentCategory)
    {
        EditorSelectedTileModifierContainer selectedTileModifierContainer = EditorCanvasUI.Instance.SelectedTileModifierContainer;

        if (EditorModificationPanelContainer.Instance.SelectedPanel is IEditorTileModificationPanel)
        {
            IEditorTileModificationPanel selectedPanel = EditorModificationPanelContainer.Instance.SelectedPanel as IEditorTileModificationPanel;
            selectedPanel.DestroyModifierActions();
        }

        // try previous category
        if (newIndex < 0)
        {
            EditorTileModifierCategory previousEditorTileModifierCategory = PreviousEditorTileModifierCategory(currentCategory);

            bool landedAtCategory = false;

            while (!landedAtCategory)
            {
                if (selectedTileModifierContainer.CurrentlyAvailableTileModifiers.TryGetValue(previousEditorTileModifierCategory, out List <IEditorTileModifier> editorTileModifiers))
                {
                    int modifierCount      = editorTileModifiers.Count;
                    int lastAvailableIndex = modifierCount - 1;
                    selectedTileModifierContainer.SetSelectedTileModifierCategory(previousEditorTileModifierCategory);
                    selectedTileModifierContainer.SetSelectedTileModifier(lastAvailableIndex);
                    landedAtCategory = true;
                }
                else
                {
                    // there are no modifiers in the previous category. Try the category before that
                    EditorTileModifierCategory lastQueriedModifierCategory = previousEditorTileModifierCategory;
                    previousEditorTileModifierCategory = PreviousEditorTileModifierCategory(lastQueriedModifierCategory);
                }
            }
        }
        else if (newIndex >= _editorSelectedModifierContainer.CurrentlyAvailableTileModifiers[currentCategory].Count) // try next category
        {
            EditorTileModifierCategory nextEditorTileModifierCategory = NextEditorTileModifierCategory(currentCategory);

            bool landedAtCategory = false;

            while (!landedAtCategory)
            {
                if (selectedTileModifierContainer.CurrentlyAvailableTileModifiers.TryGetValue(nextEditorTileModifierCategory, out List <IEditorTileModifier> editorTileModifiers))
                {
                    selectedTileModifierContainer.SetSelectedTileModifierCategory(nextEditorTileModifierCategory);
                    selectedTileModifierContainer.SetSelectedTileModifier(0);
                    landedAtCategory = true;
                }
                else
                {
                    // there are no modifiers in the next category. Try the category after that
                    EditorTileModifierCategory lastQueriedModifierCategory = nextEditorTileModifierCategory;
                    nextEditorTileModifierCategory = NextEditorTileModifierCategory(lastQueriedModifierCategory);
                }
            }
        }
    }
예제 #2
0
    public void SelectNextModifierCategory()
    {
        if (EditorCanvasUI.Instance.SelectedTileModifierContainer.UsedTileModifierCategories.Count == 1)
        {
            return;
        }

        EditorTileModifierCategory          currentCategory = EditorManager.SelectedTileModifierCategory;
        EditorSelectedTileModifierContainer selectedTileModifierContainer = EditorCanvasUI.Instance.SelectedTileModifierContainer;


        if (EditorModificationPanelContainer.Instance.SelectedPanel is IEditorTileModificationPanel)
        {
            IEditorTileModificationPanel selectedPanel = EditorModificationPanelContainer.Instance.SelectedPanel as IEditorTileModificationPanel;
            selectedPanel.DestroyModifierActions();
        }

        EditorTileModifierCategory nextEditorTileModifierCategory = NextEditorTileModifierCategory(currentCategory);

        bool landedAtCategory = false;

        while (!landedAtCategory)
        {
            if (selectedTileModifierContainer.CurrentlyAvailableTileModifiers.TryGetValue(nextEditorTileModifierCategory, out List <IEditorTileModifier> editorTileModifiers))
            {
                selectedTileModifierContainer.SetSelectedTileModifierCategory(nextEditorTileModifierCategory);
                selectedTileModifierContainer.SetSelectedTileModifier(0);
                landedAtCategory = true;
            }
            else
            {
                // there are no modifiers in the next category. Try the category after that
                EditorTileModifierCategory lastQueriedModifierCategory = nextEditorTileModifierCategory;
                nextEditorTileModifierCategory = NextEditorTileModifierCategory(lastQueriedModifierCategory);
            }
        }
    }