Beispiel #1
0
    private void OnGUI()
    {
        minSize = new Vector2(300, 200);
        maxSize = minSize;

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("ROOM EDITOR", _style2);
        EditorGUILayout.Space();
        EditorGUI.DrawRect(GUILayoutUtility.GetRect(100, 2), Color.black);

        bool createRoom = GUI.Button(new Rect(75, 50, 150, 50), "Create a Room");

        if (createRoom)
        {
            RoomConfigEditor roomConfig = (RoomConfigEditor)GetWindow(typeof(RoomConfigEditor));
            roomConfig.Show();
            roomConfig.nameRoom        = "New Room";
            roomConfig.normal          = 25;
            roomConfig.traps           = 25;
            roomConfig.enemies         = 25;
            roomConfig.difficulty      = 25;
            RoomConfigEditor.sizeImage = Vector2.one * 5;
            Close();
        }

        bool loadRoom = GUI.Button(new Rect(75, 110, 150, 50), "Load Room");

        if (loadRoom)
        {
            LoadRoom roomLoader = (LoadRoom)GetWindow(typeof(LoadRoom));
            roomLoader.Show();
            Close();
        }
    }
Beispiel #2
0
    private void OnGUI()
    {
        EditorGUILayout.Space();

        roomScriptable = (RoomConfig)EditorGUILayout.ObjectField("Room", roomScriptable, typeof(RoomConfig), false);
        if (roomScriptable != null)
        {
            EditorUtility.SetDirty(roomScriptable);
        }

        bool variant = GUI.Button(new Rect(0, 80, position.width / 2, position.height - 92), "MakeVariant");

        if (variant)
        {
            if (roomScriptable != null)
            {
                RoomConfigEditor RCE = (RoomConfigEditor)GetWindow(typeof(RoomConfigEditor));
                RCE.wantsMouseMove = true;
                RCE.Show();
                RCE.nameRoom               = roomScriptable.roomName;
                RCE.normal                 = roomScriptable.normalTiles;
                RCE.traps                  = roomScriptable.traps;
                RCE.enemies                = roomScriptable.enemys;
                RCE.difficulty             = roomScriptable.enemysDif;
                RCE.roomScriptableV        = roomScriptable;
                RCE.variant                = true;
                RoomConfigEditor.sizeImage = new Vector2(roomScriptable.width, roomScriptable.height);
            }
            else
            {
                error = true;
            }
        }

        bool edit = GUI.Button(new Rect(position.width / 2, 80, position.width / 2, position.height - 92), "Edit");

        if (edit)
        {
            if (roomScriptable != null)
            {
                RoomConfigEditor.sizeImage.x = roomScriptable.width;
                RoomConfigEditor.sizeImage.y = roomScriptable.height;
                RoomEditor roomEditorWindow = (RoomEditor)GetWindow <RoomEditor>();
                roomEditorWindow.wantsMouseMove           = true;
                roomEditorWindow.zoom                     = 30;
                roomEditorWindow.myStyle                  = new GUIStyle();
                roomEditorWindow.myStyle.fontSize         = 50;
                roomEditorWindow.myStyle.normal.textColor = Color.yellow;
                roomEditorWindow.myStyle.alignment        = TextAnchor.MiddleCenter;
                roomEditorWindow.re = roomEditorWindow;
                roomEditorWindow.Show();
                roomEditorWindow.roomScriptable = roomScriptable;
                RoomEditor.layers = roomScriptable.layers;
                roomEditorWindow.texturesLayers      = roomScriptable.texturesLayers;
                roomEditorWindow.spritesCreateLayers = roomScriptable.spritesCreateLayers;
                roomEditorWindow.centerTextures      = roomScriptable.centerTextures;
                roomEditorWindow.setDefaultTexture   = true;
                roomEditorWindow.roomTextures        = roomScriptable.roomTextures;
                roomEditorWindow.colors = new Color[(int)RoomConfigEditor.sizeImage.x, (int)RoomConfigEditor.sizeImage.y];
                if (!RoomConfigEditor.load)
                {
                    for (int x = 0; x < (int)RoomConfigEditor.sizeImage.x; x++)
                    {
                        for (int y = 0; y < (int)RoomConfigEditor.sizeImage.y; y++)
                        {
                            roomEditorWindow.colors[x, y] = Color.gray;
                        }
                    }
                }
            }
            else
            {
                error = true;
            }
        }

        if (error)
        {
            EditorGUILayout.HelpBox("Add Room", MessageType.Error);
        }
        minSize = new Vector2(300, 150);
        maxSize = minSize;
    }