protected float DrawItemBasicInfo(float startX, float startY, Collectible item)
        {
            TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), item.icon);

            startX += 65;

            cont = new GUIContent("Name:", "The collectible name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont);
            item.itemName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), item.itemName);
            if (GUI.changed)
            {
                UpdateLabel_Collectible();
            }

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

            cont = new GUIContent("Prefab:", "The prefab object of the collectible\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), item.gameObject, typeof(GameObject), false);

            startX -= 65;
            startY += spaceY * 2;

            cont = new GUIContent("Trigger Effect:", "The effect object to be spawned when the item is triggered\nThis is entirely optional");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            item.triggerEffectObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.triggerEffectObj, typeof(GameObject), false);

            cont = new GUIContent(" - AutoDestroy:", "Check if the effect object needs to be removed from the game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (item.triggerEffectObj != null)
            {
                item.destroyTriggerEffect = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.destroyTriggerEffect);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", ""));
            }

            cont = new GUIContent(" - EffectDuration:", "The delay in seconds before the effect object is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (item.triggerEffectObj != null && item.destroyTriggerEffect)
            {
                item.triggerEffectDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.triggerEffectDuration);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", ""));
            }

            return(startY + spaceY);
        }
        private Vector2 DrawAbilityConfigurator(float startX, float startY, FactionAbility ability)
        {
            TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), ability.icon);
            startX += 65;

            cont = new GUIContent("Name:", "The ability name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY / 4, width, height), cont);
            ability.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.name);
            if (GUI.changed)
            {
                UpdateLabel_FactionAbility();
            }

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

            cont = new GUIContent("AbilityID:", "The ID used to associate a perk item in perk menu to a perk when configuring perk menu manually");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.LabelField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.prefabID.ToString());

            startX -= 65;
            startY += 10 + spaceY - spaceY / 2;         //cachedY=startY;

            cont = new GUIContent("Only Available Via Perk:", "Check if the ability can only be added by perk ");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            ability.onlyAvailableViaPerk = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, widthS, height), ability.onlyAvailableViaPerk);

            startY += 10;

            startY = DrawGeneralSetting(startX, startY + spaceY, ability);

            startY = DrawTargetingSetting(startX, startY + spaceY, ability);

            startY = DrawAbilityVisualEffect(startX, startY + spaceY, ability);

            startY = DrawAbilityEffect(startX, startY + spaceY, ability);

            startY += 10;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            ability.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 100), ability.desp, style);


            return(new Vector2(startX, startY + spaceY + 100));
        }
        public static void Init(int prefabID = -1)
        {
            // Get existing open window or if none, make a new one:
            window         = (NewCollectibleEditorWindow)EditorWindow.GetWindow(typeof(NewCollectibleEditorWindow), false, "Collectible Editor");
            window.minSize = new Vector2(420, 300);

            LoadDB();

            //InitLabel();

            if (prefabID >= 0)
            {
                window.selectID = TBEditor.GetCollectibleIndex(prefabID) - 1;
            }

            window.SetupCallback();
        }
Пример #4
0
        private Vector2 DrawPerkConfigurator(float startX, float startY, Perk perk)
        {
            TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), perk.icon);
            startX += 65;

            cont = new GUIContent("Name:", "The perk name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY / 4, width, height), cont);
            perk.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.name);
            if (GUI.changed)
            {
                UpdateLabel_Perk();
            }

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

            cont = new GUIContent("PerkID:", "The ID used to associate a perk item in perk menu to a perk when configuring perk menu manually");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.LabelField(new Rect(startX + spaceX - 65, startY, width - 5, height), perk.prefabID.ToString());

            startX -= 65;
            startY += 10 + spaceY - spaceY / 2;         //cachedY=startY;

            startY = DrawGeneralSetting(startX, startY + spaceY, perk);

            startY = DrawPerkProperty(startX, startY + spaceY, perk);

            startY += 10;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            perk.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 100), perk.desp, style);


            return(new Vector2(startX, startY + spaceY + 100));
        }
Пример #5
0
 protected static void UpdateLabel_DamageTable()
 {
     TBEditor.UpdateLabel_DamageTable();
 }
Пример #6
0
 protected static void LoadDamageTable()
 {
     TBEditor.LoadDamageTable();
 }
Пример #7
0
        protected Vector2 DrawList(float startX, float startY, float winWidth, float winHeight, List <Item> list, bool drawRemove = true, bool shiftItem = true, bool clampSelectID = true)
        {
            float width = minimiseList ? 60 : 260;

            if (!minimiseList && shiftItem)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (shiftItemUpCallback != null)
                    {
                        shiftItemUpCallback();
                    }
                    else
                    {
                        Debug.Log("call back is null");
                    }
                    if (selectID * 35 < scrollPosList.y)
                    {
                        scrollPosList.y = selectID * 35;
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (shiftItemDownCallback != null)
                    {
                        shiftItemDownCallback();
                    }
                    else
                    {
                        Debug.Log("call back is null");
                    }
                    if (visibleRectList.height - 35 < selectID * 35)
                    {
                        scrollPosList.y = (selectID + 1) * 35 - visibleRectList.height + 5;
                    }
                }
            }

            visibleRectList = new Rect(startX, startY, width + 15, winHeight - startY - 5);
            contentRectList = new Rect(startX, startY, width, list.Count * 35 + 5);

            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(visibleRectList, "");
            GUI.color = Color.white;

            scrollPosList = GUI.BeginScrollView(visibleRectList, scrollPosList, contentRectList);

            startY += 5;      startX += 5;

            for (int i = 0; i < list.Count; i++)
            {
                TBEditor.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), list[i].icon);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        Select(i);
                    }
                    GUI.color = Color.white;
                    continue;
                }

                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150 + (!drawRemove ? 60 : 0), 30), list[i].name))
                {
                    Select(i);
                }
                GUI.color = Color.white;

                if (!drawRemove)
                {
                    continue;
                }

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            Select(Mathf.Max(0, selectID - 1));
                        }
                        if (deleteItemCallback != null)
                        {
                            deleteItemCallback();
                        }
                        else
                        {
                            Debug.Log("callback is null");
                        }
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            if (clampSelectID)
            {
                selectID = Mathf.Clamp(selectID, 0, list.Count - 1);
            }

            return(new Vector2(startX + width + 10, startY));
        }
Пример #8
0
        protected float DrawPerkProperty(float startX, float startY, Perk perk)
        {
            string text = "Perk Property " + (!foldProperty ? "(show)" : "(hide)");

            foldProperty = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldProperty, text, foldoutStyle);
            if (foldProperty)
            {
                startX += 15;

                int type = (int)perk.type;
                cont = new GUIContent("Perk Type:", "What the perk does");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                contL = new GUIContent[perkTypeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(perkTypeLabel[i], perkTypeTooltip[i]);
                }
                type      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
                perk.type = (_PerkType)type;

                startY += 8;
                spaceX -= 5;      startX += 5;

                if (perk.type == _PerkType.Unit || perk.type == _PerkType.Unit_All)
                {
                    if (perk.type == _PerkType.Unit)
                    {
                        cont = new GUIContent("Target Units:", "Unit that will be affected by the perk");
                        EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont, perk.unitIDList.Count > 0 ? new GUIStyle("Label") : conflictStyle);

                        for (int i = 0; i < perk.unitIDList.Count + 1; i++)
                        {
                            EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                            int index = (i < perk.unitIDList.Count) ? TBEditor.GetUnitIndex(perk.unitIDList[i]) : 0;
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), index, unitLabel);
                            if (index > 0)
                            {
                                int unitID = unitDB.unitList[index - 1].prefabID;
                                if (!perk.unitIDList.Contains(unitID))
                                {
                                    if (i < perk.unitIDList.Count)
                                    {
                                        perk.unitIDList[i] = unitID;
                                    }
                                    else
                                    {
                                        perk.unitIDList.Add(unitID);
                                    }
                                }
                            }
                            else if (i < perk.unitIDList.Count)
                            {
                                perk.unitIDList.RemoveAt(i); i -= 1;
                            }

                            if (i < perk.unitIDList.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-"))
                            {
                                perk.unitIDList.RemoveAt(i); i -= 1;
                            }
                        }
                    }

                    startY = DrawStatsModifier(startX, startY + spaceY + 5, perk.stats);
                }

                if (perk.type == _PerkType.UnitAbility || perk.type == _PerkType.UnitAbility_All)
                {
                    if (perk.type == _PerkType.UnitAbility)
                    {
                        cont = new GUIContent("Target Abilities:", "Unit Abilities that will be affected by the perk");
                        EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont, perk.unitAbilityIDList.Count > 0 ? new GUIStyle("Label") : conflictStyle);

                        for (int i = 0; i < perk.unitAbilityIDList.Count + 1; i++)
                        {
                            EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                            int index = (i < perk.unitAbilityIDList.Count) ? TBEditor.GetUnitAbilityIndex(perk.unitAbilityIDList[i]) : 0;
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), index, uAbilityLabel);
                            if (index > 0)
                            {
                                int abID = uAbilityDB.abilityList[index - 1].prefabID;
                                if (!perk.unitAbilityIDList.Contains(abID))
                                {
                                    if (i < perk.unitAbilityIDList.Count)
                                    {
                                        perk.unitAbilityIDList[i] = abID;
                                    }
                                    else
                                    {
                                        perk.unitAbilityIDList.Add(abID);
                                    }
                                }
                            }
                            else if (i < perk.unitAbilityIDList.Count)
                            {
                                perk.unitAbilityIDList.RemoveAt(i); i -= 1;
                            }

                            if (i < perk.unitAbilityIDList.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-"))
                            {
                                perk.unitAbilityIDList.RemoveAt(i); i -= 1;
                            }
                        }
                    }

                    startY = DrawAbilityModifier(startX, startY + spaceY + 10, perk, true) + 5;
                    startY = DrawStatsModifier(startX, startY, perk.stats);
                }

                if (perk.type == _PerkType.FactionAbility || perk.type == _PerkType.FactionAbility_All)
                {
                    if (perk.type == _PerkType.FactionAbility)
                    {
                        cont = new GUIContent("Target Abilities:", "Faction Abilities that will be affected by the perk");
                        EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont, perk.facAbilityIDList.Count > 0 ? new GUIStyle("Label") : conflictStyle);

                        for (int i = 0; i < perk.facAbilityIDList.Count + 1; i++)
                        {
                            EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                            int index = (i < perk.facAbilityIDList.Count) ? TBEditor.GetFactionAbilityIndex(perk.facAbilityIDList[i]) : 0;
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), index, fAbilityLabel);
                            if (index > 0)
                            {
                                int abID = fAbilityDB.abilityList[index - 1].prefabID;
                                if (!perk.facAbilityIDList.Contains(abID))
                                {
                                    if (i < perk.facAbilityIDList.Count)
                                    {
                                        perk.facAbilityIDList[i] = abID;
                                    }
                                    else
                                    {
                                        perk.facAbilityIDList.Add(abID);
                                    }
                                }
                            }
                            else if (i < perk.facAbilityIDList.Count)
                            {
                                perk.facAbilityIDList.RemoveAt(i); i -= 1;
                            }

                            if (i < perk.facAbilityIDList.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-"))
                            {
                                perk.facAbilityIDList.RemoveAt(i); i -= 1;
                            }
                        }
                    }

                    startY = DrawAbilityModifier(startX, startY + spaceY + 10, perk, false) + 5;
                    startY = DrawStatsModifier(startX, startY, perk.stats);
                }

                if (perk.type == _PerkType.NewUnitAbility)
                {
                    int index = TBEditor.GetUnitAbilityIndex(perk.newUnitAbilityID);

                    cont = new GUIContent("New Abilitiy:", "New unit ability to be added to the selected units");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, index == 0 ? conflictStyle : new GUIStyle("Label"));

                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, uAbilityLabel);
                    if (index > 0)
                    {
                        perk.newUnitAbilityID = uAbilityDB.abilityList[index - 1].prefabID;
                    }
                    else
                    {
                        perk.newUnitAbilityID = -1;
                    }


                    cont = new GUIContent("Replacing:", "(Optional) Existing unit ability to be replaced by the new ability.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

                    index = TBEditor.GetUnitAbilityIndex(perk.subUnitAbilityID);
                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, uAbilityLabel);
                    if (index > 0 && uAbilityDB.abilityList[index - 1].prefabID != perk.newUnitAbilityID)
                    {
                        perk.subUnitAbilityID = uAbilityDB.abilityList[index - 1].prefabID;
                    }
                    else
                    {
                        perk.subUnitAbilityID = -1;
                    }

                    startY += 5;

                    cont = new GUIContent("Add to all Unit:", "Check if the ability is to add to all player unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    perk.addAbilityToAllUnit = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), perk.addAbilityToAllUnit);

                    if (!perk.addAbilityToAllUnit)
                    {
                        cont = new GUIContent("Target Units:", "Units that will gain the new abilities");
                        EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont, perk.newABUnitIDList.Count == 0 ? conflictStyle : new GUIStyle("Label"));

                        for (int i = 0; i < perk.newABUnitIDList.Count + 1; i++)
                        {
                            EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                            int uIndex = (i < perk.newABUnitIDList.Count) ? TBEditor.GetUnitIndex(perk.newABUnitIDList[i]) : 0;
                            uIndex = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), uIndex, unitLabel);
                            if (uIndex > 0)
                            {
                                int unitID = unitDB.unitList[uIndex - 1].prefabID;
                                if (!perk.newABUnitIDList.Contains(unitID))
                                {
                                    if (i < perk.newABUnitIDList.Count)
                                    {
                                        perk.unitIDList[i] = unitID;
                                    }
                                    else
                                    {
                                        perk.newABUnitIDList.Add(unitID);
                                    }
                                }
                            }
                            else if (i < perk.newABUnitIDList.Count)
                            {
                                perk.newABUnitIDList.RemoveAt(i); i -= 1;
                            }

                            if (i < perk.newABUnitIDList.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-"))
                            {
                                perk.newABUnitIDList.RemoveAt(i); i -= 1;
                            }
                        }
                    }
                }

                if (perk.type == _PerkType.NewFactionAbility)
                {
                    int index = TBEditor.GetFactionAbilityIndex(perk.newFacAbilityID);

                    cont = new GUIContent("New Abilitiy:", "New faction Ability to be added to the game");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, index == 0 ? conflictStyle : new GUIStyle("Label"));

                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, fAbilityLabel);
                    if (index > 0)
                    {
                        perk.newFacAbilityID = fAbilityDB.abilityList[index - 1].prefabID;
                    }
                    else
                    {
                        perk.newFacAbilityID = -1;
                    }

                    cont = new GUIContent("Replacing:", "(Optional) Existing faction ability to be replaced by the new ability.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

                    index = TBEditor.GetFactionAbilityIndex(perk.subFacAbilityID);
                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, fAbilityLabel);
                    if (index > 0 && fAbilityDB.abilityList[index - 1].prefabID != perk.newFacAbilityID)
                    {
                        perk.subFacAbilityID = fAbilityDB.abilityList[index - 1].prefabID;
                    }
                    else
                    {
                        perk.subFacAbilityID = -1;
                    }
                }

                spaceX += 5;      startX -= 5;
            }

            return(startY + spaceY);
        }
Пример #9
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake();
            }

            GUI.changed = false;

            EditorGUILayout.Space();


            PrefabType type = PrefabUtility.GetPrefabType(instance);

            if (type == PrefabType.Prefab || type == PrefabType.PrefabInstance)
            {
                bool existInDB = false;
                if (type == PrefabType.PrefabInstance)
                {
                    existInDB = TBEditor.ExistInDB((Unit)PrefabUtility.GetCorrespondingObjectFromSource(instance));
                }
                else if (type == PrefabType.Prefab)
                {
                    existInDB = TBEditor.ExistInDB(instance);
                }

                if (!existInDB)
                {
                    EditorGUILayout.Space();

                    EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible to the game.", MessageType.Warning);
                    GUI.color = new Color(1f, 0.7f, .2f, 1f);
                    if (GUILayout.Button("Add Prefab to Database"))
                    {
                        NewUnitEditorWindow.Init();
                        NewUnitEditorWindow.NewItem(instance);
                        NewUnitEditorWindow.Init();                                     //call again to select the instance in editor window
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    EditorGUILayout.HelpBox("Editing unit using Inspector is not recommended.\nPlease use the editor window instead.", MessageType.Info);
                    if (GUILayout.Button("Unit Editor Window"))
                    {
                        NewUnitEditorWindow.Init(instance.prefabID);
                    }
                }

                EditorGUILayout.Space();
            }
            else
            {
                string text = "Unit object won't be available for game deployment, or accessible in TBTK editor until it's made a prefab and added to TBTK database.";
                text += "\n\nYou can still edit the unit using default inspector. However it's not recommended";
                EditorGUILayout.HelpBox(text, MessageType.Warning);

                EditorGUILayout.Space();
                if (GUILayout.Button("Unit Editor Window"))
                {
                    NewUnitEditorWindow.Init(instance.prefabID);
                }
            }


            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        protected float DrawSpawnGroup(float startX, float startY, FactionSpawnInfo spInfo)
        {
            cont = new GUIContent("Tiles Count:", "The number of tiles assigned to this SpawnGroup in which the unit can be placed on. This can be Edit in GridEditor");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), spInfo.startingTileList.Count.ToString());

            cont = new GUIContent("Limit Type:", "The type of spawn limit applied to this spawn group.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            int limitType = (int)spInfo.limitType;

            cont = new GUIContent("", "");    contL = new GUIContent[limitTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(limitTypeLabel[i], limitTypeTooltip[i]);
            }
            limitType        = EditorGUI.Popup(new Rect(startX + spaceX, startY, width - widthS - 5, height), cont, limitType, contL);
            spInfo.limitType = (FactionSpawnInfo._LimitType)limitType;


            spInfo.limit = EditorGUI.IntField(new Rect(startX + spaceX + width - widthS, startY, widthS, height), spInfo.limit);
            spInfo.limit = Mathf.Clamp(spInfo.limit, 1, 99);


            cont = new GUIContent("Prefab List:", "Unit to be spawned for this spawn group");
            GUI.Label(new Rect(startX, startY + spaceY, width, height), cont);

            for (int i = 0; i < spInfo.unitPrefabList.Count + 1; i++)
            {
                int index = i >= spInfo.unitPrefabList.Count ? 0 : TBEditor.GetUnitIndex(spInfo.unitPrefabList[i].prefabID);

                GUI.Label(new Rect(startX + spaceX - 15, startY += spaceY, width, height), " - ");
                index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width - widthS - 5, height), index, unitLabel);

                if (index > 0)
                {
                    Unit unit = unitDB.unitList[index - 1];
                    if (!spInfo.unitPrefabList.Contains(unit))
                    {
                        if (i < spInfo.unitPrefabList.Count)
                        {
                            spInfo.unitPrefabList[i] = unit;
                        }
                        else
                        {
                            spInfo.unitPrefabList.Add(unit);
                        }
                    }
                }
                else if (i < spInfo.unitPrefabList.Count)
                {
                    spInfo.unitPrefabList.RemoveAt(i);      i -= 1;
                }

                while (spInfo.unitLimitList.Count < spInfo.unitPrefabList.Count)
                {
                    spInfo.unitLimitList.Add(50);
                }
                while (spInfo.unitLimitList.Count > spInfo.unitPrefabList.Count)
                {
                    spInfo.unitLimitList.RemoveAt(spInfo.unitLimitList.Count - 1);
                }

                if (i < spInfo.unitPrefabList.Count && i >= 0)
                {
                    spInfo.unitLimitList[i] = EditorGUI.IntField(new Rect(startX + spaceX + width - widthS, startY, widthS, height), spInfo.unitLimitList[i]);
                }
            }

            cont = new GUIContent("Spawn Direction:", "The default unit rotation in y-axis rotation for this spawn group\nValue from 0-360");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spInfo.spawnDirection = EditorGUI.FloatField(new Rect(startX + spaceX, startY, width / 2, height), spInfo.spawnDirection);
            spInfo.spawnDirection = Mathf.Clamp(spInfo.spawnDirection, 0, 360);

            GUI.Label(new Rect(startX, startY + 7, spaceX + width, height), "____________________________________________");

            return(startY);
        }
Пример #11
0
        protected float DrawUnitReserveAbilities(float startX, float startY, Unit unit)
        {
            string text = "Unit Deck Abilities " + (!foldAbilities ? "(show)" : "(hide)");

            foldAbilities = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldAbilities, text, foldoutStyle);
            if (foldAbilities)
            {
                startX += 15;

                if (unit.reserveAbilityIDList.Count > 0)
                {
                    startY += spaceY;
                    for (int i = 0; i < unit.reserveAbilityIDList.Count; i++)
                    {
                        int index = TBEditor.GetUnitAbilityIndex(unit.reserveAbilityIDList[i]);

                        if (index < 0)
                        {
                            unit.reserveAbilityIDList.RemoveAt(i);
                            i -= 1;   continue;
                        }

                        TBEditor.DrawSprite(new Rect(startX + (i * 45), startY, 40, 40), uAbilityDB.abilityList[index - 1].icon);
                    }

                    startY += 45 - spaceY;
                }

                cont = new GUIContent("Abilities:", "Abilities in the common deck");
                EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont);

                int count = Mathf.Min(unit.reserveAbilityIDList.Count + 1, 6);

                for (int i = 0; i < count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX + 55, startY + spaceY, width, height), "-");

                    int index = (i < unit.reserveAbilityIDList.Count) ? TBEditor.GetUnitAbilityIndex(unit.reserveAbilityIDList[i]) : 0;
                    index = EditorGUI.Popup(new Rect(startX + 65, startY += spaceY, width, height), index, uAbilityLabel);
                    if (index > 0)
                    {
                        int abID = uAbilityDB.abilityList[index - 1].prefabID;
                        //if(!unit.reserveAbilityIDList.Contains(abID)){
                        if (i < unit.reserveAbilityIDList.Count)
                        {
                            unit.reserveAbilityIDList[i] = abID;
                        }
                        else
                        {
                            unit.reserveAbilityIDList.Add(abID);
                        }
                        //}
                    }
                    else if (i < unit.reserveAbilityIDList.Count)
                    {
                        unit.reserveAbilityIDList.RemoveAt(i); i -= 1;
                    }

                    if (i < unit.reserveAbilityIDList.Count && GUI.Button(new Rect(startX + 67 + width, startY, 20, height - 1), "-"))
                    {
                        unit.reserveAbilityIDList.RemoveAt(i); i -= 1;
                    }
                }
            }

            return(startY + spaceY);
        }
Пример #12
0
 protected static void LoadFactionAbility()
 {
     TBEditor.LoadFactionAbility();
 }
Пример #13
0
 protected static void UpdateLabel_UnitAbility()
 {
     TBEditor.UpdateLabel_UnitAbility();
 }
Пример #14
0
 protected static void LoadUnitAbility()
 {
     TBEditor.LoadUnitAbility();
 }
Пример #15
0
 protected static void LoadUnit()
 {
     TBEditor.LoadUnit();
 }
        //private bool showItemList=true;
        void DrawItemList()
        {
            //~ EditorGUILayout.BeginHorizontal();
            //~ EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            //~ showPerkList=EditorGUILayout.Foldout(showItemList, "Show Collectible List");
            //~ EditorGUILayout.EndHorizontal();
            //~ if(showItemList){

            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 < collectibleDB.collectibleList.Count; i++)
                {
                    instance.unavailableIDList.Add(collectibleDB.collectibleList[i].prefabID);
                }
            }
            EditorGUILayout.EndHorizontal();


            for (int i = 0; i < collectibleDB.collectibleList.Count; i++)
            {
                Collectible item = collectibleDB.collectibleList[i];

                GUILayout.BeginHorizontal();

                GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                Rect rect = GUILayoutUtility.GetLastRect();
                TBEditor.DrawSprite(rect, item.icon, item.desp, false);

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

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

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

                GUILayout.EndHorizontal();

                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }

            //}
        }
Пример #17
0
        void DrawPerkList()
        {
            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 < perkDB.perkList.Count; i++)
                    {
                        instance.unavailableIDList.Add(perkDB.perkList[i].prefabID);
                    }
                }
                EditorGUILayout.EndHorizontal();


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

                    GUILayout.BeginHorizontal();

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

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

                    GUILayout.BeginHorizontal();
                    bool flag = !instance.unavailableIDList.Contains(perk.prefabID) ? 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.prefabID);
                        }
                        else
                        {
                            if (!instance.unavailableIDList.Contains(perk.prefabID))
                            {
                                instance.unavailableIDList.Add(perk.prefabID);
                                instance.purchasedIDList.Remove(perk.prefabID);
                            }
                        }
                    }

                    if (!instance.unavailableIDList.Contains(perk.prefabID))
                    {
                        flag = instance.purchasedIDList.Contains(perk.prefabID);
                        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.prefabID);
                        }
                        else if (!instance.purchasedIDList.Contains(perk.prefabID))
                        {
                            instance.purchasedIDList.Add(perk.prefabID);
                        }
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }
        }
Пример #18
0
        protected float DrawUnitBasicStats(float startX, float startY, Unit unit)
        {
            TBEditor.DrawSprite(new Rect(startX, startY, 60, 60), unit.iconSprite);

            startX += 65;

            //bool enter=Event.current.Equals (Event.KeyboardEvent ("return"));
            cont = new GUIContent("Name:", "The unit name to be displayed in game");
            EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont);
            unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), unit.unitName);
            //if(enter) UpdateLabel_Unit();
            if (GUI.changed)
            {
                UpdateLabel_Unit();
            }


            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, height), unit.iconSprite, typeof(Sprite), false);

            cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.gameObject, typeof(GameObject), false);

            startX -= 65;
            startY += spaceY * 2;

            string text = "Basic Unit Info " + (!foldHitPoint ? "(show)" : "(hide)");

            foldHitPoint = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldHitPoint, text, foldoutStyle);
            if (foldHitPoint)
            {
                startX += 15;

                cont = new GUIContent("HitPoint (HP):", "The unit's base Hit-Point.\nDetermine how much the damage the unit can take before it's destroyed");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.defaultHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.defaultHP);

                cont = new GUIContent(" - Regen (PerTurn):", "HP regeneration rate. The amount of HP to be regenerated each turn");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.HPPerTurn = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.HPPerTurn);

                //startX+=140;		startY=cachedY;
                startY += 5;

                cont = new GUIContent("ActionPoint (AP):", "The unit's base Action-Point. Used by the unit to performed various action");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.defaultAP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.defaultAP);

                cont = new GUIContent(" - Regen (PerTurn):", "AP regeneration rate. The amount of AP to be regenerated each turn");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.APPerTurn = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.APPerTurn);

                //startX-=140;
                startY += 5;

                cont = new GUIContent("Unit Value:", "The value of the unit. Used in unit generation on grid if the limit mode is set to be based on value.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.value = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.value);
            }

            return(startY + spaceY);
        }
Пример #19
0
 protected static void UpdateLabel_FactionAbility()
 {
     TBEditor.UpdateLabel_FactionAbility();
 }
        protected float DrawFactionAbilityInfo(float startX, float startY, Faction faction)
        {
            string text = "Faction Abilities " + (!foldAbilityInfo ? "(show)" : "(hide)");

            foldAbilityInfo = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldAbilityInfo, text, foldoutStyle);
            if (foldAbilityInfo)
            {
                startX += 15;     spaceX -= 15;

                FactionAbilityInfo abInfo = faction.abilityInfo;

                cont = new GUIContent(" - Full Energy:", "The maximum energy pool available to use ability for the faction");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                abInfo.energyFull = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), abInfo.energyFull);

                cont = new GUIContent(" - Energy Rate:", "The amount of energy gained each turn");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                abInfo.energyGainPerTurn = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), abInfo.energyGainPerTurn);


                cont = new GUIContent(" - Abilities:", "Abilities available for this faction");
                GUI.Label(new Rect(startX, startY + spaceY, width, height), cont);

                for (int i = 0; i < fAbilityDB.abilityList.Count; i++)
                {
                    if (fAbilityDB.abilityList[i].onlyAvailableViaPerk)
                    {
                        continue;
                    }
                    if (abInfo.unavailableIDList.Contains(fAbilityDB.abilityList[i].prefabID))
                    {
                        continue;
                    }
                    if (!abInfo.availableIDList.Contains(fAbilityDB.abilityList[i].prefabID))
                    {
                        abInfo.availableIDList.Add(fAbilityDB.abilityList[i].prefabID);
                    }
                }

                for (int i = 0; i < abInfo.availableIDList.Count + 1; i++)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX - 15, startY + spaceY, width, height), "-");

                    int index = (i < abInfo.availableIDList.Count) ? TBEditor.GetFactionAbilityIndex(abInfo.availableIDList[i]) : 0;
                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 22, height), index, fAbilityLabel);
                    if (index > 0)
                    {
                        int abID = fAbilityDB.abilityList[index - 1].prefabID;
                        if (fAbilityDB.abilityList[index - 1].onlyAvailableViaPerk)
                        {
                            Debug.LogWarning("Ability '" + fAbilityDB.abilityList[index - 1].name + "' can only be unlocked via perk", this);
                        }
                        else if (!abInfo.availableIDList.Contains(abID))
                        {
                            if (i < abInfo.availableIDList.Count)
                            {
                                abInfo.availableIDList[i] = abID;
                            }
                            else
                            {
                                abInfo.availableIDList.Add(abID);
                            }
                        }
                    }
                    else if (i < abInfo.availableIDList.Count)
                    {
                        abInfo.availableIDList.RemoveAt(i); i -= 1;
                    }

                    if (i < abInfo.availableIDList.Count && GUI.Button(new Rect(startX + spaceX + width - 20, startY, 20, height - 1), "-"))
                    {
                        abInfo.availableIDList.RemoveAt(i); i -= 1;
                    }
                }

                abInfo.unavailableIDList = new List <int>();
                for (int i = 0; i < fAbilityDB.abilityList.Count; i++)
                {
                    if (fAbilityDB.abilityList[i].onlyAvailableViaPerk)
                    {
                        continue;
                    }
                    if (abInfo.availableIDList.Contains(fAbilityDB.abilityList[i].prefabID))
                    {
                        continue;
                    }
                    abInfo.unavailableIDList.Add(fAbilityDB.abilityList[i].prefabID);
                }

                spaceX += 15;
            }

            return(startY);
        }
Пример #21
0
 protected static void LoadPerk()
 {
     TBEditor.LoadPerk();
 }
        protected float DrawStartUnitSetting(float startX, float startY, Faction faction)
        {
            string text = "Starting Units " + (!foldUnit ? "(show)" : "(hide)");

            foldUnit = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldUnit, text, foldoutStyle);
            if (foldUnit)
            {
                startX += 15;     spaceX -= 15;

                cont = new GUIContent("Load From Data:", "Check to have the starting unit load from data setup prior to the level start.\n\nMUST HAVE ASSIGNED UNIT USING TBData.SetStartData()\n\nRefer to the section 'Integrating TBTK To Your Game' in documentation;");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                faction.loadFromData = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), faction.loadFromData);

                if (faction.loadFromData)
                {
                    cont = new GUIContent("Data-ID:", "The reference ID use to load the matching data as there can be multiple set of data.");
                    EditorGUI.LabelField(new Rect(startX + spaceX + 20, startY, width, height), cont);
                    faction.dataID = EditorGUI.IntField(new Rect(startX + spaceX + 75, startY, widthS, height), faction.dataID);

                    cont = new GUIContent(" - Starting Unit:", "Unit to be spawned and deployed before the start of the game");
                    GUI.Label(new Rect(startX, startY + spaceY, width, height), cont);
                    GUI.Label(new Rect(startX + spaceX, startY + spaceY, width, height), "-");

                    startY += spaceY;
                }
                else
                {
                    cont = new GUIContent(" - Starting Unit:", "Unit to be spawned and deployed before the start of the game");
                    GUI.Label(new Rect(startX, startY + spaceY, width, height), cont);

                    for (int i = 0; i < faction.startingUnitList.Count + 1; i++)
                    {
                        int index = i >= faction.startingUnitList.Count ? 0 : TBEditor.GetUnitIndex(faction.startingUnitList[i].prefabID);

                        GUI.Label(new Rect(startX + spaceX - 15, startY += spaceY, width, height), " - ");
                        index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, unitLabel);

                        if (index > 0)
                        {
                            Unit unit = unitDB.unitList[index - 1];
                            //if(!faction.startingUnitList.Contains(unit)){
                            if (i < faction.startingUnitList.Count)
                            {
                                faction.startingUnitList[i] = unit;
                            }
                            else
                            {
                                faction.startingUnitList.Add(unit);
                            }
                            //}
                        }
                        else if (i < faction.startingUnitList.Count)
                        {
                            faction.startingUnitList.RemoveAt(i);        i -= 1;
                        }
                    }
                }

                spaceX += 15;
            }

            return(startY + spaceY);
        }
        protected float DrawAbilityEffect(float startX, float startY, FactionAbility ability)
        {
            string text = "Ability Effects Setting " + (!foldEffect ? "(show)" : "(hide)");

            foldEffect = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldEffect, text, foldoutStyle);
            if (foldEffect)
            {
                startX += 15;

                //~ cont=new GUIContent("Use Default Effect:", "Check if the ability use default TBTK effect.\n\nAlternatively you can use your own custom effect by putting a custom script to on the spawn visual effect object");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ ability.useDefaultEffect=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), ability.useDefaultEffect);

                if (ability.useDefaultEffect)
                {
                    cont = new GUIContent("Effect Delay:", "Delay in second before the effect actually take place.\nThis is for the visual effect to kicks in");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (ability.type == _AbilityType.None)
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                    }
                    ability.effectDelayDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ability.effectDelayDuration);

                    startY += 5;

                    int type = (int)ability.type;
                    cont = new GUIContent("Ability Effect Type:", "Type of the ability's effect. Define what the ability do");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    contL = new GUIContent[abilityTypeLabel.Length];
                    for (int i = 0; i < contL.Length; i++)
                    {
                        contL[i] = new GUIContent(abilityTypeLabel[i], abilityTypeTooltip[i]);
                    }
                    type         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
                    ability.type = (_AbilityType)type;

                    //startX+=15;	spaceX-=15;

                    if (ability.type == _AbilityType.Generic)
                    {
                        startY = DrawEffect(startX, startY + spaceY, ability.effect);
                    }

                    //~ if(ability.type==UnitAbility._AbilityType.Teleport){
                    //~ GUI.Label(new Rect(startX+spaceX, startY+=spaceY, width, height), "- No input required -");
                    //~ }

                    if (ability.type == _AbilityType.ScanFogOfWar)
                    {
                        //GUI.Label(new Rect(startX+spaceX, startY+=spaceY, width, height), "- No input required -");

                        cont = new GUIContent(" - Duration:", "");
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                        ability.effect.duration = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), ability.effect.duration);
                    }

                    if (ability.type == _AbilityType.SpawnNew)
                    {
                        cont = new GUIContent(" - Unit To Spawn:", "Unit to be spawned");
                        GUI.Label(new Rect(startX, startY += spaceY, width, height), cont);
                        int index = ability.spawnUnit != null?TBEditor.GetUnitIndex(ability.spawnUnit.prefabID) : 0;

                        index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, unitLabel);
                        if (index > 0)
                        {
                            ability.spawnUnit = unitDB.unitList[index - 1];
                        }
                        else if (index == 0)
                        {
                            ability.spawnUnit = null;
                        }
                    }


                    if (ability.type == _AbilityType.SpawnNew)
                    {
                        if (ability.targetType != _TargetType.EmptyTile)
                        {
                            Debug.LogWarning(ability.type + " ability must have 'EmptyTile' TargetType");
                        }
                        if (!ability.requireTargetSelection)
                        {
                            Debug.LogWarning(ability.type + " ability requires target selection");
                        }
                        if (ability.type != _AbilityType.ScanFogOfWar && ability.aoeRange > 0)
                        {
                            Debug.LogWarning(ability.type + " ability's aoe-range must be zero");
                        }

                        ability.targetType             = _TargetType.EmptyTile;
                        ability.requireTargetSelection = true;
                        if (ability.type != _AbilityType.ScanFogOfWar)
                        {
                            ability.aoeRange = 0;
                        }
                    }


                    //startX-=15;	spaceX+=15;
                }
            }

            return(startY + spaceY);
        }
Пример #24
0
 protected static void UpdateLabel_Perk()
 {
     TBEditor.UpdateLabel_Perk();
 }
Пример #25
0
        protected float DrawGeneralSetting(float startX, float startY, Perk perk)
        {
            string text = "General Setting " + (!foldGeneral ? "(show)" : "(hide)");

            foldGeneral = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldGeneral, text, foldoutStyle);
            if (foldGeneral)
            {
                startX += 15;

                cont = new GUIContent("Cost:", "How many perk currency is required to purchase the perk");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.cost);

                cont = new GUIContent("Min PerkPoint req:", "Minimum perk point to have before the perk becoming available");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.minPerkPoint = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.minPerkPoint);

                startY += 5;

                cont = new GUIContent("Prerequisite Perk:", "Perks that needs to be purchased before this perk is unlocked and become available");
                EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont);

                for (int i = 0; i < perk.prereq.Count + 1; i++)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                    int index = (i < perk.prereq.Count) ? TBEditor.GetPerkIndex(perk.prereq[i]) : 0;
                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width - 20, height), index, perkLabel);
                    if (index > 0)
                    {
                        int perkID = perkDB.perkList[index - 1].prefabID;
                        if (perkID != perk.prefabID && !perk.prereq.Contains(perkID))
                        {
                            if (i < perk.prereq.Count)
                            {
                                perk.prereq[i] = perkID;
                            }
                            else
                            {
                                perk.prereq.Add(perkID);
                            }
                        }
                    }
                    else if (i < perk.prereq.Count)
                    {
                        perk.prereq.RemoveAt(i); i -= 1;
                    }

                    if (i < perk.prereq.Count && GUI.Button(new Rect(startX + spaceX + width - 15, startY, 20, height - 1), "-"))
                    {
                        perk.prereq.RemoveAt(i); i -= 1;
                    }
                }

                if (perk.prereq.Count > 0)
                {
                    startY += spaceY + 5;
                    for (int i = 0; i < perk.prereq.Count; i++)
                    {
                        int index = TBEditor.GetPerkIndex(perk.prereq[i]) - 1;
                        TBEditor.DrawSprite(new Rect(startX + (i * 45), startY, 40, 40), perkDB.perkList[index].icon);
                    }
                    startY += 45 - spaceY;
                }
            }

            return(startY + spaceY);
        }
        Vector2 DrawCollectibleConfigurator(float startX, float startY, Collectible item)
        {
            float maxX = startX;

            startY = DrawItemBasicInfo(startX, startY, item) - 10;

            if (GUI.Button(new Rect(startX + spaceX + width - 100, startY += spaceY, 100, height), "Ability Editor"))
            {
                NewFactionAbilityEditorWindow.Init();
            }

            string tooltip = "The ability to cast when the item is triggered";

            tooltip += "\n\nUses ability setup in Faction Ability Editor but does not cost energy";
            tooltip += "\n\n*The ability target setting still applies, the effect will be applied to all unit if the 'require target selection' option is not checked";
            tooltip += "\n\nRandom ability will be chosen when multiple abilities has been assigned, useful for item with random effects";
            cont     = new GUIContent("Trigger Ability:", tooltip);
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);


            //~ int index=TBEditor.GetFactionAbilityIndex(item.facAbilityID);
            //~ index=EditorGUI.Popup(new Rect(startX+spaceX, startY, width, height), index, fAbilityLabel);
            //~ if(index>0) item.facAbilityID=fAbilityDB.abilityList[index-1].prefabID;
            //~ else item.facAbilityID=-1;

            startY -= spaceY;
            int count = item.facAbilityIDList.Count + 1;

            for (int i = 0; i < count; i++)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX - 10, startY + spaceY, width, height), "-");

                int index = (i < item.facAbilityIDList.Count) ? TBEditor.GetFactionAbilityIndex(item.facAbilityIDList[i]) : 0;
                index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width, height), index, fAbilityLabel);
                if (index > 0)
                {
                    int abID = fAbilityDB.abilityList[index - 1].prefabID;
                    if (!item.facAbilityIDList.Contains(abID))
                    {
                        if (i < item.facAbilityIDList.Count)
                        {
                            item.facAbilityIDList[i] = abID;
                        }
                        else
                        {
                            item.facAbilityIDList.Add(abID);
                        }
                    }
                }
                else if (i < item.facAbilityIDList.Count)
                {
                    item.facAbilityIDList.RemoveAt(i); i -= 1;
                }

                if (i < item.facAbilityIDList.Count && GUI.Button(new Rect(startX + width + spaceX + 5, startY, 20, height - 1), "-"))
                {
                    item.facAbilityIDList.RemoveAt(i); i -= 1;
                }
            }



            startY += spaceY;

            startY = DrawEffect(startX, startY + spaceY, item.effect);

            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Collectible description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 100), item.desp, style);

            return(new Vector2(maxX, startY + 120));
        }
Пример #27
0
 protected static void LoadCollectible()
 {
     TBEditor.LoadCollectible();
 }
Пример #28
0
 protected static void UpdateLabel_Collectible()
 {
     TBEditor.UpdateLabel_Collectible();
 }
Пример #29
0
 protected void UpdateObjectHierarchyList(GameObject obj)
 {
     TBEditor.GetObjectHierarchyList(obj, this.SetObjListCallback);
 }