Exemple #1
0
        public void CreateLayoutElement(Transform element)
        {
            EditorApplication.delayCall += () => {
                EditorApplication.delayCall = null;

                FlowDatabase.AddLayoutElementComponent("LayoutElement", element.parent, element.GetSiblingIndex());
            };
        }
Exemple #2
0
        public static DungeonFlow GetRandomFlowFromNextDungeonPrefabForGlitchFloor()
        {
            int     NextLevelIndex = ReflectionHelpers.ReflectGetField <int>(typeof(GameManager), "nextLevelIndex", GameManager.Instance);
            Dungeon dungeon        = null;
            bool    useFallBack    = true;

            switch (NextLevelIndex)
            {
            case 2:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Castle");
                break;

            case 3:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Gungeon");
                break;

            case 4:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Mines");
                break;

            case 5:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Catacombs");
                break;

            case 6:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Forge");
                break;

            case 7:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Bullethell");
                break;

            default:
                dungeon = DungeonDatabase.GetOrLoadByName("Base_Mines");
                break;
            }
            DungeonFlow m_AssignedFallBackFlow = FlowDatabase.GetOrLoadByName(BraveUtility.RandomElement(GlitchChestFlows));
            DungeonFlow m_AssignedFlow         = FlowHelpers.DuplicateDungeonFlow(BraveUtility.RandomElement(dungeon.PatternSettings.flows));

            dungeon = null;
            foreach (DungeonFlowNode node in m_AssignedFlow.AllNodes)
            {
                if (node.roomCategory == PrototypeDungeonRoom.RoomCategory.BOSS)
                {
                    node.overrideExactRoom = ExpandPrefabs.doublebeholsterroom01;
                    useFallBack            = false;
                    break;
                }
            }
            if (useFallBack)
            {
                return(m_AssignedFallBackFlow);
            }
            else
            {
                return(m_AssignedFlow);
            }
        }
Exemple #3
0
        public static void CreateLayout()
        {
            LayoutWindowType layoutScreen = null;

            var name = string.Empty;

            var obj  = Selection.activeObject;
            var path = AssetDatabase.GetAssetPath(obj.GetInstanceID());

            if (path.Length > 0 && Directory.Exists(path) == true)
            {
            }
            else if (Selection.activeGameObject != null)
            {
                var screen = Selection.activeGameObject.GetComponent <WindowBase>();
                if (screen != null)
                {
                    var splitted = path.Split('/');
                    path = string.Join("/", splitted, 0, splitted.Length - 2).Trim('/');

                    path = path + "/Layouts";
                    if (Directory.Exists(path) == true)
                    {
                        layoutScreen = screen as LayoutWindowType;
                        name         = layoutScreen.name.Replace("Screen", "Layout");
                    }
                }
            }

            FlowChooserFilterWindow.Show <FlowWindowLayoutTemplate>(null, (element) => {
                // on select

                if (string.IsNullOrEmpty(name) == true)
                {
                    name = element.name + "Layout";
                }

                // Create an instance
                var layoutPrefab = FlowDatabase.GenerateLayout(path + "/" + name + ".prefab", element);

                if (layoutScreen != null)
                {
                    layoutScreen.layout.layout = layoutPrefab;
                    layoutScreen.OnValidate();
                    EditorUtility.SetDirty(layoutScreen);
                }

                Selection.activeObject = layoutPrefab;
            }, (element) => {
                // on gui

                var style      = new GUIStyle(GUI.skin.label);
                style.wordWrap = true;

                GUILayout.Label(element.comment, style);
            }, strongType: true);
        }
        public void RemoveLayoutElement(Transform element)
        {
            EditorApplication.delayCall += () => {
                //GameObject.DestroyImmediate(element.gameObject);
                //FlowSceneView.GetItem().SetLayoutDirty();

                FlowDatabase.RemoveLayoutComponent(element);
            };
        }
        private void DrawScreenChooser(float width)
        {
            var screens = new string[this.screens.Count + 1];

            screens[0] = "None";
            for (int i = 1; i < screens.Length; ++i)
            {
                screens[i] = this.screens[i - 1].name.Replace("Screen", string.Empty);
            }

            GUILayout.Label("Use existing screen:");

            var index = this.screenPrefab == null ? 0 : (System.Array.IndexOf(screens, this.screenPrefab.name.Replace("Screen", string.Empty)));

            index = EditorGUILayout.Popup(index, screens);
            if (index > 0)
            {
                this.screenPrefab = this.screens[index - 1];
            }

            this.screenPrefab = EditorGUILayout.ObjectField(this.screenPrefab, typeof(WindowBase), false) as WindowBase;
            if (GUILayout.Button("Load") == true)
            {
                this.LoadScreen(this.screenPrefab);
            }

            GUILayout.Label("Or create the new one:");

            if (GUILayout.Button("Create Screen...", GUILayout.Height(30f)) == true)
            {
                this.showScreenWindow = true;
            }

            if (Event.current.type == EventType.Repaint && this.showScreenWindow == true)
            {
                this.showScreenWindow = false;

                var commentStyle = new GUIStyle(EditorStyles.miniLabel);
                commentStyle.wordWrap = true;

                var rect = GUILayoutUtility.GetLastRect();
                rect.x += this.mainRect.x + this.currentView.position.x - this.scrollPosition.x + this.lastRect.x;
                rect.y += this.mainRect.y + this.currentView.position.y + rect.height - this.scrollPosition.y + this.lastRect.y + 15f;
                FlowDropDownFilterWindow.Show <FlowLayoutWindowTypeTemplate>(rect, (screen) => {
                    this.screenPrefab = FlowDatabase.GenerateScreen(this.window, screen);
                    this.ReloadScreens();
                    this.LoadScreen(this.screenPrefab);

                    this.isScreenDirty = true;
                }, (screen) => {
                    GUILayout.Label(screen.comment, commentStyle);
                }, strongType: true);

                Event.current.Use();
            }
        }
        private void DrawLayoutChooser(float width)
        {
            if (this.screenInstance == null)
            {
                return;
            }

            var layouts = new string[this.layouts.Count + 1];

            layouts[0] = "None";
            for (int i = 1; i < layouts.Length; ++i)
            {
                layouts[i] = this.layouts[i - 1].name.Replace("Layout", string.Empty);
            }

            GUILayout.Label("Use existing layout:");

            var index = this.layoutPrefab == null ? 0 : (System.Array.IndexOf(layouts, this.layoutPrefab.name.Replace("Layout", string.Empty)));

            index = EditorGUILayout.Popup(index, layouts);
            if (index > 0)
            {
                this.layoutPrefab = this.layouts[index - 1];
            }

            this.layoutPrefab = EditorGUILayout.ObjectField(this.layoutPrefab, typeof(WindowLayout), false) as WindowLayout;
            if (GUILayout.Button("Load") == true)
            {
                this.LoadLayout(this.layoutPrefab);
            }

            GUILayout.Label("Or create the new one:");

            if (GUILayout.Button("Create Layout...", GUILayout.Height(30f)) == true)
            {
                this.showLayoutWindow = true;
            }

            if (Event.current.type == EventType.Repaint && this.showLayoutWindow == true)
            {
                this.showLayoutWindow = false;

                var commentStyle = new GUIStyle(EditorStyles.miniLabel);
                commentStyle.wordWrap = true;

                FlowChooserFilterWindow.Show <FlowWindowLayoutTemplate>(this.rootWindow, (layout) => {
                    this.layoutPrefab = FlowDatabase.GenerateLayout(this.window, layout);
                    this.ReloadLayouts();
                    this.LoadLayout(this.layoutPrefab);

                    this.isScreenDirty = true;
                }, (layout) => {
                    GUILayout.Label(layout.comment, commentStyle);
                });
            }
        }
Exemple #7
0
        public static void CreateScreen(Object activeObject, string namespaceName, string localPath = "", System.Action callback = null)
        {
            var obj  = activeObject;
            var path = AssetDatabase.GetAssetPath(obj.GetInstanceID()) + localPath;

            FlowChooserFilterWindow.Show <FlowLayoutWindowTypeTemplate>(null, (element) => {
                // on select
                var splitted = path.Split('/');
                var _path    = string.Join("/", splitted, 0, splitted.Length - 1).Trim('/');

                var className = string.Empty;
                var files     = AssetDatabase.FindAssets("t:MonoScript", new string[] { _path });

                foreach (var file in files)
                {
                    var data = AssetDatabase.GUIDToAssetPath(file);
                    var sp   = data.Split('/');
                    var last = sp[sp.Length - 1];
                    if (last.EndsWith("Base.cs") == true)
                    {
                        className = last.Replace("Base.cs", string.Empty);
                    }
                }

                if (string.IsNullOrEmpty(className) == false)
                {
                    var name = className;
                    // Create an instance
                    var layoutPrefab = FlowDatabase.GenerateScreen(path + "/" + name + ".prefab", className, namespaceName, element);

                    Selection.activeObject = layoutPrefab;
                }

                if (callback != null)
                {
                    callback();
                }
            }, (element) => {
                // on gui

                var style      = new GUIStyle(GUI.skin.label);
                style.wordWrap = true;

                GUILayout.Label(element.comment, style);
            }, strongType: true);
        }
Exemple #8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            //property.serializedObject.Update();

            var text    = property.serializedObject.targetObject as UnityEngine.UI.Text;
            var locText = property.serializedObject.targetObject as LocalizationText;

            if (text != null && property.serializedObject.targetObject.GetType() == typeof(UnityEngine.UI.Text))
            {
                /*EditorGUI.LabelField(position, label);
                 * property.stringValue = EditorGUI.TextArea(new Rect(position.x, position.y + 16f, position.width, position.height - 16f), property.stringValue);*/
                EditorGUILayout.LabelField(label);
                property.stringValue = EditorGUILayout.TextArea(property.stringValue, GUILayout.MinHeight(40f));

                var width = 120f;
                if (GUI.Button(new Rect(position.x + position.width - width, position.y, width, 16f), new GUIContent("Switch to Localized", "Replace Text component with LocalizationText"), EditorStyles.miniButtonMid) == true)
                {
                    FlowDatabase.ReplaceComponents <UnityEngine.UI.Text, LocalizationText>(text, typeof(LocalizationText));
                    return;
                }
            }
            else if (locText != null && property.serializedObject.targetObject.GetType() == typeof(LocalizationText))
            {
                /*EditorGUI.LabelField(position, label);
                 * property.stringValue = EditorGUI.TextArea(new Rect(position.x, position.y + 16f, position.width, position.height - 16f), property.stringValue);*/
                EditorGUILayout.LabelField(label);
                property.stringValue = EditorGUILayout.TextArea(property.stringValue, GUILayout.MinHeight(40f));

                var width = 120f;
                if (GUI.Button(new Rect(position.x + position.width - width, position.y, width, 16f), new GUIContent("Switch to normal Text", "Replace Text component with LocalizationText"), EditorStyles.miniButtonMid) == true)
                {
                    FlowDatabase.ReplaceComponents <LocalizationText, UnityEngine.UI.Text>(locText, typeof(UnityEngine.UI.Text));
                    return;
                }
            }
            else
            {
                EditorGUILayout.LabelField(label);
                property.stringValue = EditorGUILayout.TextArea(property.stringValue, GUILayout.MinHeight(40f));

                //EditorGUILayout.PropertyField(property, label);
            }

            //property.serializedObject.ApplyModifiedProperties();
        }
        private void LoadScreen(WindowBase screenPrefab)
        {
            if (screenPrefab != null)
            {
                if (this.screenInstance != null)
                {
                    GameObject.DestroyImmediate(this.screenInstance.gameObject);
                }

                // Loading screen
                this.screenInstance = FlowDatabase.LoadScreen(screenPrefab);
                this.screenInstance.transform.position   = Vector3.zero;
                this.screenInstance.transform.rotation   = Quaternion.identity;
                this.screenInstance.transform.localScale = Vector3.zero;

                this.window.SetScreen(screenPrefab);
            }
        }
        private void LoadLayout(WindowLayout layoutPrefab)
        {
            if (layoutPrefab != null)
            {
                if (this.layoutInstance != null)
                {
                    GameObject.DestroyImmediate(this.layoutInstance.gameObject);
                }

                // Loading layout
                this.layoutInstance = FlowDatabase.LoadLayout(layoutPrefab);
                this.layoutInstance.transform.position   = Vector3.zero;
                this.layoutInstance.transform.rotation   = Quaternion.identity;
                this.layoutInstance.transform.localScale = Vector3.zero;

                if ((this.screenInstance as LayoutWindowType) != null)
                {
                    var layoutScreen = this.screenInstance as LayoutWindowType;
                    layoutScreen.layout.layout = layoutPrefab;
                    this.isScreenDirty         = true;
                }
            }
        }
        public void OnGUI(SceneView sceneView)
        {
            sceneView.in2DMode = true;

            if (this.view != null)
            {
                GUILayout.BeginArea(new Rect(0f, SceneView.kToolbarHeight, this.view.position.width, this.view.position.height));

                var headerStyle = new GUIStyle(EditorStyles.whiteLargeLabel);
                headerStyle.fontSize = 30;

                var oldColor = GUI.color;
                var color    = Color.white;
                color.a   = 0.6f;
                GUI.color = color;
                GUI.Label(new Rect(30f, SceneView.kToolbarHeight, this.view.position.width, this.view.position.height), this.window.title, headerStyle);
                GUI.color = oldColor;

                GUILayout.EndArea();
            }

            if (this.defaultRects == false)
            {
                var rect = sceneView.position;
                var size = new Vector2(250f, 100f);
                this.mainRect = new Rect(rect.width - size.x, 30f, size.x, size.y);

                var itemSize = new Vector2(250f, 300f);
                this.itemRect        = this.mainRect;
                this.itemRect.height = itemSize.y;

                this.defaultRects = true;
            }

            this.currentView = sceneView;

            if (this.view != null)
            {
                if (this.mainRect.x + this.mainRect.width > this.view.position.width)
                {
                    this.mainRect.x = this.view.position.width - this.mainRect.width;
                }
                if (this.mainRect.y + this.mainRect.height > this.view.position.height)
                {
                    this.mainRect.y = this.view.position.height - this.mainRect.height;
                }
                if (this.mainRect.x < 0f)
                {
                    this.mainRect.x = 0f;
                }
                if (this.mainRect.y < 0f)
                {
                    this.mainRect.y = 0f;
                }
            }

            this.mainRect = GUILayout.Window(1, this.mainRect, (id) => {
                this.DrawGUI();
                GUI.DragWindow();
            }, "Window Settings", GUILayout.ExpandHeight(true));

            if (this.isScreenDirty == true && this.screenInstance != null)
            {
                FlowDatabase.SaveScreen(this.screenInstance);
                this.isScreenDirty = false;
            }

            if (this.isLayoutDirty == true && this.layoutInstance != null)
            {
                FlowDatabase.SaveLayout(this.layoutInstance);
                this.isLayoutDirty = false;
            }

            if (this.view != null)
            {
                var height   = 80f;
                var tabsRect = this.view.position;
                tabsRect.x      = 10f;
                tabsRect.y      = tabsRect.height - height - 10f;
                tabsRect.width -= 10f * 2f;
                tabsRect.height = height;
                GUILayout.BeginArea(tabsRect);
                this.DrawTabs(height);
                GUILayout.EndArea();
            }
        }