Beispiel #1
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);
        }
Beispiel #2
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));
        }