Esempio n. 1
0
        Vector2 DrawAbilityConfigurator(float startX, float startY, Ability item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);

            TDE.Label(startX, startY += spaceY, width, height, "Hide In Inspector:", "");
            item.hideInInspector      = EditorGUI.Toggle(new Rect(startX + width, startY, width, height), item.hideInInspector);

            startY = DrawGeneralSetting(startX, startY + 10, item);

            startY += spaceY * 2;


            string text = "Ability Stats ";          //+(!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (foldStats)
            {
                int effType = (int)item.effectType;
                TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "Indicate what does the ability do");
                contL           = TDE.SetupContL(effTypeLabel, effTypeTooltip);
                effType         = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), effType, contL);
                item.effectType = (Ability._EffectType)effType;

                startY += 10;

                if (item.effectType != Ability._EffectType.Default || item.effectDelay <= 0)
                {
                    GUI.color = Color.grey;
                }

                TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Delay:", "Delay in second before the effects apply to target\n\nFor any visual effect to play out");
                item.effectDelay = EditorGUI.FloatField(new Rect(startX + spaceX + 12, startY, widthS, height), item.effectDelay);

                GUI.color = item.effectType == Ability._EffectType.Default ? Color.white : Color.grey;

                startY    = DrawStats(startX, startY, item.stats, _EType.Ability);
                GUI.color = Color.white;
            }
            else
            {
                startY += spaceY;
            }


            startY = DrawVisualSetting(startX, startY, item) + spaceY;


            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

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

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 2
0
        public float DrawEffectTypeSetting(float startX, float startY, Perk item)
        {
            if (!item.SupportModNMul())
            {
                return(startY);
            }

            int type = (int)item.effType;             contL = TDE.SetupContL(effTypeLabel, effTypeTooltip);

            TDE.Label(startX, startY, width, height, "Effect Type:", "", TDE.headerS);
            type                = EditorGUI.Popup(new Rect(startX + spaceX, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL);
            item.effType        = (Perk._EffType)type;
            item.effect.effType = (Effect._EffType)type;


            if (GUI.Button(new Rect(startX + spaceX + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset"))
            {
                if (item.effType == Perk._EffType.Modifier)
                {
                    item.gain = 0;
                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        item.gainList[i] = 0;
                    }

                    if (item.type == _PerkType.ModifyAbility)
                    {
                        item.costMul = 0;
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        item.effect.duration = 0;
                    }
                }
                if (item.effType == Perk._EffType.Multiplier)
                {
                    item.gain = 1;
                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        item.gainList[i] = 1;
                    }

                    if (item.type == _PerkType.ModifyAbility)
                    {
                        item.costMul = 1;
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        item.effect.duration = 1;
                    }
                }

                item.effect.Reset();
            }


            return(startY + spaceY);
        }
Esempio n. 3
0
        Vector2 DrawEffectConfigurator(float startX, float startY, Effect item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);

            spaceX += 12;

            TDE.Label(startX, startY += spaceY, width, height, "Stackable:", "Check if the effect can stack if apply on a same unit with repeatably");
            item.stackable            = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stackable);

            TDE.Label(startX, startY += spaceY, width, height, "Duration:", "The long the effect will last (in second)");
            item.duration             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.duration);

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Effect Attributes:", "", TDE.headerS);        startX += 12;     spaceX -= 12;

            if (GUI.Button(new Rect(startX + spaceX, startY, widthS * 2, height), "Reset"))
            {
                item.Reset();
            }

            TDE.Label(startX, startY += spaceY, width, height, "Stun Target:", "Check if the effect effect will stun its target");
            item.stun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stun);

            startY += 10;     startX -= 12;     spaceX -= 12;

            int type = (int)item.effType;             contL = TDE.SetupContL(effTypeLabel, effTypeTooltip);

            TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "", TDE.headerS);
            type         = EditorGUI.Popup(new Rect(startX + spaceX + 23, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL);
            item.effType = (Effect._EffType)type;

            if (GUI.Button(new Rect(startX + spaceX + 23 + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset"))
            {
                item.Reset();
            }

            //TDE.Label(startX, startY+=spaceY, width, height, "Multipliers:", "", TDE.headerS);
            startY = DrawStats(startX, startY += spaceY, item.stats, _EType.Effect);

            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, height), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 4
0
        private Vector2 DrawUnitConfigurator(float startX, float startY, UnitTower unit)
        {
            startY = TDE.DrawBasicInfo(startX, startY, unit);

            TDE.Label(startX + 12, startY, width, height, "Hide In Inspector:", "Check to hide the tower in Inspector (It won't be showing up in TowerManager)");
            unit.hideInInspector = EditorGUI.Toggle(new Rect(startX + spaceX + 12, startY, width, height), unit.hideInInspector);

            int type = (int)unit.towerType;

            cont  = new GUIContent("Tower Type:", "Type of the tower. Each type of tower serve a different function");
            contL = TDE.SetupContL(towerTypeLabel, towerTypeTooltip);
            EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont);
            type           = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL);
            unit.towerType = (UnitTower._TowerType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), towerTypeTooltip[(int)unit.towerType], MessageType.Info);
                startY += 45 - height;
            }


            cont = new GUIContent("MaxCount In Scene:", "The maximum number of this tower prefab is allowed in any particular scene.\nSet to >0 to take effect");
            EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont);
            GUI.color         = unit.limitInScene > 0 ? Color.white : Color.grey;
            unit.limitInScene = EditorGUI.IntField(new Rect(startX + spaceX + 12, startY, widthS, height), unit.limitInScene);    GUI.color = Color.white;


            startY = DrawGeneralSetting(startX, startY + 10, unit);

            if (unit.statsList.Count == 0)
            {
                unit.statsList.Add(new Stats());
            }
            startY = DrawTowerStats(startX, startY + spaceY, unit);

            startY = DrawTowerVisualEffect(startX, startY + spaceY, unit) + spaceY;

            startY = DrawUnitAnimation(startX, startY, unit) + spaceY;

            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 5
0
        protected float DrawGeneralSetting(float startX, float startY, UnitTower unit)
        {
            string textF = "General Tower Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }


            startX += 12;

            //TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            //unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret);
            //TDE.Label(startX, startY+=spaceY, width, height, "AOE:", "");
            //unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE);
            //TDE.Label(startX, startY+=spaceY, width, height, "Support:", "");
            //unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport);
            //TDE.Label(startX, startY+=spaceY, width, height, "Resource:", "");
            //unit.isResource=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isResource);
            //TDE.Label(startX, startY+=spaceY, width, height, "Mine:", "");
            //unit.isMine=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isMine);
            ////TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            ////unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner);

            //startY+=10;

            if (unit.IsTurret() || unit.IsAOE() || unit.IsMine())
            {
                int tgtGroup = (int)unit.targetGroup;
                cont  = new GUIContent("Target Group:", "The target group of the tower");
                contL = TDE.SetupContL(targetGroupLabel, targetGroupTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                tgtGroup         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtGroup, contL);
                unit.targetGroup = (UnitTower._TargetGroup)tgtGroup;
            }

            startY = DrawUnitSetting(startX - 12, startY, unit);

            return(startY);
        }
Esempio n. 6
0
        Vector2 DrawPerkConfigurator(float startX, float startY, Perk item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);


            int type = (int)item.type;                contL = TDE.SetupContL(perkTypeLabel, perkTypeTooltip);

            TDE.Label(startX, startY += spaceY + 5, width, height, "Perk Type:", "Specify what the perk do");
            type      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
            item.type = (_PerkType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 2, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), perkTypeTooltip[(int)item.type], MessageType.Info);
                startY += 45 - height;
            }

            startY += 10;


            startY = DrawBasicSetting(startX, startY, item) + 10;


            startY = DrawEffectSetting(startX, startY, item);


            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

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

            return(new Vector2(maxX, startY + 170));
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "SpawnManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Endless Mode:", "Check to enable endless mode");
            instance.endlessMode = EditorGUILayout.Toggle(cont, instance.endlessMode);

            cont = new GUIContent("Generate On Start:", "Check to have the waves regenerated at the start of game. All preset setting will be overwritten.");
            if (instance.endlessMode)
            {
                EditorGUILayout.LabelField("Generate On Start:", "-");
            }
            else
            {
                instance.genWaveOnStart = EditorGUILayout.Toggle(cont, instance.genWaveOnStart);
            }


            int spawnCDType = (int)instance.spawnCDType;

            cont                 = new GUIContent("Spawn CD Type:", "Spawn CD Type used in this level");
            contL                = TDE.SetupContL(spawnCDTypeLabel, spawnCDTypeTooltip);
            spawnCDType          = EditorGUILayout.Popup(cont, spawnCDType, contL);
            instance.spawnCDType = (SpawnManager._SpawnCDType)spawnCDType;

            cont = new GUIContent("Skippable:", "Allow player to skip ahead and spawn the next wave");
            if (instance.spawnCDType == SpawnManager._SpawnCDType.None)
            {
                EditorGUILayout.LabelField("Skippable:", "-");
            }
            else
            {
                instance.skippable = EditorGUILayout.Toggle(cont, instance.skippable);
            }


            cont = new GUIContent("Auto Start:", "Check to start the game on a timer instead of waiting for player initiation");
            instance.autoStart = EditorGUILayout.Toggle(cont, instance.autoStart);

            cont = new GUIContent(" - Start Timer:", "Delay in second before the spawn start automatically");
            if (!instance.autoStart)
            {
                EditorGUILayout.LabelField(" - Start Timer:", "-");
            }
            else
            {
                instance.startTimer = EditorGUILayout.FloatField(cont, instance.startTimer);
            }

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("Editing wave Information using Inspector is not recommended.\nPlease use SpawnEditorWindow instead", MessageType.Info);
            if (GUILayout.Button("Open SpawnEditorWindow"))
            {
                SpawnEditorWindow.Init();
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Esempio n. 8
0
        private float DrawGeneralSetting(float startX, float startY)
        {
            TDE.Label(startX, startY, width, height, "Endless Mode:", "Check to enable endless mode");
            instance.endlessMode = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.endlessMode);

            TDE.Label(startX, startY += spaceY, width, height, "Generate On Start:", "Check to have the waves regenerated at the start of game. All preset setting will be overwritten.");
            if (instance.endlessMode)
            {
                TDE.Label(startX + spaceX, startY, height, height, "-", "");
            }
            else
            {
                instance.genWaveOnStart = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.genWaveOnStart);
            }

            TDE.Label(startX, startY += spaceY, width, height, "Start On Timer:", "Check to start the game on a timer instead of waiting for player initiation");
            instance.autoStart        = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.autoStart);
            if (instance.autoStart)
            {
                instance.startTimer = EditorGUI.FloatField(new Rect(startX + spaceX + height + 5, startY, widthS, height), instance.startTimer);
            }

            int spawnCDType = (int)instance.spawnCDType;

            TDE.Label(startX, startY += spaceY, width, height, "Countdown Type:", "Spawn count down type in this level");
            contL                = TDE.SetupContL(spawnCDTypeLabel, spawnCDTypeTooltip);
            spawnCDType          = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthS * 2 + 5, height), new GUIContent(""), spawnCDType, contL);
            instance.spawnCDType = (SpawnManager._SpawnCDType)spawnCDType;

            cont = new GUIContent(" - Skippable", "Allow player to skip ahead and spawn the next wave");
            if (instance.spawnCDType != SpawnManager._SpawnCDType.None)
            {
                instance.skippable = EditorGUI.ToggleLeft(new Rect(startX + spaceX + widthS * 2 + 10, startY, width, 15), cont, instance.skippable);
            }


            startY += spaceY * .5f;

            if (!instance.endlessMode)
            {
                TDE.Label(startX, startY += spaceY, width, height, "WavesList (" + instance.waveList.Count + "):", "Number of waves in the level");

                if (GUI.Button(new Rect(startX + spaceX, startY, widthS, 15), "-1"))
                {
                    if (instance.waveList.Count > 1)
                    {
                        instance.waveList.RemoveAt(instance.waveList.Count - 1);
                    }
                }
                if (GUI.Button(new Rect(startX + spaceX + widthS + 5, startY, widthS, 15), "+1"))
                {
                    instance.waveList.Add(new Wave());
                }

                if (!instance.genWaveOnStart && !configureGenerator)
                {
                    if (GUI.Button(new Rect(startX + spaceX + widthS * 2.5f, startY, widthS * 2, height), "Generate"))
                    {
                        instance.GenerateWave();
                    }
                }

                TDE.Label(window.position.width - width - 7, startY, width, height, " - Show Override Setting");
                showOverrideSetting = EditorGUI.Toggle(new Rect(window.position.width - width - 20, startY, width, height), showOverrideSetting);
            }
            else
            {
                startY += spaceY;           //TDE.Label(startX+spaceX, startY, width, height), "-");
            }
            return(startY + spaceY);
        }
Esempio n. 9
0
        protected float DrawGeneralSetting(float startX, float startY, Ability item)
        {
            string textF = "General Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of AbilityManager resource required for the ability\nUsed when 'Use RscManager For Cost' is disabled in AbilityManager");
            item.cost = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.cost);

            TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the ability\nUsed when 'Use RscManager For Cost' is enabled in AbilityManager");
            while (item.stats.cost.Count < RscDB.GetCount())
            {
                item.stats.cost.Add(0);
            }
            while (item.stats.cost.Count > RscDB.GetCount())
            {
                item.stats.cost.RemoveAt(item.stats.cost.Count - 1);
            }

            float cachedX = startX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                if (i > 0 && i % 3 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                item.stats.cost[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.stats.cost[i]);
            }
            startX = cachedX;


            TDE.Label(startX, startY += spaceY, width, height, "Use Limit:", "How many time the ability can be used in a single level");
            if (item.useLimit <= 0)
            {
                GUI.color = Color.grey;
            }
            item.useLimit = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.useLimit);
            GUI.color     = Color.white;

            TDE.Label(startX, startY += spaceY, width, height, "Cooldown:", "The ability cooldown in second");
            item.stats.cooldown       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.stats.cooldown);


            int targetType = (int)item.targetType;            contL = TDE.SetupContL(targetTypeLabel, targetTypeTooltip);

            TDE.Label(startX, startY += spaceY + 10, width, height, "Target Type:", "The type of unit affected by the ability");
            targetType      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetType, contL);
            item.targetType = (Ability._TargetType)targetType;


            TDE.Label(startX, startY   += spaceY, width, height, "Require Target:", "Check if the ability require the player to specify a target/position");
            item.requireTargetSelection = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.requireTargetSelection);

            TDE.Label(startX, startY += spaceY, width, height, " - Unit As Target:", "Check if the ability require the player to select a specific unit as the target");
            if (!item.requireTargetSelection)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
            }
            else
            {
                item.requireUnitAsTarget = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.requireUnitAsTarget);
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Select Indicator:", "OPTIONAL - The object used to indicate the target area during the target select phase\nIf left empty, the default indicator in AbilityManager will be used instead");
            if (!item.requireTargetSelection)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
            }
            else
            {
                item.tgtSelectIndicator = (Transform)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.tgtSelectIndicator, typeof(Transform), true);
            }


            return(startY);
        }
Esempio n. 10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;
            Undo.RecordObject(instance, "ShootObject");

            serializedObject.Update();

            EditorGUILayout.Space();

            srlPpt = serializedObject.FindProperty("type");
            //EditorGUI.showMixedValue=srlPpt.hasMultipleDifferentValues;

            //EditorGUI.BeginChangeCheck();

            //cont=new GUIContent("Type:", "Type of the shoot object");
            //contL=TDE.SetupContL(soTypeLabel, soTypeTooltip);
            //int type = EditorGUILayout.Popup(cont, srlPpt.enumValueIndex, contL);

            //if(EditorGUI.EndChangeCheck()) srlPpt.enumValueIndex=type;
            //EditorGUI.showMixedValue=false;

            //EditorGUILayout.Space();

            if (srlPpt.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Editing of type specify attribute is unavailable when selecting multiple shoot object of different type", MessageType.Warning);
            }
            else if (!srlPpt.hasMultipleDifferentValues)
            {
                int type = (int)instance.type;
                cont                  = new GUIContent("Type:", "Type of the shoot object");
                contL                 = TDE.SetupContL(soTypeLabel, soTypeTooltip);
                type                  = EditorGUILayout.Popup(cont, type, contL);
                instance.type         = (ShootObject._Type)type;
                srlPpt.enumValueIndex = type;

                if (type == (int)ShootObject._Type.Projectile)
                {
                    cont           = new GUIContent("Speed:", "The travel speed of the shootObject");
                    instance.speed = EditorGUILayout.FloatField(cont, instance.speed);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("speed"), cont);

                    cont = new GUIContent("Elevation:", "The elevation in the shoot trajectory\nSet to 0 for a straight shot");
                    instance.elevation = EditorGUILayout.FloatField(cont, instance.elevation);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("elevation"), cont);

                    cont = new GUIContent("Fall Off Range:", "The shot trajectory elevation will gradually decrease if get closer than this range\nIt's recommanded to match this value to the range of the tower");
                    instance.falloffRange = EditorGUILayout.FloatField(cont, instance.falloffRange);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("falloffRange"), cont);
                }
                else if (type == (int)ShootObject._Type.Beam)
                {
                    if (serializedObject.isEditingMultipleObjects)
                    {
                        EditorGUILayout.HelpBox("Assignment of LineRenderer component is not supported for multi-instance editing", MessageType.Info);
                    }
                    else
                    {
                        if (instance.lines.Count == 0)
                        {
                            instance.lines.Add(null);
                        }
                        instance.lines[0] = (LineRenderer)EditorGUILayout.ObjectField("LineRenderer", instance.lines[0], typeof(LineRenderer), true);
                    }

                    cont = new GUIContent("Beam Duration:", "The active duration of the beam");
                    instance.beamDuration = EditorGUILayout.FloatField(cont, instance.beamDuration);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("beamDuration"), cont);

                    cont = new GUIContent("Start Width:", "The starting width of the beam");
                    instance.startWidth = EditorGUILayout.FloatField(cont, instance.startWidth);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("startWidth"), cont);
                }
                else if (type == (int)ShootObject._Type.Effect)
                {
                    cont = new GUIContent("Effect Duration:", "How long the effect will last");
                    instance.effectDuration = EditorGUILayout.FloatField(cont, instance.effectDuration);
                    //EditorGUILayout.PropertyField(serializedObject.FindProperty("effectDuration"), cont);
                }
            }

            EditorGUILayout.Space();

            cont = new GUIContent("Effect (Shoot):", "The visual effect to spawn at the shoot-point when the shoot-object is fired");
            DrawVisualObject(instance.effectShoot, cont);

            EditorGUILayout.Space();

            cont = new GUIContent("Effect (Hit):", "The visual effect to spawn at the hit-point when the shoot-object hit its target");
            DrawVisualObject(instance.effectHit, cont);

            EditorGUILayout.Space();

            cont = new GUIContent("Shoot Sound:", "The audio clip to play when the shoot-object fires");
            instance.shootSound = (AudioClip)EditorGUILayout.ObjectField(cont, instance.shootSound, typeof(AudioClip), true);

            cont = new GUIContent("Hit Sound:", "The audio clip to play when the shoot-object hits");
            instance.hitSound = (AudioClip)EditorGUILayout.ObjectField(cont, instance.hitSound, typeof(AudioClip), true);

            EditorGUILayout.Space();


            DefaultInspector();

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Esempio n. 11
0
        protected float DrawMovementSetting(float startX, float startY, UnitCreep unit)
        {
            string text = "Movement Setting ";          //+(!foldMovement ? "(show)" : "(hide)");

            foldMovement = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), foldMovement, text, TDE.foldoutS);
            if (foldMovement)
            {
                startX += 12;

                int type = (int)unit.pathOffsetMode;
                cont  = new GUIContent("Path Offset Mode:", "Gives a slight random offset to prevent creep from following the center of the path exactly\nThe actual deviation magnitude is set on individual path");
                contL = TDE.SetupContL(offsetModeLabel, offsetModeTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
                unit.pathOffsetMode = (UnitCreep._PathOffsetMode)type;

                startY += 7;

                TDE.Label(startX, startY += spaceY, width, height, "Face Traveling Dir.:", "Check to have the creep face the direction their traveling in");
                unit.faceTravelingDir     = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.faceTravelingDir);

                TDE.Label(startX, startY += spaceY, width, height, " - Snap To Dir.:", "Check to have the creep sanp to the traveling direction instantly instead of rotate towards it");
                if (unit.faceTravelingDir)
                {
                    unit.snapToDir = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.snapToDir);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }

                TDE.Label(startX, startY += spaceY, width, height, " - Rotate Speed:", "The speed in which the unit rotate to face the traveling direction");
                if (unit.faceTravelingDir && !unit.snapToDir)
                {
                    unit.rotateSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.rotateSpeed);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }

                if (unit.IsTurret())
                {
                    startY += 7;

                    TDE.Label(startX, startY += spaceY, width, height, "Stop To Attack:", "Check to have the creep stop while attacking");
                    unit.stopToAttack         = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.stopToAttack);

                    TDE.Label(startX, startY += spaceY, width, height, " - Limit Per Stop:", "Number of attack the creep will perform everytime it stops\nOnce the limit is hit the unit will carry on moving");
                    if (unit.stopToAttack)
                    {
                        unit.attackLimitPerStop = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.attackLimitPerStop);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }

                    TDE.Label(startX, startY += spaceY, width, height, " - Cooldown:", "Cooldown between stop\nUnit cannot stop to attack again when it's on cooldown");
                    if (unit.stopToAttack)
                    {
                        unit.stopToAttackCooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.stopToAttackCooldown);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }
                }
            }

            return(startY);
        }
Esempio n. 12
0
        private Vector2 DrawUnitConfigurator(float startX, float startY, UnitCreep unit)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, unit);

            int type = (int)unit.creepType;

            cont  = new GUIContent("Creep Type:", "Type of the creep. Each type of creep serve a different function");
            contL = TDE.SetupContL(creepTypeLabel, creepTypeTooltip);
            EditorGUI.LabelField(new Rect(startX + 12, startY, width, height), cont);
            type           = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL);
            unit.creepType = (UnitCreep._CreepType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), creepTypeTooltip[(int)unit.creepType], MessageType.Info);
                startY += 45 - height;
            }


            startY = DrawGeneralSetting(startX, startY + spaceY + 10, unit);

            startY = DrawMovementSetting(startX, startY + spaceY, unit);


            startY += spaceY * 2;


            _EType cType = _EType.CDefault;

            if (unit.IsTurret())
            {
                cType = _EType.CTurret;
            }
            else if (unit.IsAOE())
            {
                cType = _EType.CAOE;
            }
            else if (unit.IsSupport())
            {
                cType = _EType.CSupport;
            }
            else if (unit.IsSpawner())
            {
                cType = _EType.CSpawner;
            }

            string text = "Unit Stats ";          //+ !foldStats ? "(show)" : "(hide)" ;

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (foldStats)
            {
                startY = DrawStats(startX, startY + spaceY, unit.statsList[0], cType) - spaceY;

                if (unit.IsSpawner())
                {
                    startX += 12;     startY += 10;

                    TDE.Label(startX, startY += spaceY, width, height, "Spawn Prefab:", "Creep prefab to be spawned");
                    int idx = CreepDB.GetPrefabIndex(unit.spawnerPrefab);
                    idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label);
                    unit.spawnerPrefab = CreepDB.GetItem(idx);
                    if (unit.spawnerPrefab == unit)
                    {
                        unit.spawnerPrefab = null;
                    }

                    if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                    {
                        unit.spawnOnDestroyed = null;
                    }

                    TDE.Label(startX, startY += spaceY, width, height, " - Num to Spawn:", "The amount of SpawnOnDestroyed creep to spawn when this unit is destroyed");
                    if (unit.spawnerPrefab != null)
                    {
                        unit.spawnerCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.spawnerCount);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }

                    bool valid = unit.spawnerPrefab != null && unit.spawnerCount > 0;

                    startY = DrawSpawnOverride(startX, startY, unit.spawnerOverride, valid, foldSpawnerOverride, SetFoldSpawnerOverride);

                    startX -= 12;
                }
            }


            startY = DrawCreepVisualEffect(startX, startY + spaceY, unit);

            startY = DrawUnitAnimation(startX, startY + spaceY, unit);

            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);


            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 13
0
        protected float DrawUnitSetting(float startX, float startY, Unit item)
        {
            InitLabel();

            //string text="Unit Setting" + (foldUnit ? "(Hide)" : "(Show)");
            //foldUnit=EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldUnit, "Unit Setting", TDE.foldoutS);
            //if(!foldUnit) return startY;

            startX += 12;

            if (item.IsTurret())
            {
                int tgtMode = (int)item.targetMode;
                cont  = new GUIContent("Targeting Mode:", "How the unit select target from a group of potential hostile");
                contL = TDE.SetupContL(targetModeLabel, targetModeTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                tgtMode         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtMode, contL);
                item.targetMode = (UnitTower._TargetMode)tgtMode;

                TDE.Label(startX, startY += spaceY, width, height, " - Reset On Attack:", "Check to force the unit to look for the most viable target on every attack (more expensive)");
                item.resetTargetOnAttack  = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.resetTargetOnAttack);

                GUI.color = (item.targetingFov <= 0 || item.targetingFov >= 360) ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, "Targeting FOV:", "Unit's active target field-of-view in angle");
                item.targetingFov         = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.targetingFov);     GUI.color = white;
                item.targetingFov         = Mathf.Clamp(item.targetingFov, 0, 360);

                startY += 10;
            }


            int objIdx = GetIndexFromHierarchy(item.targetPoint, objHierarchyList);

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "TargetPoint:", "The transform object which indicate the center point of the unit\nThis would be the point where the shootObject and effect will be aiming at");
            objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
            item.targetPoint = objHierarchyList[objIdx];

            TDE.Label(startX, startY += spaceY, width, height, "Unit Radius:", "A reference value to indicate how 'big' the target is, used to determine when a shootobject hit the unit");
            item.unitRadius           = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.unitRadius);


            if (item.IsTurret())
            {
                startY += 10;

                GUIStyle style = item.shootObject == null ? TDE.conflictS : null;
                TDE.Label(startX, startY += spaceY, width, height, "Shoot Object:", "The shoot-object to fire at each attack. Must be a prefab contain a 'ShootObject' component", style);
                item.shootObject          = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.shootObject, typeof(ShootObject), true);

                cont = new GUIContent("ShootPoint:", "OPTIONAL - The transform which indicate the position where the shootObject will be fired from\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount = item.shootPoint.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), shootPointCount);

                if (shootPointCount != item.shootPoint.Count)
                {
                    while (item.shootPoint.Count < shootPointCount)
                    {
                        item.shootPoint.Add(null);
                    }
                    while (item.shootPoint.Count > shootPointCount)
                    {
                        item.shootPoint.RemoveAt(item.shootPoint.Count - 1);
                    }
                }

                if (shootPointFoldout)
                {
                    for (int i = 0; i < item.shootPoint.Count; i++)
                    {
                        objIdx = GetIndexFromHierarchy(item.shootPoint[i], objHierarchyList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objIdx             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                        item.shootPoint[i] = objHierarchyList[objIdx];
                    }
                }

                TDE.Label(startX, startY += spaceY, width, height, "Shoot Point Spacing:", "The time delay in second between each shoot-point during an attack");
                if (item.shootPoint.Count <= 1)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-", "");
                }
                else
                {
                    item.shootPointSpacing = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shootPointSpacing);
                }

                startY += 10;

                TDE.Label(startX, startY += spaceY, width, height, "Turret Pivot:", "OPTIONAL - The object under unit's hierarchy which is used to aim toward target\nWhen left unassigned, no aiming will be done.");
                objIdx           = GetIndexFromHierarchy(item.turretPivot, objHierarchyList);
                objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                item.turretPivot = objHierarchyList[objIdx];

                TDE.Label(startX, startY += spaceY, width, height, "Barrel Pivot:", "OPTIONAL - The secondary object under unit's hierarchy which is used to aim toward target in x-axis only\nWhen left unassigned, no aiming will be done.");
                if (item.turretPivot == null)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                else
                {
                    objIdx           = GetIndexFromHierarchy(item.barrelPivot, objHierarchyList);
                    objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                    item.barrelPivot = objHierarchyList[objIdx];
                }

                TDE.Label(startX, startY += spaceY, width, height, "Aim In X-Axis:", "Check to have the turret aim in x-axis");
                if (item.turretPivot == null)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                else
                {
                    item.aimInXAxis = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.aimInXAxis);
                }

                TDE.Label(startX, startY += spaceY, width, height, "Snap Aiming:", "Check to have the turret look at target instantly");
                if (item.turretPivot == null)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }
                else
                {
                    item.snapAiming = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.snapAiming);
                }

                TDE.Label(startX, startY += spaceY, width, height, "Aim Speed:", "");
                if (item.turretPivot == null || item.snapAiming)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }
                else
                {
                    item.aimSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.aimSpeed);
                }


                //~ public bool snapAiming=true;
                //~ public float aimSpeed=20;
            }

            return(startY);
        }