Example #1
0
    public static MapMeshChunk CreateEmpty(Transform parent)
    {
        MapMeshChunk result = CreateEmpty();

        result.transform.SetParent(parent, false);
        return(result);
    }
Example #2
0
    private MapMeshChunk[] GetHexMeshChunks(
        HexGrid <Hex> grid,
        float hexOuterRadius
        )
    {
        MapMeshChunk[] result = new MapMeshChunk[
            HexMeshChunkRows * HexMeshChunkColumns
                                ];

        for (int i = 0; i < result.Length; i++)
        {
            result[i] = MapMeshChunk.CreateEmpty(this.transform);
        }

        for (int hexRow = 0; hexRow < HexOffsetRows; hexRow++)
        {
            for (int hexColumn = 0; hexColumn < HexOffsetColumns; hexColumn++)
            {
                Hex hex = grid.GetElement(hexColumn, hexRow);

                int hexChunkColumn =
                    hexColumn / HexMeshConstants.CHUNK_SIZE_Z;

                int hexChunkRow =
                    hexRow / HexMeshConstants.CHUNK_SIZE_X;

                int hexLocalColumn =
                    hexColumn % HexMeshConstants.CHUNK_SIZE_X;

                int hexLocalRow =
                    hexRow % HexMeshConstants.CHUNK_SIZE_Z;

                result[
                    (hexChunkRow * HexMeshChunkColumns) +
                    hexChunkColumn
                ].AddHex(
                    (hexLocalRow * HexMeshConstants.CHUNK_SIZE_Z) +
                    hexLocalColumn,
                    hex
                    );
            }
        }

        return(result);
    }
Example #3
0
    public static MapMeshChunk CreateEmpty()
    {
        GameObject   resultObj  = new GameObject("Map Mesh Chunk");
        MapMeshChunk resultMono = resultObj.AddComponent <MapMeshChunk>();

        resultMono.Hexes = new Hex[
            HexMeshConstants.CHUNK_SIZE_X *
            HexMeshConstants.CHUNK_SIZE_Z
                           ];

        GameObject resultCanvasObj = new GameObject(
            "World Space UI Canvas"
            );

        Canvas resultCanvasMono =
            resultCanvasObj.AddComponent <Canvas>();

        CanvasScaler resultCanvasScalerMono =
            resultCanvasObj.AddComponent <CanvasScaler>();

        resultCanvasObj.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono.WorldSpaceUICanvas = resultCanvasMono;
        resultCanvasScalerMono.dynamicPixelsPerUnit = 10f;

        resultCanvasObj.transform.rotation = Quaternion.Euler(
            90,
            0,
            0
            );

        resultCanvasObj.transform.position += Vector3.up * .005f;

        resultMono._terrainLayer = TerrainChunkLayer.CreateEmpty(
            Resources.Load <Material>("Terrain"),
            true,
            true,
            false,
            false
            );

        resultMono._terrainLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._riversLayer = RiversChunkLayer.CreateEmpty(
            Resources.Load <Material>("River"),
            false,
            true,
            true,
            false
            );

        resultMono._riversLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._roadsLayer = RoadsChunkLayer.CreateEmpty(
            Resources.Load <Material>("Road"),
            false,
            true,
            true,
            false
            );

        resultMono._roadsLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._openWaterLayer =
            OpenWaterChunkLayer.CreateEmpty(
                Resources.Load <Material>("Water"),
                false,
                true,
                false,
                false
                );

        resultMono._openWaterLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._waterShoreLayer =
            WaterShoreChunkLayer.CreateEmpty(
                Resources.Load <Material>("WaterShore"),
                false,
                true,
                true,
                false
                );

        resultMono._waterShoreLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._estuariesLayer = EstuariesChunkLayer.CreateEmpty(
            Resources.Load <Material>("Estuary"),
            false,
            true,
            true,
            true
            );

        resultMono._estuariesLayer.transform.SetParent(
            resultObj.transform,
            false
            );

        MapMeshChunkLayer walls = MapMeshChunkLayer.CreateEmpty(
            Resources.Load <Material>("Urban"),
            false,
            false,
            false,
            false
            );

        walls.name = "Walls Layer";
        walls.transform.SetParent(resultObj.transform, false);

        resultMono._features = FeatureContainer.GetFeatureContainer(
            walls
            );

        resultMono._features.transform.SetParent(
            resultObj.transform,
            false
            );

        resultMono._features.name = "Features Layer";

        return(resultMono);
    }