Exemplo n.º 1
0
        Vector2 WaveGeneratorSetting(float startX, float startY)
        {
            float cachedX = startX;

            WaveGenerator waveGen = instance.waveGenerator;

            Vector2 v2;

            cont = new GUIContent("Sub Wave Count:");
            v2   = DrawProceduralVariable(startX, startY, waveGen.subWaveCount, cont);          startX += v2.x + 20;
            cont = new GUIContent("Total Creep Count:");
            v2   = DrawProceduralVariable(startX, startY, waveGen.unitCount, cont);             startX += v2.x + 20;            //startY=v2.y;

            startX += 140;
            showProceduralPathList = EditorGUI.Foldout(new Rect(startX, startY, 60, height), showProceduralPathList, "Path List " + (showProceduralPathList ? "" : "(" + waveGen.pathList.Count + ")"));
            if (showProceduralPathList)
            {
                int count = waveGen.pathList.Count;
                count = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height - 2), count);
                while (count < waveGen.pathList.Count)
                {
                    waveGen.pathList.RemoveAt(waveGen.pathList.Count - 1);
                }
                while (count > waveGen.pathList.Count)
                {
                    waveGen.pathList.Add(null);
                }

                for (int i = 0; i < waveGen.pathList.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                    waveGen.pathList[i] = (PathTD)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, 15), waveGen.pathList[i], typeof(PathTD), true);
                }
            }


            if (startY < v2.y)
            {
                startY = v2.y;
            }


            startX  = cachedX;
            startY += spaceY + 15;

            for (int i = 0; i < waveGen.rscSettingList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY - 5, 22, 22), rscList[i].icon);
                cont = new GUIContent("      " + rscList[i].name + ":");
                v2   = DrawProceduralVariable(startX, startY, waveGen.rscSettingList[i], cont);             startX += v2.x + 20;                //startY=v2.y;
            }

            startX = cachedX;
            startY = v2.y + spaceY + 15;

            for (int i = 0; i < waveGen.unitSettingList.Count; i++)
            {
                ProceduralUnitSetting unitSetting = waveGen.unitSettingList[i];
                v2 = DrawProceduralUnitSetting(startX, startY, unitSetting);              startY = v2.y + spaceY + 15;
            }

            contentWidth = 185 * 4 + 25;

            return(new Vector2(185 * 4, startY));
        }
Exemplo n.º 2
0
        private float DrawProceduralSetting(float startX, float startY)
        {
            WaveGenerator waveGen = instance.waveGenerator;

            float cachedY = startY;
            float cachedX = startX;

            cont   = new GUIContent("Sub Wave Count:");
            startY = DrawProceduralVariable(startX, cachedY, waveGen.subWaveCount, cont);
            cont   = new GUIContent("Total Creep Count:");
            startY = DrawProceduralVariable(startX += proceduralVariableWidth + 20, cachedY, waveGen.unitCount, cont);

            float alignY = startY += spaceY;    startY = cachedY;

            startX += proceduralVariableWidth + 40;


            cont = new GUIContent("SimilarSubwave:", "Check to have identical subwave for each wave");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            waveGen.similarSubWave = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), waveGen.similarSubWave);

            startY += 5;

            cont = new GUIContent("Utilise All Path:", "Check to have the generator to use all the path when possible, by assigning different path to each subwave (when there's more path than subwave)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            waveGen.utiliseAllPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), waveGen.utiliseAllPath);

            showProceduralPathList = EditorGUI.Foldout(new Rect(startX, startY += spaceY, widthS, height), showProceduralPathList, "Path List " + (showProceduralPathList ? "" : "(" + waveGen.pathList.Count + ")"));
            if (showProceduralPathList)
            {
                int count = waveGen.pathList.Count;
                count = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), count);
                while (count < waveGen.pathList.Count)
                {
                    waveGen.pathList.RemoveAt(waveGen.pathList.Count - 1);
                }
                while (count > waveGen.pathList.Count)
                {
                    waveGen.pathList.Add(null);
                }

                for (int i = 0; i < waveGen.pathList.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                    waveGen.pathList[i] = (PathTD)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), waveGen.pathList[i], typeof(PathTD), true);
                }
                startY += spaceY;
            }

            startX  = cachedX;
            cachedY = rscDB.rscList.Count > 2 ? Mathf.Max(startY, alignY) : alignY;

            while (waveGen.rscSettingList.Count < rscDB.rscList.Count)
            {
                waveGen.rscSettingList.Add(new ProceduralVariable(0, 0));
            }
            while (waveGen.rscSettingList.Count > rscDB.rscList.Count)
            {
                waveGen.rscSettingList.RemoveAt(waveGen.rscSettingList.Count - 1);
            }

            for (int i = 0; i < rscDB.rscList.Count; i++)
            {
                startY = cachedY + 10;
                TDEditor.DrawSprite(new Rect(startX, startY - 2, 20, 20), rscDB.rscList[i].icon);
                cont    = new GUIContent("      " + rscDB.rscList[i].name + ":");
                startY  = DrawProceduralVariable(startX, startY, waveGen.rscSettingList[i], cont);
                startX += proceduralVariableWidth + 20;
            }

            startX = cachedX; startY += spaceY;

            for (int i = 0; i < waveGen.unitSettingList.Count; i++)
            {
                ProceduralUnitSetting unitSetting = waveGen.unitSettingList[i];
                startY = DrawProceduralUnitSetting(startX, startY + 12, unitSetting);
            }

            return(startY);
        }