Exemplo n.º 1
0
        /// <summary>
        /// Gets the color a particular pixel should be drawn with.
        /// </summary>
        /// <param name="terrainType">The type of terrain.</param>
        /// <param name="localX">The patch local X coordinate.</param>
        /// <param name="localY">The patch local Y coordinate.</param>
        /// <param name="textured">Whether to return color for a textured render.</param>
        /// <returns>See summary.</returns>
        private static Color GetDrawColor(TerrainType terrainType, int localX, int localY, bool textured)
        {
            if (textured)
            {
                Bitmap texture = terrainType.GetImage();
                Xna.Point texCoords = WorldMap.GetPixels(new Vector2(localX / (float)TerrainPatch.PatchSize, localY / (float)TerrainPatch.PatchSize), texture);
                Color sysColor = texture.GetPixel(texCoords.X, texCoords.Y);
                Xna.Graphics.Color drawColor = new Microsoft.Xna.Framework.Graphics.Color(sysColor.R, sysColor.G, sysColor.B, sysColor.A);

                return TextureManipulation.XnaColorToSystemColor(drawColor);
            }
            else
            {
                return TextureManipulation.XnaColorToSystemColor(terrainType.GetWorldMapColor());
            }
        }