Exemple #1
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();
            AbilityBehavior abilityHolder = (AbilityBehavior)target;
            Ability         ability       = abilityHolder.ability;

            if (ability == null)
            {
                return;
            }

            if (GUILayout.Button("Show In Editor"))
            {
                AbilityEditorWindow.Init();
                AbilityEditorWindow.window.Select(ability.name, abilityHolder.gameObject);
            }

            //EditorGUI.BeginChangeCheck();


            //ability.name = EditorGUILayout.TextField("Name:", ability.name);

            //if(EditorGUI.EndChangeCheck())
            //{
            //    EditorUtility.SetDirty(abilityHolder);
            //    AbilityEditorWindow.Init();
            //}

            //base.OnInspectorGUI();
        }
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (AbilityEditorWindow)EditorWindow.GetWindow(typeof(AbilityEditorWindow), false, "Ability Editor");
            //~ window.minSize=new Vector2(375, 449);
            //~ window.maxSize=new Vector2(375, 800);

            prefab      = AbilityDB.LoadDB();
            abilityList = prefab.abilityList;

            for (int i = 0; i < abilityList.Count; i++)
            {
                //towerList[i].prefabID=i;
                if (abilityList[i] != null)
                {
                    abilityIDList.Add(abilityList[i].ID);
                }
                else
                {
                    abilityList.RemoveAt(i);
                    i -= 1;
                }
            }

            InitLabel();
        }
Exemple #3
0
        public static Vector3 DrawIconAndName(Unit unit, float startX, float startY)
        {
            float cachedX = startX;
            float cachedY = startY;

            EditorUtilities.DrawSprite(new Rect(startX, startY, 60, 60), unit.iconSprite);
            startX += 65;

            cont = new GUIContent("Name:", "The unit name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.unitName);

            cont = new GUIContent("Icon:", "The unit icon to be displayed in game, must be a sprite");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.iconSprite = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), unit.iconSprite, typeof(Sprite), false);

            startY += 1;
            //cont = new GUIContent("Ab ID:", "The ID of ability that unit may cast");
            //EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            unit.abilityType = (AbilityGUIType)EditorGUI.Popup(new Rect(startX, startY += spaceY, 45, 30), (int)unit.abilityType, new string[] { "ID", "Object" });

            if (unit.abilityType == AbilityGUIType.ID)
            {
                unit.Ab_ID = EditorGUI.IntField(new Rect(startX + spaceX - 60, startY, 20, height), unit.Ab_ID);
                if (unit.Ab_ID > -1)
                {
                    if (GUI.Button(new Rect(startX + 80, startY, 50, height), "Show"))
                    {
                        AbilityEditorWindow.Init();
                        AbilityEditorWindow.window.SelectAbility(unit.Ab_ID);
                    }

                    var   newStartX = startX + UnitEditorWindow.spaceX;
                    float spaceX    = 80;
                    cont = new GUIContent("Delay:", "The Delay of the ability");
                    EditorGUI.LabelField(new Rect(newStartX + 20, startY, spaceX, height), cont);
                    unit.Ab_StartDelay = EditorGUI.FloatField(new Rect(newStartX + 60, startY, 30, height), unit.Ab_StartDelay);
                    cont = new GUIContent("Interval:", "The Interval of the casting");
                    EditorGUI.LabelField(new Rect(newStartX + 90, startY, spaceX, height), cont);
                    unit.Ab_IntervalTime = EditorGUI.FloatField(new Rect(newStartX + 140, startY, 30, height), unit.Ab_IntervalTime);
                }
            }
            else
            {
                unit.Ab_holder = GetAbility(unit.Ab_holder, startX, startY);
                if (unit.Ab_holder)
                {
                    var   newStartX = startX + UnitEditorWindow.spaceX;
                    float spaceX    = 80;
                    cont = new GUIContent("Delay:", "The Delay of the ability");
                    EditorGUI.LabelField(new Rect(newStartX + 20, startY, spaceX, height), cont);
                    unit.Ab_StartDelay = EditorGUI.FloatField(new Rect(newStartX + 60, startY, 30, height), unit.Ab_StartDelay);
                    cont = new GUIContent("Interval:", "The Interval of the casting");
                    EditorGUI.LabelField(new Rect(newStartX + 90, startY, spaceX, height), cont);
                    unit.Ab_IntervalTime = EditorGUI.FloatField(new Rect(newStartX + 140, startY, 30, height), unit.Ab_IntervalTime);
                }
            }



            startX -= 65;
            startY  = cachedY;
            startX += 35 + spaceX + width;  //startY+=20;
            width   = 200;
            cont    = new GUIContent("Dead Effect:", "The unit default's Dead Effect");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.deadEffectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + 80, startY, 80, height), unit.deadEffectObj, typeof(GameObject));

            startX += 133;

            cont = new GUIContent("Hit", "The unit default's Hit Effect");
            EditorGUI.LabelField(new Rect(startX + 30, startY, width, height), cont);
            unit.hitedEffect = (GameObject)EditorGUI.ObjectField(new Rect(startX + 80, startY, 80, height), unit.hitedEffect, typeof(GameObject));

            startX -= 133;
            startY += 20;

            cont = new GUIContent("HitPoint(HP):", "The unit default's HitPoint.\nThis is the base value to be modified by various in game bonus.");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.defaultHP = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.defaultHP);

            cont = new GUIContent(" - Regen:", "HP regeneration rate. The amount of HP to be regenerated per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.HPRegenRate = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.HPRegenRate);

            if (unit.HPRegenRate <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Stagger:", "HP regeneration stagger duration(in second). The duration which the HP regen will be stopped when a unit is hit. Once the duration is passed the HP will start regenerating again");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.HPStaggerDuration = EditorGUI.FloatField(new Rect(startX + 80, startY, 40, height), unit.HPStaggerDuration);
            GUI.color = Color.white;

            startY  = cachedY; startX += 145;
            startY += 20;

            cont = new GUIContent("Shield:", "The unit default's Shield. Shield can act as a regenerative damage absorber. A unit only be damaged once its shield has been depleted.\nThis is the base value to be modified by various in game bonus.");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            unit.defaultShield = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.defaultShield);

            if (unit.defaultShield <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Regen:", "Shield regeneration rate. The amount of shield to be regenerated per second");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.shieldRegenRate = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.shieldRegenRate);
            GUI.color            = Color.white;

            if (unit.defaultShield <= 0 || unit.shieldRegenRate <= 0)
            {
                GUI.color = new Color(0.5f, 0.5f, 0.5f, 1);
            }
            cont = new GUIContent(" - Stagger:", "Shield regeneration stagger duration(in second). The duration which the shield regen will be stopped when a unit is hit. Once the duration is passed the shield will start regenerating again");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.shieldStaggerDuration = EditorGUI.FloatField(new Rect(startX + 70, startY, 40, height), unit.shieldStaggerDuration);

            GUI.color = Color.white;

            float contentWidth = startX - cachedX + spaceX + 25;

            return(new Vector3(startX, startY + spaceY, contentWidth));
        }
Exemple #4
0
        public override void OnInspectorGUI()
        {
            GUI.changed = false;

            EditorGUILayout.Space();

            cont = new GUIContent("Energy Capacity:", "The maximum amount of energy available to player. Energy is used to cast ability and is recharged overtime");
            instance.fullEnergy = EditorGUILayout.FloatField(cont, instance.fullEnergy);

            cont = new GUIContent("Energy Rate:", "The amount of energy to be recharged at each second");
            instance.energyRate = EditorGUILayout.FloatField(cont, instance.energyRate);

            cont = new GUIContent("Full Energy Start:", "Check to start the game with full energy");
            instance.startWithFullEnergy = EditorGUILayout.Toggle(cont, instance.startWithFullEnergy);

            if (!instance.startWithFullEnergy)
            {
                cont            = new GUIContent(" - Starting Energy:", "The amount of energy player possess at the start of the game");
                instance.energy = EditorGUILayout.FloatField(cont, instance.energy);
            }

            cont = new GUIContent("Charge Before Spawn:", "Check to start energy charging before spawning");
            instance.onlyChargeOnSpawn = EditorGUILayout.Toggle(cont, instance.onlyChargeOnSpawn);

            EditorGUILayout.Space();

            cont = new GUIContent("Default Indicator:", "The default cursor indicator to used for ability target selecting in case the selected ability doesnt have a designated indicator");
            instance.defaultIndicator = (Transform)EditorGUILayout.ObjectField(cont, instance.defaultIndicator, typeof(Transform), true);


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showAbilityList = EditorGUILayout.Foldout(showAbilityList, "Show Ability List");
            EditorGUILayout.EndHorizontal();
            if (showAbilityList)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailableIDList = new List <int>();
                    for (int i = 0; i < abilityList.Count; i++)
                    {
                        instance.unavailableIDList.Add(abilityList[i].ID);
                    }
                }
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < abilityList.Count; i++)
                {
                    Ability ability = abilityList[i];

                    if (ability.disableInAbilityManager)
                    {
                        if (!instance.unavailableIDList.Contains(ability.ID))
                        {
                            instance.unavailableIDList.Add(ability.ID);
                        }
                        continue;
                    }

                    GUILayout.BeginHorizontal();

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

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

                    GUILayout.BeginHorizontal();

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

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

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();


            if (GUILayout.Button("Open AbilityEditor"))
            {
                AbilityEditorWindow.Init();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Exemple #5
0
 public static void OpenFPSWeaponEditor()
 {
     AbilityEditorWindow.Init();
 }