コード例 #1
0
        public static void Init(int prefabID = -1)
        {
            // Get existing open window or if none, make a new one:
            window         = (NewUnitEditorWindow)EditorWindow.GetWindow(typeof(NewUnitEditorWindow), false, "Unit Editor");
            window.minSize = new Vector2(420, 300);

            LoadDB();

            //InitLabel();

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

            window.SetupCallback();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
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);
        }