/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public void Initialize() { //RenderTarget = RenderTargetUtils.CreateRenderTarget(game.GraphicsDevice, 1, SurfaceFormat.Color, 800, 600); /** Load the terrain effect **/ effect = GameFacade.Game.Content.Load<Effect>("Effects/TerrainSplat"); /** Setup **/ //SetCity("0020"); SetCity("0013"); //transX = -(City.Width * Geom.CellWidth / 2); //transY = +(City.Height / 2 * Geom.CellHeight / 2); /** * Setup terrain texture */ var device = GameFacade.GraphicsDevice; var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/"); var grass = Texture2D.FromFile(device, Path.Combine(textureBase, "gr.tga")); var rock = Texture2D.FromFile(device, Path.Combine(textureBase, "rk.tga")); var snow = Texture2D.FromFile(device, Path.Combine(textureBase, "sn.tga")); var sand = Texture2D.FromFile(device, Path.Combine(textureBase, "sd.tga")); var water = Texture2D.FromFile(device, Path.Combine(textureBase, "wt.tga")); TextureTerrain = TextureUtils.MergeHorizontal(device, grass, snow, sand, rock, water); TextureGrass = grass; TextureSand = sand; TextureSnow = snow; TextureRock = rock; TextureWater = water; effect.Parameters["xTextureBlend"].SetValue(TextureBlend); effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain); /** Dont need these anymore **/ //grass.Dispose(); //rock.Dispose(); //snow.Dispose(); //sand.Dispose(); //water.Dispose(); /** * Setup alpha map texture */ /** Construct a single texture out of the alpha maps **/ Texture2D[] alphaMaps = new Texture2D[15]; for (var t = 0; t < 15; t++) { var index = t.ToString(); if (t < 10) { index = "0" + index; } alphaMaps[t] = Texture2D.FromFile(device, Path.Combine(textureBase, "transb" + index + "b.tga")); } /** We add an extra 64px so that the last slot in the sheet is a solid color aka no blending **/ TextureBlend = TextureUtils.MergeHorizontal(device, 64, alphaMaps); alphaMaps.ToList().ForEach(x => x.Dispose()); effect.Parameters["xTextureBlend"].SetValue(TextureBlend); effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain); //TextureBlend.Save(@"C:\Users\Admin\Desktop\blendBB.jpg", ImageFileFormat.Jpg); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public void Initialize(string CityName) { /** Load the terrain effect **/ if (zoomedIn) { effect = GameFacade.Game.Content.Load<Effect>("Effects/TerrainSplat"); } else { effect = GameFacade.Game.Content.Load<Effect>("Effects/TerrainSplat2"); } //Queue f*****g gigantic switch :) switch (CityName) { case "Blazing Falls": SetCity("0001"); break; case "Alphaville": SetCity("0002"); break; case "Test Center": SetCity("0003"); break; case "Interhogan": SetCity("0004"); break; case "Ocean's Edge": SetCity("0005"); break; case "East Jerome": SetCity("0006"); break; case "Fancy Fields": SetCity("0007"); break; case "Betaville": SetCity("0008"); break; case "Charvatia": SetCity("0009"); break; case "Dragon's Cove": SetCity("0010"); break; case "Rancho Rizzo": SetCity("0011"); break; case "Zavadaville": SetCity("0012"); break; case "Queen Margaret's": SetCity("0013"); break; case "Shannopolis": SetCity("0014"); break; case "Grantley Grove": SetCity("0015"); break; case "Calvin's Creek": SetCity("0016"); break; case "The Billabong": SetCity("0017"); break; case "Mount Fuji": SetCity("0018"); break; case "Dan's Grove": SetCity("0019"); break; case "Jolly Pines": SetCity("0020"); break; case "Yatesport": SetCity("0021"); break; case "Landry Lakes": SetCity("0022"); break; case "Nichol's Notch": SetCity("0023"); break; case "King Canyons": SetCity("0024"); break; case "Virginia Islands": SetCity("0025"); break; case "Pixie Point": SetCity("0026"); break; case "West Darrington": SetCity("0027"); break; case "Upper Shankelston": SetCity("0028"); break; case "Albertstown": SetCity("0029"); break; case "Terra Tablante": SetCity("0030"); break; default: SetCity("0001"); break; } /** * Setup terrain texture */ var device = GameFacade.GraphicsDevice; var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/"); var grass = Texture2D.FromFile(device, Path.Combine(textureBase, "gr.tga")); var rock = Texture2D.FromFile(device, Path.Combine(textureBase, "rk.tga")); var snow = Texture2D.FromFile(device, Path.Combine(textureBase, "sn.tga")); var sand = Texture2D.FromFile(device, Path.Combine(textureBase, "sd.tga")); var water = Texture2D.FromFile(device, Path.Combine(textureBase, "wt.tga")); TextureTerrain = TextureUtils.MergeHorizontal(device, grass, snow, sand, rock, water); TextureGrass = grass; TextureSand = sand; TextureSnow = snow; TextureRock = rock; TextureWater = water; /** * Setup alpha map texture */ /** Construct a single texture out of the alpha maps **/ Texture2D[] alphaMaps = new Texture2D[15]; for (var t = 0; t < 15; t++) { var index = t.ToString(); if (t < 10) { index = "0" + index; } alphaMaps[t] = Texture2D.FromFile(device, Path.Combine(textureBase, "transb" + index + "b.tga")); } /** We add an extra 64px so that the last slot in the sheet is a solid color aka no blending **/ TextureBlend = TextureUtils.MergeHorizontal(device, 64, alphaMaps); alphaMaps.ToList().ForEach(x => x.Dispose()); }