public void CityTakesPrecedenceOnTerrain() { var ground = new TextureHolder(); var city = new TextureHolder(); var window = new Window(null, ground, city); var island = new IslandEntity { Corners = new[] { new GeoPoint { X = 1, Y = 1 } } }; window.AddIsland(island); window.AddCity(new CityEntity(1, 1)); var view = window.GetWindow(1, 1, 1, 1).ToArray(); view.First().Texture.Should().Be(city); }
/// <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 CityTakesPrecedenceOnTerrain() { var ground = new TextureHolder(); var city = new TextureHolder(); var window = new Window(null, city, null, new GroundStrategy(ground), new CityStrategy(city)); var island = new IslandEntity { Corners = new[] { new GeoPoint { X = 1, Y = 1 } } }; window.AddIsland(island); window.AddCity(new CityEntity(1, 1)); var view = window.GetWindow(1, 1, 1, 1).ToArray(); view.First().Texture.Should().Be(city); }
public void LandUnitTakesPrecedenceOnTerrain() { var ground = new TextureHolder(); var city = new TextureHolder(); var landUnit = new TextureHolder(); var window = new Window(null, city, new DefaultStrategy(null), new LandUnitStrategy(landUnit)); var island = new IslandEntity { Corners = new[] { new GeoPoint { X = 1, Y = 1 } } }; window.AddCity(new CityEntity(1, 1)); window.Include(new LandUnitEntity(1, 1)); var view = window.GetWindow(1, 1, 1, 1).ToArray(); view.First().Texture.Should().Be(landUnit); }