Exemple #1
0
        public static void Init()
        {
            window = (PerkEditorWindow)EditorWindow.GetWindow(typeof(PerkEditorWindow));
            EditorDBManager.Init();

            InitLabel();
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showPerkList)
            {
                for (int i = 0; i < perkList.Count; i++)
                {
                    Perk perk = perkList[i];
                    if (perk.disablePerk)
                    {
                        continue;
                    }
                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, perk.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Open PerkEditor"))
            {
                PerkEditorWindow.Init();
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
		public static void Init () {
			// Get existing open window or if none, make a new one:
			window = (PerkEditorWindow)EditorWindow.GetWindow(typeof (PerkEditorWindow));
			//~ window.minSize=new Vector2(375, 449);
			//~ window.maxSize=new Vector2(375, 800);
			
			EditorDBManager.Init();
			
			InitLabel();
		}
Exemple #4
0
        public static void Init(int prefabID = -1)
        {
            window         = (PerkEditorWindow)EditorWindow.GetWindow(typeof(PerkEditorWindow), false, "PerkEditor");
            window.minSize = new Vector2(420, 300);

            TDE.Init();

            InitLabel();

            //if(prefabID>=0) window.selectID=PerkDB.GetPrefabIDIndex(prefabID);
        }
Exemple #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.changed = false;
            Undo.RecordObject(instance, "BuildManager");

            EditorGUILayout.Space();


            cont = new GUIContent("Enable Save", "Check to enable auto saving of any progress made for future game session");
            instance.enableSave = EditorGUILayout.Toggle(cont, instance.enableSave);

            cont = new GUIContent("Enable Load", "Check to load from existing saved progress. This will override any preset purchased setting for this level");
            instance.enableLoad = EditorGUILayout.Toggle(cont, instance.enableLoad);


            cont = new GUIContent("Clear Saved Progress", "Remove all the save");
            if (GUILayout.Button(cont))
            {
                instance.ClearProgress();
            }



            EditorGUILayout.Space();


            DrawPerkList();


            EditorGUILayout.Space();
            EditorGUILayout.Space();


            if (GUILayout.Button("Open PerkEditor Window"))
            {
                PerkEditorWindow.Init();
            }


            EditorGUILayout.Space();


            DefaultInspector();

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemple #6
0
 public static void OpenPerkEditor()
 {
     PerkEditorWindow.Init();
 }
Exemple #7
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Persistant Progress", "Check to use persistantProgress\nThe progress done in this level will be carried to next\nEnable this will cause all the level to use the perk enabled in this instance, perk enabled/disable in subsequent PerkManager instance will be ignored");
            instance.persistantProgress = EditorGUILayout.Toggle(cont, instance.persistantProgress);

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showPerkList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.purchasedIDList = new List <int>();

                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < perkList.Count; i++)
                    {
                        instance.unavailableIDList.Add(perkList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();


                for (int i = 0; i < perkList.Count; i++)
                {
                    Perk perk = perkList[i];


                    GUILayout.BeginHorizontal();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    Rect rect = GUILayoutUtility.GetLastRect();
                    EditorUtilities.DrawSprite(rect, perk.icon, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();
                    bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false;
                    if (Application.isPlaying)
                    {
                        flag = !flag;                                                                           //switch it around in runtime
                    }
                    EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70));
                    flag = EditorGUILayout.Toggle(flag);

                    if (!Application.isPlaying)
                    {
                        if (flag)
                        {
                            instance.unavailableIDList.Remove(perk.ID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(perk.ID))
                            {
                                instance.unavailableIDList.Add(perk.ID);
                                instance.purchasedIDList.Remove(perk.ID);
                            }
                        }
                    }

                    if (!instance.unavailableIDList.Contains(perk.ID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.ID);
                        EditorGUILayout.LabelField(new GUIContent("- purchased:", "Check to set the perk as purchased right from the start"), GUILayout.Width(75));
                        flag = EditorGUILayout.Toggle(flag);
                        if (!flag)
                        {
                            instance.purchasedIDList.Remove(perk.ID);
                        }
                        else if (!instance.purchasedIDList.Contains(perk.ID))
                        {
                            instance.purchasedIDList.Add(perk.ID);
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Open PerkEditor"))
            {
                PerkEditorWindow.Init();
            }
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }