private void DisplaySkillSelectionFooter()
        {
            var selectedCollection = SkillCollectionDatabase.Instance.Get(SelectedAssetId, true);

            if (selectedCollection != null)
            {
                GUILayout.BeginHorizontal(GUILayout.Width(200));
                if (GUILayout.Button("+", EditorStyles.toolbarButton))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(SkillEditorUtility.GetNames(), (index) => {
                        var skillAsset = SkillEditorUtility.CreateAsset(index);
                        selectedCollection.Skills.Add(skillAsset);

                        SelectedSkillIndex = selectedCollection.Skills.Count - 1;
                        EditorWindow.FocusWindowIfItsOpen <SkillCollectionWindow> ();
                    }).ShowAsContext();
                }
                if (GUILayout.Button("-", EditorStyles.toolbarButton) &&
                    EditorUtility.DisplayDialog("Delete Skill", "Are you sure you want to delete the selected skill?", "Delete", "Cancel"))
                {
                    if (SelectedSkillIndex >= 0 && SelectedSkillIndex < selectedCollection.Skills.Count)
                    {
                        selectedCollection.Skills.RemoveAt(SelectedSkillIndex--);
                        if (SelectedSkillIndex == -1 && selectedCollection.Skills.Count > 0)
                        {
                            SelectedSkillIndex = 0;
                        }
                    }
                }
                GUILayout.Label("", EditorStyles.toolbarButton, GUILayout.Width(15));
                GUILayout.EndHorizontal();
            }
        }
Esempio n. 2
0
        private void DisplaySelectedStatContent(RPGStatAsset stat)
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            var statType = RPGStatTypeDatabase.Instance.Get(stat.AssignedStatId, true);

            GUILayout.Label(string.Format("[{0}]: {1}", stat.CreateInstance().GetType().Name,
                                          statType == null ? "Stat Type Not Set" : statType.Name));

            if (GUILayout.Button(statType == null ? "Assign Type" : "Change Type", EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    stat.AssignedStatId = statTypeAsset.Id;
                    Debug.Log("Assigning stat to stat type " + statTypeAsset.Id);
                }, typeof(RPGStatTypeWindow));
            }
            GUILayout.EndHorizontal();

            if (stat != null)
            {
                foreach (var extension in RPGStatEditorUtility.GetExtensions())
                {
                    if (extension.CanHandleType(stat.GetType()))
                    {
                        extension.OnGUI(stat);
                    }
                }
            }

            GUILayout.EndVertical();
        }
Esempio n. 3
0
        public override void OnGUI(object asset)
        {
            var link = asset as RPGStatLinkerAsset;

            if (link != null)
            {
                var    statType    = RPGStatTypeDatabase.Instance.Get(link.linkedStatType);
                string displayText = string.Empty;
                if (statType != null)
                {
                    displayText = statType.Name;
                }
                else if (link.linkedStatType <= 0)
                {
                    displayText = "Type Not Set";
                }
                else
                {
                    displayText = "Error Type not Found";
                }

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Linked Stat", displayText);
                if (GUILayout.Button("Change Type", EditorStyles.miniButtonMid, GUILayout.Width(100)))
                {
                    XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                        link.linkedStatType = statTypeAsset.Id;
                        //EditorUtility.SetDirty(RPGStatCollectionDatabase.Instance);
                        //EditorWindow.FocusWindowIfItsOpen<RPGStatCollectionWindow>();
                    }, typeof(RPGStatTypeWindow));
                }
                GUILayout.EndHorizontal();
            }
        }
        public override void OnGUI(object asset)
        {
            PositionAOEStatEffectAsset effectAsset = asset as PositionAOEStatEffectAsset;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Source Stat Type", GUILayout.Width(150));
            var baseStatType = RPGStatTypeDatabase.Instance.Get(effectAsset.StatBase, true);

            if (GUILayout.Button(baseStatType == null ? "Assign Type" : baseStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    effectAsset.StatBase = statTypeAsset.Id;
                }, typeof(RPGStatTypeWindow));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Target Stat Name", GUILayout.Width(150));
            var targetStatType = RPGStatTypeDatabase.Instance.Get(effectAsset.TargetStat, true);

            if (GUILayout.Button(targetStatType == null ? "Assign Type" : targetStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    effectAsset.TargetStat = statTypeAsset.Id;
                }, typeof(RPGStatTypeWindow));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Base Value", GUILayout.Width(150));
            effectAsset.FlatValue = EditorGUILayout.IntField(effectAsset.FlatValue);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Modifier", GUILayout.Width(150));
            effectAsset.Modifier = EditorGUILayout.FloatField(effectAsset.Modifier);
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            effectAsset.IncludeSelf = GUILayout.Toggle(effectAsset.IncludeSelf, "Include Self ", GUILayout.Width(150));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Target Type", GUILayout.Width(150));
            effectAsset.TargetType = (int)(PerceptionTags)(EditorGUILayout.EnumFlagsField((PerceptionTags)effectAsset.TargetType));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Radius", GUILayout.Width(150));
            effectAsset.Radius = EditorGUILayout.FloatField(effectAsset.Radius);
            GUILayout.EndHorizontal();
        }
Esempio n. 5
0
        public override void OnGUI(object asset)
        {
            TargetStatEffectAsset effectAsset = asset as TargetStatEffectAsset;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Source Stat Type", GUILayout.Width(150));
            //effectAsset.StatBase= EditorGUILayout.TextField (effectAsset.StatBase);

            var baseStatType = RPGStatTypeDatabase.Instance.Get(effectAsset.StatBase, true);

            if (GUILayout.Button(baseStatType == null ? "Assign Type" : baseStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    effectAsset.StatBase = statTypeAsset.Id;
                }, typeof(RPGStatTypeWindow));
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Target Stat Type", GUILayout.Width(150));
            //effectAsset.TargetStat= EditorGUILayout.TextField (effectAsset.TargetStat);

            var targetStatType = RPGStatTypeDatabase.Instance.Get(effectAsset.TargetStat, true);

            if (GUILayout.Button(targetStatType == null ? "Assign Type" : targetStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    effectAsset.TargetStat = statTypeAsset.Id;
                }, typeof(RPGStatTypeWindow));
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Base Value", GUILayout.Width(150));
            effectAsset.FlatValue = EditorGUILayout.IntField(effectAsset.FlatValue);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Modifier", GUILayout.Width(150));
            effectAsset.Modifier = EditorGUILayout.FloatField(effectAsset.Modifier);
            GUILayout.EndHorizontal();
        }
Esempio n. 6
0
        protected void DisplayGambitGUI(GambitAsset gambitAsset)
        {
            GUILayout.BeginVertical();
            for (int i = 0; i < gambitAsset.Conditions.Count; i++)
            {
                var gambitCondition = gambitAsset.Conditions [i];
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);

                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                    EditorUtility.DisplayDialog("Remove Condition", "Are you sure you want to delete the condition?", "Delete", "Cancel"))
                {
                    gambitAsset.Conditions.RemoveAt(i);
                }

                GUILayout.Label(gambitCondition.GetType().Name, EditorStyles.toolbarButton, GUILayout.Width(200));

                foreach (var editorExtension in GambitConditionEditorUtility.GetExtensions())
                {
                    if (editorExtension.CanHandleType(gambitCondition.GetType()))
                    {
                        editorExtension.OnGUI(gambitCondition);
                    }
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            if (GUILayout.Button("Add Condition", EditorStyles.toolbarButton))
            {
                XmlDatabaseEditorUtility.GetGenericMenu(GambitConditionEditorUtility.GetNames(), (index) => {
                    var gambitConditionAsset = GambitConditionEditorUtility.CreateAsset(index);
                    gambitAsset.Conditions.Add(gambitConditionAsset);
                    EditorWindow.FocusWindowIfItsOpen <GambitCollectionWindow> ();
                }).ShowAsContext();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Esempio n. 7
0
        public override void DisplayGUIFooter()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add New", EditorStyles.toolbarButton))
            {
                XmlDatabaseEditorUtility.GetGenericMenu(ItemEditorUtility.GetNames(), (index) => {
                    var itemAsset = ItemEditorUtility.CreateAsset(index);
                    itemAsset.Id  = GetDatabaseInstance().GetNextHighestId();
                    GetDatabaseInstance().Add(itemAsset);
                    EditorWindow.FocusWindowIfItsOpen <ItemDatabaseWindow> ();
                }).ShowAsContext();

                //OnAddNewAssetClick();
            }

            DisplayLoadButton();
            DisplaySaveButton();

            GUILayout.EndHorizontal();
        }
Esempio n. 8
0
        public override void OnGUI(object asset)
        {
            StatGambitConditionAsset gambitConditionAsset = asset as StatGambitConditionAsset;

            GUILayout.Label("Name ", EditorStyles.toolbarButton, GUILayout.Width(50));

            //gambitConditionAsset.StatName = GUILayout.TextField(gambitConditionAsset.StatName, GUILayout.Width (100));

            var baseStatType = RPGStatTypeDatabase.Instance.Get(gambitConditionAsset.StatName, true);

            if (GUILayout.Button(baseStatType == null ? "Assign Type" : baseStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
            {
                XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                    gambitConditionAsset.StatName = statTypeAsset.Id;
                }, typeof(RPGStatTypeWindow));
            }

            GUILayout.Label("Value ", EditorStyles.toolbarButton, GUILayout.Width(50));
            gambitConditionAsset.StatValue = EditorGUILayout.FloatField(gambitConditionAsset.StatValue, GUILayout.Width(50));
        }
        public void DisplayCollectionAssetGUI(GambitCollection collection)
        {
            var    asset = GambitCollectionDatabase.Instance.Get(collection.GambitCollectionId);
            string displayText;

            // if the asset is found, use its name
            if (asset != null)
            {
                displayText = asset.Name;
            }
            // if the id is below 0 no collection is assigned
            else if (collection.GambitCollectionId <= 0)
            {
                displayText = "Not set";
            }
            // if no asset is assigned and the id is above zero
            // previous collection is missing
            else
            {
                displayText = "Missing";
            }

            GUILayout.Space(4);

            // show the collection's name and id and allow user to change
            // the assigned stat collection via a dialogue pop up
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            GUILayout.Label("Gambit Collection:");
            if (GUILayout.Button(string.Format("[ID: {0}] {1}", Mathf.Max(0, collection.GambitCollectionId).ToString(), displayText), EditorStyles.toolbarPopup))
            {
                GambitCollectionDatabase.Instance.LoadDatabase();
                XmlDatabaseEditorUtility.ShowContext(GambitCollectionDatabase.Instance, (value) => {
                    collection.GambitCollectionId = value.Id;
                }, typeof(GambitCollectionWindow));
            }

            EditorGUI.EndDisabledGroup();
        }
        private void DisplayCollectionAssetGUI(RPGStatCollection collection)
        {
            // Determine the string to display for the given stat collection
            var    asset = RPGStatCollectionDatabase.Instance.Get(collection.StatCollectionId);
            string displayText;

            // If the asset is found within the database use it's name.
            if (asset != null)
            {
                displayText = asset.Name;
            }
            // If the id is below zero no collection is assigned.
            else if (collection.StatCollectionId <= 0)
            {
                displayText = "Not Set";
            }
            // If no asset is assigned and the id i above zero
            // the previous collection is currently missing.
            else
            {
                displayText = "Missing";
            }

            GUILayout.Space(4);

            // Show the collection's name and id and allow user to change
            // the assigned stat collection via a dialog popup
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            if (GUILayout.Button(string.Format("[ID: {0}] {1}", Mathf.Max(0, collection.StatCollectionId).ToString("D4"), displayText), EditorStyles.toolbarPopup))
            {
                RPGStatCollectionDatabase.Instance.LoadDatabase();
                XmlDatabaseEditorUtility.ShowContext(RPGStatCollectionDatabase.Instance, (value) => {
                    collection.StatCollectionId = value.Id;
                }, typeof(RPGStatCollectionWindow));
            }
            EditorGUI.EndDisabledGroup();
        }
        private void DisplaySelectedSkillContent(SkillAsset skill)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label("Parameters", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Skill Name", GUILayout.Width(100));
            skill.Name = EditorGUILayout.TextField(skill.Name);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Cooldown", GUILayout.Width(100));
            skill.Cooldown = EditorGUILayout.FloatField(skill.Cooldown);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Cast Time", GUILayout.Width(100));
            skill.CastTime = EditorGUILayout.FloatField(skill.CastTime);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Range", GUILayout.Width(100));
            skill.Range = EditorGUILayout.FloatField(skill.Range);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Duration", GUILayout.Width(100));
            skill.Delay = EditorGUILayout.FloatField(skill.Delay);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Interruptable", GUILayout.Width(100));
            skill.Interruptable = EditorGUILayout.Toggle(skill.Interruptable);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Unlocked Level", GUILayout.Width(100));
            skill.RequiredLevel = EditorGUILayout.IntField(skill.RequiredLevel);
            GUILayout.EndHorizontal();

            foreach (var extension in SkillEditorUtility.GetExtensions())
            {
                if (extension.CanHandleType(skill.GetType()))
                {
                    extension.OnGUI(skill);
                }
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Height(200));
            GUILayout.Label("Prerequisites", EditorStyles.boldLabel);

            skillPrerequisiteScroll = GUILayout.BeginScrollView(skillPrerequisiteScroll, false, true);

            for (int i = 0; i < skill.Prerequisites.Count; i++)
            {
                SkillPrerequisiteAsset prerequisite = skill.Prerequisites [i];
                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                    EditorUtility.DisplayDialog("Remove prerequisite", "Are you sure you want to delete the prerequisite?", "Delete", "Cancel"))
                {
                    skill.Prerequisites.RemoveAt(i);
                }
                GUILayout.Label("StatType", GUILayout.Width(100));
                //prerequisite.StatName = EditorGUILayout.TextField (prerequisite.StatName);

                var targetStatType = RPGStatTypeDatabase.Instance.Get(prerequisite.StatName, true);
                if (GUILayout.Button(targetStatType == null ? "Assign Type" : targetStatType.Name, EditorStyles.toolbarButton, GUILayout.Width(100)))
                {
                    XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                        prerequisite.StatName = statTypeAsset.Id;
                    }, typeof(RPGStatTypeWindow));
                }

                GUILayout.Label("StatValue", GUILayout.Width(100));
                prerequisite.StatValue = EditorGUILayout.IntField(prerequisite.StatValue);
                GUILayout.EndHorizontal();
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndScrollView();

            if (GUILayout.Button("Add Prerequisite", EditorStyles.toolbarButton))
            {
                var newPrerequisite = new SkillPrerequisiteAsset();
                skill.Prerequisites.Add(newPrerequisite);
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.Label("Effects", EditorStyles.boldLabel);
            skillEffectScroll = GUILayout.BeginScrollView(skillEffectScroll, false, true);

            GUILayout.BeginHorizontal();
            GUILayout.Label("", EditorStyles.boldLabel, GUILayout.Width(30));
            GUILayout.Label("Type", EditorStyles.boldLabel, GUILayout.Width(150));
            GUILayout.Label("Delay", EditorStyles.boldLabel, GUILayout.Width(50));
            GUILayout.EndHorizontal();

            for (int i = 0; i < skill.Effects.Count; i++)
            {
                //foreach(var effect in skill.Effects){
                EffectAsset effect = skill.Effects[i];
                GUILayout.BeginHorizontal(EditorStyles.toolbar);

                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                    EditorUtility.DisplayDialog("Remove effect", "Are you sure you want to delete the effect?", "Delete", "Cancel"))
                {
                    skill.Effects.RemoveAt(i);
                }

                bool clicked = GUILayout.Toggle(i == SelectedEffectIndex, effect.GetType().Name, ToggleButtonStyle, GUILayout.Width(150));
                if (clicked != (i == SelectedEffectIndex))
                {
                    if (clicked)
                    {
                        SelectedEffectIndex = i;
                        GUI.FocusControl(null);
                    }
                    else
                    {
                        SelectedEffectIndex = -1;
                    }
                }

                effect.Delay = EditorGUILayout.FloatField(effect.Delay, GUILayout.Width(50));
                GUILayout.EndHorizontal();


                if (SelectedEffectIndex == i)
                {
                    GUILayout.BeginVertical(EditorStyles.helpBox);
                    foreach (var extension in EffectEditorUtility.GetExtensions())
                    {
                        if (extension.CanHandleType(effect.GetType()))
                        {
                            extension.OnGUI(effect);
                        }
                    }
                    GUILayout.EndVertical();
                }
            }

            //Object source = null;
            //source = EditorGUILayout.ObjectField(source, typeof(Object), true);
            //AssetDatabase.GetAssetPath (source);


            GUILayout.FlexibleSpace();
            GUILayout.EndScrollView();

            if (GUILayout.Button("Add Effect", EditorStyles.toolbarButton))
            {
                if (typeof(PositionSkillAsset).IsAssignableFrom(skill.GetType()))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetPositionEffectNames(), (index) => {
                        var skillEffectAsset = EffectEditorUtility.CreatePositionEffectAsset(index);
                        skill.Effects.Add(skillEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <SkillCollectionWindow> ();
                    }).ShowAsContext();
                }
                else if (typeof(TargetSkillAsset).IsAssignableFrom(skill.GetType()))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetTargetEffectNames(), (index) => {
                        var skillEffectAsset = EffectEditorUtility.CreateTargetEffectAsset(index);
                        skill.Effects.Add(skillEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <SkillCollectionWindow> ();
                    }).ShowAsContext();
                }
                else
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetNames(), (index) => {
                        var skillEffectAsset = EffectEditorUtility.CreateAsset(index);
                        skill.Effects.Add(skillEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <SkillCollectionWindow> ();
                    }).ShowAsContext();
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndVertical();
        }
        protected override void DisplayAssetGUI(EntityAsset asset)
        {
            GUILayout.BeginVertical("Box");

            GUILayout.BeginHorizontal();

            //asset.Icon = (Sprite)EditorGUILayout.ObjectField(asset.Icon, typeof(Sprite), false,
            //	GUILayout.Width(72), GUILayout.Height(72));

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.Width(100));
            asset.Name = EditorGUILayout.TextField(asset.Name);

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Gambit Collection ", GUILayout.Width(100));

            GambitCollectionAsset gambitCollectionAsset = GambitCollectionDatabase.Instance.Get(asset.GambitCollectionId);

            if (GUILayout.Button(gambitCollectionAsset == null?"Assign Gambit Collection":gambitCollectionAsset.Name))
            {
                XmlDatabaseEditorUtility.ShowContext(GambitCollectionDatabase.Instance, (gambitColAsset) => {
                    if (EditorUtility.DisplayDialog("Change gambit collection", "Are you sure you want to change the associated gambit collection? Changing gambit collection might result in unsynchronized skill collection", "Change", "Cancel"))
                    {
                        asset.GambitCollectionId = gambitColAsset.Id;
                    }
                });
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Skill Collection ", GUILayout.Width(100));

            SkillCollectionAsset skillCollectionAsset = SkillCollectionDatabase.Instance.Get(asset.SkillCollectionId);

            if (GUILayout.Button(skillCollectionAsset == null?"Assign Skill Collection":skillCollectionAsset.Name))
            {
                XmlDatabaseEditorUtility.ShowContext(SkillCollectionDatabase.Instance, (skillColAsset) => {
                    if (EditorUtility.DisplayDialog("Change skill collection", "Are you sure you want to change the associated skill collection? Changing skill collection might result in loss of skill data in gambits.", "Change", "Cancel"))
                    {
                        asset.SkillCollectionId = skillColAsset.Id;
                    }
                });
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Description", GUILayout.Width(100));
            asset.Description = EditorGUILayout.TextField(asset.Description);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Tag", GUILayout.Width(100));
            asset.Tag = (int)(PerceptionTags)(EditorGUILayout.EnumFlagsField((PerceptionTags)asset.Tag));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Alert Mask", GUILayout.Width(100));
            asset.AlertMask = (int)(PerceptionTags)(EditorGUILayout.EnumFlagsField((PerceptionTags)asset.AlertMask));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Vision", GUILayout.Width(100));
            asset.Vision = EditorGUILayout.FloatField(asset.Vision);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Esempio n. 13
0
        public void OnGUI(object asset, ItemDatabaseWindow itemDBWindow)
        {
            GUILayout.BeginVertical();

            UsableItemAsset itemAsset = asset as UsableItemAsset;

            for (int i = 0; i < itemAsset.Effects.Count; i++)
            {
                EffectAsset effect = itemAsset.Effects[i];
                GUILayout.BeginHorizontal(EditorStyles.toolbar);

                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                    EditorUtility.DisplayDialog("Remove effect", "Are you sure you want to delete the effect?", "Delete", "Cancel"))
                {
                    itemAsset.Effects.RemoveAt(i);
                }

                bool clicked = GUILayout.Toggle(i == itemDBWindow.SelectedEffectIndex, effect.GetType().Name, ToggleButtonStyle, GUILayout.Width(150));
                if (clicked != (i == itemDBWindow.SelectedEffectIndex))
                {
                    if (clicked)
                    {
                        itemDBWindow.SelectedEffectIndex = i;
                        GUI.FocusControl(null);
                    }
                    else
                    {
                        itemDBWindow.SelectedEffectIndex = -1;
                    }
                }
                GUILayout.EndHorizontal();

                if (itemDBWindow.SelectedEffectIndex == i)
                {
                    GUILayout.BeginVertical();
                    foreach (var extension in EffectEditorUtility.GetExtensions())
                    {
                        if (extension.CanHandleType(effect.GetType()))
                        {
                            extension.OnGUI(effect);
                        }
                    }
                    GUILayout.EndVertical();
                }
            }

            if (GUILayout.Button("Add Effect", EditorStyles.toolbarButton))
            {
                Debug.Log(itemAsset.GetType().ToString());
                if (typeof(PositionUsableItemAsset).IsAssignableFrom(itemAsset.GetType()))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetPositionEffectNames(), (index) => {
                        var itemEffectAsset = EffectEditorUtility.CreatePositionEffectAsset(index);
                        itemAsset.Effects.Add(itemEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <ItemDatabaseWindow> ();
                    }).ShowAsContext();
                }
                else if (typeof(TargetUsableItemAsset).IsAssignableFrom(itemAsset.GetType()))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetTargetEffectNames(), (index) => {
                        var itemEffectAsset = EffectEditorUtility.CreateTargetEffectAsset(index);
                        itemAsset.Effects.Add(itemEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <ItemDatabaseWindow> ();
                    }).ShowAsContext();
                }
                else
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(EffectEditorUtility.GetNames(), (index) => {
                        var skillEffectAsset = EffectEditorUtility.CreateAsset(index);
                        itemAsset.Effects.Add(skillEffectAsset);
                        EditorWindow.FocusWindowIfItsOpen <ItemDatabaseWindow> ();
                    }).ShowAsContext();
                }
            }

            GUILayout.EndVertical();
        }
Esempio n. 14
0
        protected override void DisplayAssetGUI(GambitCollectionAsset asset)
        {
            GUILayout.BeginVertical();

            var selectedCollection = GambitCollectionDatabase.Instance.Get(SelectedAssetId);

            if (selectedCollection != null)
            {
                GUILayout.Label(selectedCollection.Name, EditorStyles.toolbarButton);

                GUILayout.BeginHorizontal();
                GUILayout.Label("ID: " + selectedCollection.Id.ToString() + ", Name ", GUILayout.Width(100));
                selectedCollection.Name = EditorGUILayout.TextField(selectedCollection.Name);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Skill Collection ", GUILayout.Width(100));

                SkillCollectionAsset skillCollectionAsset = SkillCollectionDatabase.Instance.Get(asset.SkillCollectionId);
                if (GUILayout.Button(skillCollectionAsset == null?"Assign Skill Collection":skillCollectionAsset.Name))
                {
                    XmlDatabaseEditorUtility.ShowContext(SkillCollectionDatabase.Instance, (skillColAsset) => {
                        if (EditorUtility.DisplayDialog("Change skill collection", "Are you sure you want to change the associated skill collection? Changing skill collection might result in loss of skill data in gambits.", "Change", "Cancel"))
                        {
                            asset.SkillCollectionId = skillColAsset.Id;
                        }
                    });
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginVertical(EditorStyles.helpBox);

                GUILayout.BeginHorizontal();
                GUILayout.Label("", EditorStyles.boldLabel, GUILayout.Width(30));
                GUILayout.Label("Priority", EditorStyles.boldLabel, GUILayout.Width(100));
                GUILayout.Label("Type", EditorStyles.boldLabel, GUILayout.Width(200));
                GUILayout.Label("Skill", EditorStyles.boldLabel, GUILayout.Width(150));
                GUILayout.Label("Use Limit", EditorStyles.boldLabel, GUILayout.Width(100));
                GUILayout.EndHorizontal();

                gambitSelectionScroll = GUILayout.BeginScrollView(gambitSelectionScroll, false, true);

                for (int i = 0; i < asset.Gambits.Count; i++)
                {
                    GambitAsset gambitAsset = asset.Gambits [i];
                    GUILayout.BeginHorizontal(EditorStyles.toolbar);

                    if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                        EditorUtility.DisplayDialog("Remove Gambit", "Are you sure you want to delete the gambit?", "Delete", "Cancel"))
                    {
                        asset.Gambits.RemoveAt(i);
                    }

                    gambitAsset.Priority = EditorGUILayout.IntField(gambitAsset.Priority, GUILayout.Width(100));

                    bool clicked = GUILayout.Toggle(i == SelectedGambitIndex, gambitAsset.GetType().Name, ToggleButtonStyle, GUILayout.Width(200));
                    if (clicked != (i == SelectedGambitIndex))
                    {
                        if (clicked)
                        {
                            SelectedGambitIndex = i;
                            GUI.FocusControl(null);
                        }
                        else
                        {
                            SelectedGambitIndex = -1;
                        }
                    }

                    if (skillCollectionAsset == null)
                    {
                        GUI.enabled = false;
                        GUILayout.Button("None", EditorStyles.toolbarButton, GUILayout.Width(150));
                    }
                    else
                    {
                        GUI.enabled = true;

                        bool skillFound = false;
                        int  iterator   = 0;
                        while (!skillFound && (iterator < skillCollectionAsset.Skills.Count))
                        {
                            if (skillCollectionAsset.Skills [iterator].Name == gambitAsset.SkillId)
                            {
                                skillFound = true;
                                break;
                            }
                            else
                            {
                                iterator++;
                            }
                        }
                        string skillLabel = skillFound?gambitAsset.SkillId:"Missing";

                        if (GUILayout.Button(gambitAsset.SkillId == ""? "Assign Skill" : skillLabel, EditorStyles.toolbarButton, GUILayout.Width(150)))
                        {
                            List <string> skillList = new List <string> ();
                            if (typeof(PositionGambitAsset).IsAssignableFrom(gambitAsset.GetType()))
                            {
                                for (int j = 0; j < skillCollectionAsset.Skills.Count; j++)
                                {
                                    if (!typeof(TargetSkillAsset).IsAssignableFrom(skillCollectionAsset.Skills [j].GetType()))
                                    {
                                        skillList.Add(skillCollectionAsset.Skills [j].Name);
                                    }
                                }
                            }
                            else
                            {
                                for (int j = 0; j < skillCollectionAsset.Skills.Count; j++)
                                {
                                    if (!typeof(PositionSkillAsset).IsAssignableFrom(skillCollectionAsset.Skills [j].GetType()))
                                    {
                                        skillList.Add(skillCollectionAsset.Skills [j].Name);
                                    }
                                }
                            }

                            string [] skillNames = skillList.ToArray();
                            XmlDatabaseEditorUtility.GetGenericMenu(skillNames, (index) => {
                                gambitAsset.SkillId = skillNames[index];
                            }).ShowAsContext();
                        }
                    }

                    GUI.enabled = true;

                    gambitAsset.MaxUse = EditorGUILayout.IntField(gambitAsset.MaxUse);

                    GUILayout.EndHorizontal();

                    if (SelectedGambitIndex == i)
                    {
                        foreach (var editorExtension in GambitEditorUtility.GetExtensions())
                        {
                            if (editorExtension.CanHandleType(gambitAsset.GetType()))
                            {
                                editorExtension.OnGUI(gambitAsset);
                            }
                        }

                        DisplayGambitGUI(gambitAsset);
                    }
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndScrollView();

                if (GUILayout.Button("Add Gambit", EditorStyles.toolbarButton))
                {
                    XmlDatabaseEditorUtility.GetGenericMenu(GambitEditorUtility.GetNames(), (index) => {
                        var gambitAsset = GambitEditorUtility.CreateAsset(index);
                        asset.Gambits.Add(gambitAsset);
                        EditorWindow.FocusWindowIfItsOpen <GambitCollectionWindow> ();
                    }).ShowAsContext();
                }

                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
Esempio n. 15
0
        public override void OnGUI(object asset)
        {
            var stat = asset as RPGAttributeAsset;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Label("Stat Linkers");
            if (GUILayout.Button("Add", EditorStyles.toolbarButton, GUILayout.Width(60)))
            {
                XmlDatabaseEditorUtility.GetGenericMenu(RPGStatLinkerEditorUtility.GetNames(), (index) => {
                    var newLinker = RPGStatLinkerEditorUtility.CreateAsset(index);
                    stat.StatLinkers.Add(newLinker);
                    EditorWindow.FocusWindowIfItsOpen <RPGStatCollectionWindow>();
                }).ShowAsContext();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            scroll = GUILayout.BeginScrollView(scroll, false, true);
            if (stat.StatLinkers.Count > 0)
            {
                for (int i = 0; i < stat.StatLinkers.Count; i++)
                {
                    var linker = stat.StatLinkers[i];
                    if (linker != null)
                    {
                        GUILayout.Space(10);

                        // Add space to the left
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(4);


                        GUILayout.BeginVertical("Box");

                        GUILayout.Space(-10);
                        GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
                        EditorGUILayout.LabelField("Linker", linker.GetType().Name);

                        if (GUILayout.Button("Remove", EditorStyles.toolbarButton, GUILayout.Width(70)))
                        {
                            stat.StatLinkers.RemoveAt(i);
                        }
                        GUILayout.EndHorizontal();



                        foreach (var extension in RPGStatLinkerEditorUtility.GetExtensions())
                        {
                            //Debug.Log("CHecking linker of type : " + linker.GetType().ToString());
                            if (extension.CanHandleType(linker.GetType()))
                            {
                                extension.OnGUI(linker);
                            }
                        }
                        GUILayout.EndVertical();

                        // Add space to right
                        GUILayout.Space(4);
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        stat.StatLinkers.RemoveAt(i);
                        GUILayout.Label("Error: Linker is null");
                    }
                }
            }
            else
            {
                GUILayout.Label("Empty", EditorStyles.centeredGreyMiniLabel);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
        public void OnGUI(object asset, ItemDatabaseWindow itemDBWindow)
        {
            GUILayout.BeginVertical();

            EquipmentAsset itemAsset = asset as EquipmentAsset;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);

            GUILayout.Label(" ", EditorStyles.toolbarButton, GUILayout.Width(30));
            GUILayout.Label("Type", EditorStyles.toolbarButton);
            GUILayout.Button("StatId", EditorStyles.toolbarButton);
            GUILayout.Label("Value", EditorStyles.toolbarButton, GUILayout.Width(50));
            GUILayout.Label("Stacks", EditorStyles.toolbarButton, GUILayout.Width(50));

            /*bool clicked = GUILayout.Toggle (i == itemDBWindow.SelectedEffectIndex, modifier.GetType ().Name, ToggleButtonStyle, GUILayout.Width(150));
             *      if (clicked != (i == itemDBWindow.SelectedEffectIndex)) {
             *              if (clicked) {
             *                      itemDBWindow.SelectedEffectIndex = i;
             *                      GUI.FocusControl (null);
             *              } else {
             *                      itemDBWindow.SelectedEffectIndex = -1;
             *              }
             *      }*/
            GUILayout.EndHorizontal();

            for (int i = 0; i < itemAsset.Mods.Count; i++)
            {
                RPGStatModifierAsset modifier = itemAsset.Mods[i];
                GUILayout.BeginHorizontal(EditorStyles.toolbar);

                if (GUILayout.Button("-", EditorStyles.toolbarButton, GUILayout.Width(30)) &&
                    EditorUtility.DisplayDialog("Remove modifier", "Are you sure you want to delete the modifier?", "Delete", "Cancel"))
                {
                    itemAsset.Mods.RemoveAt(i);
                }

                GUILayout.Label(modifier.GetType().Name, EditorStyles.toolbarButton);
                //modifier.AssignedStatId = EditorGUILayout.IntField (modifier.AssignedStatId);

                var statType = RPGStatTypeDatabase.Instance.Get(modifier.AssignedStatId, true);
                if (GUILayout.Button(statType == null ? "Assign Stat" : statType.Name, EditorStyles.toolbarButton))
                {
                    XmlDatabaseEditorUtility.ShowContext(RPGStatTypeDatabase.Instance, (statTypeAsset) => {
                        modifier.AssignedStatId = statTypeAsset.Id;
                        Debug.Log("Assigning stat to stat type " + statTypeAsset.Id);
                    }, typeof(RPGStatTypeWindow));
                }


                modifier.Value  = EditorGUILayout.FloatField(modifier.Value, GUILayout.Width(50));
                modifier.Stacks = EditorGUILayout.Toggle(modifier.Stacks, GUILayout.Width(50));

                /*bool clicked = GUILayout.Toggle (i == itemDBWindow.SelectedEffectIndex, modifier.GetType ().Name, ToggleButtonStyle, GUILayout.Width(150));
                 * if (clicked != (i == itemDBWindow.SelectedEffectIndex)) {
                 *      if (clicked) {
                 *              itemDBWindow.SelectedEffectIndex = i;
                 *              GUI.FocusControl (null);
                 *      } else {
                 *              itemDBWindow.SelectedEffectIndex = -1;
                 *      }
                 * }*/
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add Modifier", EditorStyles.toolbarButton))
            {
                XmlDatabaseEditorUtility.GetGenericMenu(RPGStatModifierEditorUtility.GetNames(), (selectedIndex) => {
                    itemAsset.Mods.Add(RPGStatModifierEditorUtility.CreateAsset(selectedIndex));
                }).ShowAsContext();
            }

            GUILayout.EndVertical();
        }
Esempio n. 17
0
        public override void OnGUI(object asset)
        {
            RPGStatAsset stat = asset as RPGStatAsset;

            stat.StatBaseValue = EditorGUILayout.IntField("Stat Base Value", stat.StatBaseValue);

            GUILayout.BeginHorizontal();
            var category = RPGStatCategoryDatabase.Instance.Get(stat.StatCategoryId);

            if (category == null)
            {
                EditorGUILayout.LabelField("Stat Category", "None");
            }
            else
            {
                EditorGUILayout.LabelField("Stat Category", category.Name);
            }

            if (GUILayout.Button("Set Category", EditorStyles.miniButtonMid, GUILayout.Width(100)))
            {
                RPGStatCategoryDatabase.Instance.LoadDatabase();
                XmlDatabaseEditorUtility.ShowContext(RPGStatCategoryDatabase.Instance, (categoryAsset) => {
                    stat.StatCategoryId = categoryAsset.Id;
                }, typeof(RPGStatCategoryWindow));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(EditorStyles.toolbarButton);
            if (stat.StatScaler != null)
            {
                EditorGUILayout.LabelField("Stat Scaler", stat.StatScaler.GetType().Name);
            }
            else
            {
                EditorGUILayout.LabelField("Stat Scaler", "No Scaler Set");
            }

            if (GUILayout.Button("Set", EditorStyles.toolbarButton, GUILayout.Width(40)))
            {
                RPGStatScalerDatabase.Instance.LoadDatabase();
                XmlDatabaseEditorUtility.GetGenericMenu(RPGStatScalerEditorUtility.GetNames(), (selectedIndex) => {
                    stat.StatScaler = RPGStatScalerEditorUtility.CreateAsset(selectedIndex);
                }).ShowAsContext();
            }

            if (GUILayout.Button("Remove", EditorStyles.toolbarButton, GUILayout.Width(60)))
            {
                stat.StatScaler = null;
            }
            GUILayout.EndHorizontal();

            if (stat.StatScaler != null)
            {
                foreach (var extension in RPGStatScalerEditorUtility.GetExtensions())
                {
                    if (extension.CanHandleType(stat.StatScaler.GetType()))
                    {
                        extension.OnGUI(stat.StatScaler);
                    }
                }
            }
            else
            {
                GUILayout.Label("No Stat Scaler selected. Stat will not scale with level",
                                EditorStyles.centeredGreyMiniLabel);
            }
        }