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);
        }
        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));
        }
Exemplo n.º 3
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);
        }