Пример #1
0
        //paint tools (clear / fill)
        void ShowGUIPaintTools()
        {
            GUI.Box(new Rect(Screen.width - 150, Screen.height - 255, 150, 50), "");

            if (GUI.Button(new Rect(Screen.width - 140, Screen.height - 250, 40, 40), "clear"))
            {
                creator.FillLayerGround();
                BuildMap();
            }

            if (GUI.Button(new Rect(Screen.width - 95, Screen.height - 250, 40, 40), "fill"))
            {
                creator.FillLayerBlock();
                BuildMap();
            }
        }
Пример #2
0
    //SHOW EDIT
    //------------------
    public void ShowEdit()
    {
        //SHOW EDIT
        GUILayout.BeginVertical("Box", GUILayout.ExpandWidth(false));


        EditorGUILayout.HelpBox("Left Click Add / Right Click Remove Cell" + "\n" + "Undo/Redo: Z + Y" + "\n" + "Show/Hide grid: H", MessageType.Info);

        GUILayout.BeginHorizontal();
        GUILayout.Label("Show Grid:");
        creator.configuration.ui.showGrid = EditorGUILayout.Toggle(creator.configuration.ui.showGrid);

        GUILayout.Label("Show Grid on deselect:");
        creator.configuration.ui.showGridAlways = EditorGUILayout.Toggle(creator.configuration.ui.showGridAlways);
        GUILayout.EndHorizontal();

        creator.configuration.ui.autoBuild = EditorGUILayout.Toggle("Automatic build:", creator.configuration.ui.autoBuild);

        //GUILayout.BeginHorizontal();
        //creator.brushx2 = EditorGUILayout.Toggle("Brush size x2:", creator.brushx2);
        //GUILayout.Label("enable recommended");
        //GUILayout.EndHorizontal();
        creator.configuration.ui.brushSize = EditorGUILayout.IntSlider("Brush size:", creator.configuration.ui.brushSize, 2, 5);

        creator.configuration.ui.cellColor      = EditorGUILayout.ColorField("Cell Color:", creator.configuration.ui.cellColor);
        creator.configuration.ui.floorCellColor = EditorGUILayout.ColorField("Floor Color:", creator.configuration.ui.floorCellColor);
        creator.configuration.ui.gridColor      = EditorGUILayout.ColorField("Grid Color:", creator.configuration.ui.gridColor);
        creator.configuration.ui.brushColor     = EditorGUILayout.ColorField("Brush Color:", creator.configuration.ui.brushColor);

        creator.configuration.ui.maskColor = EditorGUILayout.ColorField("Mask Color:", creator.configuration.ui.maskColor);

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.BeginHorizontal();


        //fill layer
        if (GUILayout.Button(iconFillBlock, GUILayout.Width(35), GUILayout.Height(35)))
        {
            if (!creator.configuration.worldMap[creator.configuration.ui.mapIndex].paintMask)
            {
                creator.FillLayerBlock();
            }
            else
            {
                creator.configuration.worldMap[creator.configuration.ui.mapIndex].maskMap = new bool[creator.configuration.global.width, creator.configuration.global.height];
            }
        }

        if (GUILayout.Button(iconFillFloor, GUILayout.Width(35), GUILayout.Height(35)))
        {
            if (!creator.configuration.worldMap[creator.configuration.ui.mapIndex].paintMask)
            {
                creator.FillLayerGround();
            }
            else
            {
                for (int ym = 0; ym < creator.configuration.worldMap[creator.configuration.ui.mapIndex].maskMap.GetLength(1); ym++)
                {
                    for (int xm = 0; xm < creator.configuration.worldMap[creator.configuration.ui.mapIndex].maskMap.GetLength(0); xm++)
                    {
                        creator.configuration.worldMap[creator.configuration.ui.mapIndex].maskMap[xm, ym] = true;
                    }
                }
            }
        }

        //copy / paste layer
        //copy map from layer
        if (GUILayout.Button(iconCopyMap, GUILayout.Width(35), GUILayout.Height(35)))
        {
            creator.CopyMapFromLayer();
        }
        //paste map to layer
        if (GUILayout.Button(iconPasteMap, GUILayout.Width(35), GUILayout.Height(35)))
        {
            creator.PasteMapToLayer();
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();

        GUILayout.BeginVertical("Box");
        GUILayout.BeginHorizontal();
        GUILayout.Label(iconLayer, GUILayout.Width(20), GUILayout.Height(20));
        GUILayout.Label("Layers");
        GUILayout.EndHorizontal();


        GUILayout.BeginVertical("TextArea");

        //show layers
        for (int l = creator.configuration.worldMap.Count - 1; l >= 0; l--)
        {
            if (creator.configuration.ui.mapIndex == l)
            {
                GUI.color = guiBlue;
            }


            GUILayout.BeginHorizontal("Box");
            GUI.color = Color.white;

            GUILayout.Label(iconLayer, GUILayout.Width(20), GUILayout.Height(18));
            if (GUILayout.Button("Layer: " + (l + 1).ToString(), "Label", GUILayout.Height(18)))
            {
                creator.configuration.ui.mapIndex = l;

                for (int pm = 0; pm < creator.configuration.worldMap.Count; pm++)
                {
                    creator.configuration.worldMap[pm].paintMask = false;
                }
            }

            creator.configuration.global.layerPresetIndex[l] = EditorGUILayout.Popup(creator.configuration.global.layerPresetIndex[l], creator.configuration.ui.availablePresets);
            //EditorGUILayout.LayerField(0, GUILayout.Width(50));

            //duplicate layer
            if (GUILayout.Button(iconDuplicate, "ToolbarButton", GUILayout.Height(18), GUILayout.Width(20)))
            {
                creator.AddNewLayer(true, false, 0, true, l);
            }


            GUI.color = guiRed;
            if (l != 0)
            {
                if (GUILayout.Button("x", "ToolbarButton", GUILayout.Height(18), GUILayout.Width(20)))
                {
                    creator.RemoveLayer(l);
                }
            }
            GUI.color = Color.white;

            GUILayout.EndHorizontal();


            //Mask Layers
            if (l < creator.configuration.worldMap.Count)
            {
                if (creator.configuration.worldMap[l].useMask)
                {
                    if (creator.configuration.worldMap[l].paintMask)
                    {
                        GUI.color = guiBluelight;
                    }

                    GUILayout.BeginHorizontal();

                    GUILayout.Label(iconMaskLayerArrow, GUILayout.Width(20), GUILayout.Height(18));

                    GUILayout.BeginHorizontal("Box");
                    GUI.color = Color.white;

                    if (GUILayout.Button("Select", "ToolbarButton", GUILayout.Height(18)))
                    {
                        creator.configuration.ui.mapIndex = l;


                        for (int pm = 0; pm < creator.configuration.worldMap.Count; pm++)
                        {
                            if (pm == creator.configuration.ui.mapIndex)
                            {
                                if (!creator.configuration.worldMap[l].paintMask)
                                {
                                    creator.configuration.worldMap[l].paintMask = true;
                                }
                                else
                                {
                                    creator.configuration.worldMap[l].paintMask = false;
                                }
                            }
                            else
                            {
                                creator.configuration.worldMap[pm].paintMask = false;
                            }
                        }
                    }

                    GUILayout.Label("Mask: " + (l + 1).ToString());

                    GUI.color = Color.white;

                    creator.configuration.worldMap[l].selectedMask = EditorGUILayout.Popup(creator.configuration.worldMap[l].selectedMask, _maskNames);

                    if (GUILayout.Button("apply", "ToolbarButton", GUILayout.Height(15), GUILayout.Width(50)))
                    {
                        creator.configuration.worldMap[l].maskMap = new bool[creator.configuration.global.width, creator.configuration.global.height];
                        creator.configuration.worldMap[l].maskMap = creator.iMasks[creator.configuration.worldMap[l].selectedMask].ApplyMask(creator.configuration.worldMap[l].cellMap, creator.GetComponent <TileWorldCreator>(), creator.configuration);


                        if (creator.firstTimeBuild)
                        {
                            //creator.BuildMapEditor();
                            creator.BuildMapComplete(false, false, true);
                        }
                        else
                        {
                            if (creator.configuration.global.buildOverlappingTiles)
                            {
                                //creator.BuildMapPartial(true);
                                //creator.BuildMapPartial(false, false, 0, 0);
                                creator.BuildMapPartial(false, false);
                            }
                            else
                            {
                                creator.firstTimeBuild = true;
                                //creator.BuildMapEditor();
                                creator.BuildMapComplete(false, false, true);
                            }
                        }

                        //update one dim array to make sure they are updated when saving map
                        creator.UpdateMap();
                    }

                    GUI.color = guiRed;
                    if (GUILayout.Button("x", "ToolbarButton", GUILayout.Height(15), GUILayout.Width(20)))
                    {
                        creator.configuration.worldMap[l].useMask = false;
                    }
                    GUI.color = Color.white;

                    GUILayout.EndHorizontal();

                    GUILayout.EndHorizontal();
                    GUILayout.Space(4);
                }
            }


            //GUILayout.Space(6);
        }
        GUILayout.Space(6);
        GUILayout.EndVertical();


        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Add new layer"))
        {
            creator.AddNewLayer(true, false, 0, false, 0);
        }

        if (GUILayout.Button("Add mask"))
        {
            if (!creator.configuration.worldMap[creator.configuration.ui.mapIndex].useMask)
            {
                creator.AddNewMask(creator.configuration.ui.mapIndex);
            }
        }

        GUILayout.EndHorizontal();

        GUILayout.EndVertical();


        GUILayout.EndVertical();
    }