Example #1
0
        public void OnGUI()
        {
            EditorStyles.textField.wordWrap = true;
            TabBar();
            GUILayout.BeginHorizontal();
            switch (tabState)
            {
            case TabState.WEAPONS:
                Weapons();
                break;

            case TabState.CONSUMABLES:
                Consumables();
                break;

            case TabState.QUEST_ITEMS:
                QuestItems();
                break;

            default:
                About();
                break;
            }

            GUILayout.EndHorizontal();
            StatusBar();
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Create Weapon", EditorStyles.toolbarButton))
            {
                var newAsset = new WeaponAsset(WeaponDatabase.Instance.GetNextId());
                WeaponDatabase.Instance.Add(newAsset);
            }
            if (GUILayout.Button("Create Consumable", EditorStyles.toolbarButton))
            {
                var newAsset = new ConsumableAsset(ConsumableDatabase.Instance.GetNextId());
                ConsumableDatabase.Instance.Add(newAsset);
            }
            if (GUILayout.Button("Create Quest Item", EditorStyles.toolbarButton))
            {
                var newAsset = new QuestAsset(QuestDatabase.Instance.GetNextId());
                QuestDatabase.Instance.Add(newAsset);
            }
            GUILayout.EndHorizontal();
        }
Example #2
0
        public void Consumables()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            for (int i = 0; i < ConsumableDatabase.GetAssetCount(); i++)
            {
                ConsumableAsset asset = ConsumableDatabase.GetAt(i);
                if (asset != null)
                {
                    GUILayout.BeginHorizontal(EditorStyles.toolbar);
                    GUILayout.Label(string.Format("ID: {0}", asset.ID.ToString("D3")), GUILayout.Width(60));

                    bool clicked = GUILayout.Toggle(asset.ID == activeID, asset.Name, ToggleButtonStyle);

                    if (clicked != (asset.ID == activeID))
                    {
                        if (clicked)
                        {
                            activeID = asset.ID;
                            GUI.FocusControl(null);
                        }
                        else
                        {
                            activeID = -1;
                        }
                    }

                    if (GUILayout.Button("x", EditorStyles.toolbarButton, GUILayout.Width(30)) && EditorUtility.DisplayDialog("Delete Consumable Item", "Are you sure you want to delete " + asset.Name + " Consumable?", "Delete", "Cancel"))
                    {
                        ConsumableDatabase.Instance.RemoveAt(i);
                    }

                    GUILayout.EndHorizontal();

                    if (activeID == asset.ID)
                    {
                        EditorGUI.BeginChangeCheck();

                        GUILayout.BeginVertical("Box");

                        GUILayout.BeginHorizontal();
                        //ITEM SPRITE
                        GUILayout.BeginVertical(GUILayout.Width(75)); //begin vertical
                        asset.Icon = (Sprite)EditorGUILayout.ObjectField(asset.Icon, typeof(Sprite), false, GUILayout.Width(72), GUILayout.Height(72));
                        GUILayout.Label("Item Sprite", GUILayout.Width(72));
                        GUILayout.EndVertical();   //end vertical

                        //ITEM CLASS
                        GUILayout.BeginVertical(); //begin vertical
                        GUILayout.Label("Item Class: " + asset.IType.ToString(), EditorStyles.boldLabel);

                        //NAME
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name", GUILayout.Width(80));
                        asset.Name = EditorGUILayout.TextField(asset.Name);
                        GUILayout.EndHorizontal();

                        //DESCRIPTION
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Description", GUILayout.Width(80));
                        asset.Description = EditorGUILayout.TextArea(asset.Description, GUILayout.MinHeight(30));
                        GUILayout.EndHorizontal();

                        //COST
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Cost", GUILayout.Width(80));
                        asset.Cost = EditorGUILayout.IntField(asset.Cost);
                        GUILayout.EndHorizontal();

                        //STACKABLE
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Stackable", GUILayout.Width(80));
                        GUILayout.BeginVertical();
                        asset.Stackable = EditorGUILayout.BeginToggleGroup("Enabled", asset.Stackable);
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Stack Size", GUILayout.Width(80));
                        asset.StackSize = EditorGUILayout.IntSlider(asset.StackSize, 2, 64);
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                        EditorGUILayout.EndToggleGroup();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Level", GUILayout.Width(80));
                        asset.Level = EditorGUILayout.IntSlider(asset.Level, 1, 99);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Weight", GUILayout.Width(80));
                        asset.Weight = EditorGUILayout.IntSlider(asset.Weight, 0, 99);
                        GUILayout.EndHorizontal();

                        GUILayout.Label("Consumable Variables", EditorStyles.boldLabel);

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Stat To Effect", GUILayout.Width(80));
                        asset.StatToEffect = (StatType)EditorGUILayout.EnumPopup(asset.StatToEffect);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Effect Amount", GUILayout.Width(80));
                        asset.EffectAmount = EditorGUILayout.IntField(asset.EffectAmount);
                        GUILayout.EndHorizontal();

                        GUILayout.EndVertical();

                        GUILayout.EndHorizontal();

                        GUILayout.EndVertical();
                        if (EditorGUI.EndChangeCheck())
                        {
                            EditorUtility.SetDirty(ConsumableDatabase.Instance);
                        }
                    }
                }
            }
            GUILayout.EndScrollView();
        }