public Window(WaterTextures water, TextureHolder ground, TextureHolder city) { this.water = water; this.ground = ground; this.city = city; strategies.Add(StrategyForCity); strategies.Add(StrategyForGround); strategies.Add(CoastWithLandToTheNorth); strategies.Add(CoastWithLandToTheSouth); strategies.Add(CoastWithLandToTheWest); strategies.Add(CoastWithLandToTheEast); strategies.Add(CoastWithLandToTheNorthEast); strategies.Add(CoastWithLandToTheNorthWest); strategies.Add(CoastWithLandToTheSouthEast); strategies.Add(CoastWithLandToTheSouthWest); strategies.Add(NullStrategy); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.White); spriteBatch.Begin(); // get screen center var offsetx = graphics.GraphicsDevice.Viewport.Width / 2; var offsety = graphics.GraphicsDevice.Viewport.Height / 2; // display sample island { var waterTextures = new WaterTextures(terrainSprite); var spriteSize = new Rectangle(1, 1 + 1 + 32, 32, 32); var window = new Window( waterTextures, new TextureHolder(terrainSprite, new Rectangle(0 * 32, 0, 32, 32)), new TextureHolder(terrainSprite, new Rectangle(7 * 32, 9 * 32, 32, 32))); window.AddIsland(island); window.AddCity(new CityEntity(20, 20)); var points = window .GetWindow(0, 0, 100, 100); var displayHeigh = GraphicsDevice.Viewport.Height; foreach (var it in points) { var position = new Vector2(it.GeoPoint.X * 32, displayHeigh - it.GeoPoint.Y * 32); spriteBatch.Draw(position, it.Texture); } } // drawing cursor Start var selectionSprite = CreateSelectorTexture(GraphicsDevice); var selectionPoint = pointerStateStream.Value.Position; var cameraSelectionPoint = camera.View(new Point(selectionPoint.X * Config.SpriteSize, selectionPoint.Y * Config.SpriteSize)); var selectionPosition = new Vector2(cameraSelectionPoint.X - 1, cameraSelectionPoint.Y - 1); spriteBatch.Draw(selectionSprite, selectionPosition); spriteBatch.End(); base.Draw(gameTime); }
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, null); 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); }