Пример #1
0
        void Start()
        {
            // Gets the script for the "Hexasphere" gameobject
            hexa = Hexasphere.GetInstance("Hexasphere");

            // Load world heightmap and watermask
            hexa.ApplyHeightMap(heightMap, waterMask);

            NewQuake();
        }
Пример #2
0
        void Start()
        {
            // Gets the script for the "Hexasphere" gameobject
            hexa = Hexasphere.GetInstance("Hexasphere");

            // Apply world texture
            hexa.ApplyColors(worldColors);

            // Apply world heights to vertices
            hexa.ApplyHeightMap(heightMap, 0.1f, null, false);
        }
Пример #3
0
        void OnGUI()
        {
            if (avoidGUI)
            {
                return;
            }
            GUI.Label(new Rect(10, 10, 220, 30), divisionsText);
            divisions = (int)GUI.HorizontalSlider(new Rect(10, 30, 220, 30), divisions, 2, 100);
            if (divisions != hexa.numDivisions)
            {
                hexa.numDivisions = divisions;
                divisionsText     = "Divisions (" + hexa.tiles.Length + " tiles)";
            }

            GUI.Label(new Rect(10, 60, 220, 30), "Divisions");
            bool wireframe = GUI.Toggle(new Rect(10, 80, 220, 20), hexa.style == STYLE.Wireframe, "Wireframe");

            if (wireframe)
            {
                hexa.style = STYLE.Wireframe;
            }
            bool shaded = GUI.Toggle(new Rect(10, 100, 220, 20), hexa.style == STYLE.Shaded, "Shaded");

            if (shaded)
            {
                hexa.style = STYLE.Shaded;
            }
            bool shadedWireframe = GUI.Toggle(new Rect(10, 120, 220, 20), hexa.style == STYLE.ShadedWireframe, "Shaded + Wireframe");

            if (shadedWireframe)
            {
                hexa.style = STYLE.ShadedWireframe;
            }

            if (GUI.Button(new Rect(10, 155, 220, 30), "Paint Mode"))
            {
                if (selectMode != DEMO_MODE.Paint)
                {
                    selectMode = DEMO_MODE.Paint;
                }
                else
                {
                    selectMode = DEMO_MODE.Idle;
                }
            }

            bool prevPaintColor = paintInColor;

            paintInColor = GUI.Toggle(new Rect(10, 190, 200, 20), paintInColor, "Color");
            paintInColor = !GUI.Toggle(new Rect(10, 210, 200, 20), !paintInColor, "Texture");
            if (prevPaintColor != paintInColor)
            {
                selectMode = DEMO_MODE.Paint;
            }

            if (GUI.Button(new Rect(10, 240, 100, 30), "Colorize"))
            {
                RandomColors();
            }

            if (GUI.Button(new Rect(120, 240, 110, 30), "Extrusion"))
            {
                if (hexa.extruded)
                {
                    hexa.extruded = false;
                    RandomColors();
                }
                else
                {
                    RandomExtrusion();
                }
            }

            if (GUI.Button(new Rect(10, 280, 220, 30), "Random Obstacles"))
            {
                RandomObstacles();
            }

            if (GUI.Button(new Rect(10, 320, 220, 30), "Clear Tiles"))
            {
                ClearTiles();
            }

            if (GUI.Button(new Rect(10, 360, 100, 30), "Random Path"))
            {
                RandomPath();
            }

            if (GUI.Button(new Rect(120, 360, 110, 30), "Custom Path"))
            {
                selectMode = DEMO_MODE.PathFind_StartTile;
            }

            if (GUI.Button(new Rect(10, 400, 220, 30), "Load Heightmap"))
            {
                if (divisions < 50)
                {
                    Debug.Log("Hint: increase hexasphere divisions for heightmap sample.");
                }
                hexa.extrudeMultiplier = 0.1f;
                hexa.ApplyHeightMap(heightMap, waterMask);
            }

            if (labelStyle == null)
            {
                labelStyle = new GUIStyle(GUI.skin.label);
                labelStyle.normal.textColor = Color.yellow;
            }

            switch (selectMode)
            {
            case DEMO_MODE.Paint:
                GUI.Label(new Rect(10, 440, 220, 30), "Click to paint a tile.", labelStyle);
                break;

            case DEMO_MODE.PathFind_StartTile:
                GUI.Label(new Rect(10, 440, 220, 30), "Click to select starting tile.", labelStyle);
                break;

            case DEMO_MODE.PathFind_EndTile:
                GUI.Label(new Rect(10, 440, 220, 30), "Click to finish path.", labelStyle);
                break;
            }

            if (hexa.lastHighlightedTileIndex >= 0)
            {
                GUI.Label(new Rect(10, 460, 220, 30), "Highlighted Tile # = " + hexa.lastHighlightedTileIndex.ToString(), labelStyle);
            }

            if (Input.GetKeyDown(KeyCode.S))
            {
                hexa.SetTileColor(hexa.lastHighlightedTileIndex, Color.white);
            }

            if (GUI.Button(new Rect(Screen.width - 230, 10, 220, 30), "Spawn Objects"))
            {
                SpawnObjects();
            }

            if (GUI.Button(new Rect(Screen.width - 230, 50, 220, 30), "Spawn Texts"))
            {
                SpawnTexts();
            }

            if (GUI.Button(new Rect(Screen.width - 230, 90, 220, 30), "Parent Sprite"))
            {
                ParentSprite();
            }
        }