Esempio n. 1
0
        public float XZPositionToHeight(float x, float z, bool scaleByMapHeight = false)
        {
            Vector2 mapPoint = new Vector2(x, z) / tileSize * mapScale;

            return(HexUtils.GetHeightOnNoiseMap(noiseMap, mapPoint) *
                   (scaleByMapHeight ? mapHeight : 1));
        }
        public int GetElevationAt(int column, int row)
        {
            int elevation;

            if (elevationTable.TryGet(column, row, out elevation))
            {
                return(elevation);
            }
            var   point = HexUtils.PositionFromCoordinates(column, row, 1f);
            float noise = HexUtils.GetHeightOnNoiseMap(Metrics.elevationNoiseMap,
                                                       point.JustXZ() * Metrics.elevationNoiseMapResolution);

            elevation = Mathf.FloorToInt(noise * Metrics.maxElevation);
            //elevation = UnityEngine.Random.Range(0, Metrics.maxElevation );
            elevationTable.Set(column, row, elevation);
            return(elevation);
        }