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