コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
        }