public void UseProperWaterTexturesForCoastWithLandToTheNorthAndSouthAndWestAndEast() { var waterTextures = new WaterTextures(); // small map for test: // O?O // ?X? // O?O // where O - water, X - island, ? - water where we test textures. var island = new IslandEntity { Corners = new[] { new GeoPoint { X = 1, Y = 1 } } }; var window = new Window(waterTextures, null, new DefaultStrategy(waterTextures.Sea), new CoastWithLandToTheNorthStrategy(waterTextures.CoastWithLandToTheNorth), new CoastWithLandToTheSouthStrategy(waterTextures.CoastWithLandToTheSouth)); window.AddIsland(island); var view = window.GetWindow(0, 0, 3, 3).ToArray(); view[2 * 3 + 1].Texture.Should().Be(waterTextures.CoastWithLandToTheNorth); view[0 * 3 + 1].Texture.Should().Be(waterTextures.CoastWithLandToTheSouth); view[1 * 3 + 0].Texture.Should().Be(waterTextures.CoastWithLandToTheWest); view[1 * 3 + 2].Texture.Should().Be(waterTextures.CoastWithLandToTheEast); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); terrainSprite = Content.Load <Texture2D>(@"Terrain"); var appSprites = Content.Load <Texture2D>("DesertRatsSprites"); selectionSprite = CreateSelectorTexture(GraphicsDevice); var waterTextures = new WaterTextures(terrainSprite); var cityTexture = new TextureHolder(terrainSprite, new Rectangle(7 * Config.SpriteSize, 9 * Config.SpriteSize, Config.SpriteSize, Config.SpriteSize)); var groundTexture = new TextureHolder(terrainSprite, new Rectangle(0 * Config.SpriteSize, 0, Config.SpriteSize, Config.SpriteSize)); var landUnitTexture = new TextureHolder(appSprites, new Rectangle(1 + 0 * Config.SpriteSize, 1 + 0, Config.SpriteSize, Config.SpriteSize)); var spriteSize = new Rectangle(1, 1 + 1 + Config.SpriteSize, Config.SpriteSize, Config.SpriteSize); window = new Window( waterTextures, cityTexture, new DefaultStrategy(waterTextures.Sea), new CoastWithLandToTheNorthStrategy(waterTextures.CoastWithLandToTheNorth), new CoastWithLandToTheSouthStrategy(waterTextures.CoastWithLandToTheSouth), new GroundStrategy(groundTexture), new LandUnitStrategy(landUnitTexture), new CityStrategy(cityTexture) ); window.AddIsland(island); window.AddCity(new CityEntity(20, 20)); window.Include(new LandUnitEntity(21, 20)); }
public Window(WaterTextures water, TextureHolder city, ITileStrategy fallbackStrategy, params ITileStrategy[] strategies) { this.water = water; this.city = city; functionStrategies.Add(CoastWithLandToTheWest); functionStrategies.Add(CoastWithLandToTheEast); functionStrategies.Add(CoastWithLandToTheNorthEast); functionStrategies.Add(CoastWithLandToTheNorthWest); functionStrategies.Add(CoastWithLandToTheSouthEast); functionStrategies.Add(CoastWithLandToTheSouthWest); this.strategies = strategies; this.fallbackStrategy = fallbackStrategy; }