Ejemplo n.º 1
0
    public void SetCurrentlyAvailableModifierCategories(EditorTileMainModifierCategory mainTileModifierCategory)
    {
        CurrentlyAvailableTileModifiers.Clear();

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

        if (mainTileModifierCategory is EditorMazeTileGroundModifierCategory || mainTileModifierCategory is EditorOverworldTileGroundModifierCategory)
        {
            Logger.Log("SetCurrentlyAvailableModifiers for ground");
            SetCurrentlyAvailableGroundModifiers();
        }
        else if (mainTileModifierCategory is EditorMazeTileWaterModifierCategory || mainTileModifierCategory is EditorOverworldTileWaterModifierCategory)
        {
            Logger.Log("SetCurrentlyAvailableModifiers for water");
            SetCurrentlyAvailableWaterModifiers();
        }
        else if (mainTileModifierCategory is EditorMazeTileAreaModifierCategory || mainTileModifierCategory is EditorOverworldTileAreaModifierCategory)
        {
            Logger.Log("SetCurrentlyAvailableModifiers for areas");
            SetCurrentlyAvailableAreaModifiers();
        }
        else
        {
            Logger.Error($"Unknown modifier category {mainTileModifierCategory}");
        }
    }
    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);
                }
            }
        }
    }
Ejemplo n.º 3
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);
            }
        }
    }