示例#1
0
        public static Texture getBumpMap(Tile[,] tiles)
        {
            int width   = tiles.GetLength(0);
            int height  = tiles.GetLength(1);
            var texture = new Texture(width, height);
            var pixels  = new Color4[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    switch (tiles[x, y].myHeightType)
                    {
                    case HeightType.DeepWater:
                        pixels[x, y] = new Color4(0, 0, 0, 1);
                        break;

                    case HeightType.ShallowWater:
                        pixels[x, y] = new Color4(0, 0, 0, 1);
                        break;

                    case HeightType.Sand:
                        pixels[x, y] = new Color4(0.3f, 0.3f, 0.3f, 1);
                        break;

                    case HeightType.Grass:
                        pixels[x, y] = new Color4(0.45f, 0.45f, 0.45f, 1);
                        break;

                    case HeightType.Forest:
                        pixels[x, y] = new Color4(0.6f, 0.6f, 0.6f, 1);
                        break;

                    case HeightType.Rock:
                        pixels[x, y] = new Color4(0.75f, 0.75f, 0.75f, 1);
                        break;

                    case HeightType.Snow:
                        pixels[x, y] = new Color4(1, 1, 1, 1);
                        break;

                    case HeightType.River:
                        pixels[x, y] = new Color4(0, 0, 0, 1);
                        break;
                    }

                    if (!tiles[x, y].myIsLand)
                    {
                        pixels[x, y] = ColorExt.mix(Color4.White, Color4.Black, tiles[x, y].myHeightValue * 2);
                    }
                }
            }

            texture.setPixels(ref pixels);
            return(texture);
        }
示例#2
0
        public static Texture getHeatMapTexture(Tile[,] tiles)
        {
            int width   = tiles.GetLength(0);
            int height  = tiles.GetLength(1);
            var texture = new Texture(width, height);
            var pixels  = new Color4[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    switch (tiles[x, y].myHeatType)
                    {
                    case HeatType.Coldest:
                        pixels[x, y] = Coldest;
                        break;

                    case HeatType.Colder:
                        pixels[x, y] = Colder;
                        break;

                    case HeatType.Cold:
                        pixels[x, y] = Cold;
                        break;

                    case HeatType.Warm:
                        pixels[x, y] = Warm;
                        break;

                    case HeatType.Warmer:
                        pixels[x, y] = Warmer;
                        break;

                    case HeatType.Warmest:
                        pixels[x, y] = Warmest;
                        break;
                    }

                    //darken the Color4 if a edge tile
                    if ((int)tiles[x, y].myHeightType > 2 && tiles[x, y].myBitmask != 15)
                    {
                        pixels[x, y] = ColorExt.mix(pixels[x, y], Color4.Black, 0.4f);
                    }
                }
            }

            texture.setPixels(ref pixels);
            return(texture);
        }
示例#3
0
        public static Texture getSimpleHeatMapTexture(Tile[,] tiles)
        {
            int width   = tiles.GetLength(0);
            int height  = tiles.GetLength(1);
            var texture = new Texture(width, height);
            var pixels  = new Color4[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    pixels[x, y] = ColorExt.mix(Color4.Blue, Color4.Red, tiles[x, y].myHeatValue);

                    //darken the color if a edge tile
                    if (tiles[x, y].myBitmask != 15)
                    {
                        pixels[x, y] = ColorExt.mix(pixels[x, y], Color4.Black, 0.4f);
                    }
                }
            }

            texture.setPixels(ref pixels);
            return(texture);
        }
示例#4
0
        public static Texture getBiomeMapTexture(Tile[,] tiles, float coldest, float colder, float cold)
        {
            int width   = tiles.GetLength(0);
            int height  = tiles.GetLength(1);
            var texture = new Texture(width, height);
            var pixels  = new Color4[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    BiomeType value = tiles[x, y].myBiomeType;

                    switch (value)
                    {
                    case BiomeType.Ice:
                        pixels[x, y] = Ice;
                        break;

                    case BiomeType.Tundra:
                        pixels[x, y] = Tundra;
                        break;

                    case BiomeType.Desert:
                        pixels[x, y] = Desert;
                        break;

                    case BiomeType.Grassland:
                        pixels[x, y] = Grassland;
                        break;

                    case BiomeType.Savanna:
                        pixels[x, y] = Savanna;
                        break;

                    case BiomeType.TemperateSeasonalForest:
                        pixels[x, y] = TemperateSeasonalForest;
                        break;

                    case BiomeType.TropicalSeasonalForest:
                        pixels[x, y] = TropicalSeasonalForest;
                        break;

                    case BiomeType.Taiga:
                        pixels[x, y] = Taiga;
                        break;

                    case BiomeType.TemperateRainforest:
                        pixels[x, y] = TemperateRainForest;
                        break;

                    case BiomeType.TropicalRainforest:
                        pixels[x, y] = TropicalRainForest;
                        break;
                    }

                    // Water tiles
                    if (tiles[x, y].myHeightType == HeightType.DeepWater)
                    {
                        pixels[x, y] = DeepColor;
                    }
                    else if (tiles[x, y].myHeightType == HeightType.ShallowWater)
                    {
                        pixels[x, y] = ShallowColor;
                    }

                    // draw rivers
                    if (tiles[x, y].myHeightType == HeightType.River)
                    {
                        float heatValue = tiles[x, y].myHeatValue;

                        if (tiles[x, y].myHeatType == HeatType.Coldest)
                        {
                            pixels[x, y] = ColorExt.mix(IceWater, ColdWater, (heatValue) / (coldest));
                        }
                        else if (tiles[x, y].myHeatType == HeatType.Colder)
                        {
                            pixels[x, y] = ColorExt.mix(ColdWater, RiverWater, (heatValue - coldest) / (colder - coldest));
                        }
                        else if (tiles[x, y].myHeatType == HeatType.Cold)
                        {
                            pixels[x, y] = ColorExt.mix(RiverWater, ShallowColor, (heatValue - colder) / (cold - colder));
                        }
                        else
                        {
                            pixels[x, y] = ShallowColor;
                        }
                    }


                    // add a outline
                    if (tiles[x, y].myHeightType >= HeightType.Shore && tiles[x, y].myHeightType != HeightType.River)
                    {
                        if (tiles[x, y].myBiomeBitmask != 15)
                        {
                            pixels[x, y] = ColorExt.mix(pixels[x, y], Color4.Black, 0.35f);
                        }
                    }
                }
            }

            texture.setPixels(ref pixels);
            return(texture);
        }
示例#5
0
        public static Texture getHeightMapTexture(Tile[,] tiles)
        {
            int width   = tiles.GetLength(0);
            int height  = tiles.GetLength(1);
            var texture = new Texture(width, height);
            var pixels  = new Color4[width, height];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    switch (tiles[x, y].myHeightType)
                    {
//                case HeightType.DeepWater:
//                   pixels[x, y] = new Color4(0f, 0f, 0f, 1f);
//                   break;
//                case HeightType.ShallowWater:
//                   pixels[x, y]= new Color4(0f, 0f, 0f, 1f);
//                   break;
//                case HeightType.Shore:
//                   pixels[x, y] = new Color4(0.15f, 0.15f, 0.15f, 1f);
//                   break;
//                case HeightType.Sand:
//                   pixels[x, y]= new Color4(0.3f, 0.3f, 0.3f, 1f);
//                   break;
//                case HeightType.Grass:
//                   pixels[x, y]= new Color4(0.45f, 0.45f, 0.45f, 1f);
//                   break;
//                case HeightType.Forest:
//                   pixels[x, y]= new Color4(0.6f, 0.6f, 0.6f, 1f);
//                   break;
//                case HeightType.Rock:
//                   pixels[x, y]= new Color4(0.75f, 0.75f, 0.75f, 1f);
//                   break;
//                case HeightType.Snow:
//                   pixels[x, y]= new Color4(1f, 1f, 1f, 1f);
//                   break;
//                case HeightType.River:
//                   pixels[x, y] = new Color4(0f, 0f, 0f, 1f);
//                   break;

//                case HeightType.DeepWater:
//                case HeightType.ShallowWater:
//                case HeightType.River:
//                   pixels[x, y] = Color4.Black;
//                   break;
                    default:
                        pixels[x, y] = ColorExt.mix(Color4.Black, Color4.White, tiles[x, y].myHeightValue);
                        break;
                    }

                    //darken the color if a edge tile
                    if (tiles[x, y].myBitmask != 15)
                    {
                        pixels[x, y] = ColorExt.mix(pixels[x, y], Color4.Black, 0.4f);
                    }
                }
            }

            texture.setPixels(ref pixels);

            return(texture);
        }