public void AddIsland(IslandEntity island) { foreach (var item in island.GeneratePoints()) { var point = new GeoPoint(item.X, item.Y); points.Add(point, LocationType.Ground); } }
public void UseProperTextureForIsland() { var ground = new TextureHolder(); var window = new Window(new WaterTextures(), ground, null); var island = new IslandEntity { Corners = new[] { new GeoPoint { X = 1, Y = 1 } } }; window.AddIsland(island); var view = window.GetWindow(1, 1, 1, 1); view.First().Texture.Should().Be(ground); }
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); }
public void GeneratePoints() { var island = new IslandEntity { Corners = new[] { new GeoPoint(0, 0), new GeoPoint(2, 0), new GeoPoint(2, 2), new GeoPoint(0, 2) } }; var actual = island.GeneratePoints(); var expected = new List<GeoPoint>(); for (int x = 0; x < 3; x++) for (int y = 0; y < 3; y++) expected.Add(new GeoPoint { X = x, Y = y }); CollectionAssert.AreEquivalent(expected, actual); }
public void GenerateIslandCase1() { var island = new IslandEntity { Corners = new[] { new GeoPoint(1, 1), new GeoPoint(3, 1), new GeoPoint(3, 3), new GeoPoint(1, 3) } }; var points = island.GeneratePoints(); Assert.True(points.Contains(new GeoPoint(1, 1))); Assert.True(points.Contains(new GeoPoint(2, 1))); Assert.True(points.Contains(new GeoPoint(3, 1))); Assert.True(points.Contains(new GeoPoint(1, 2))); Assert.True(points.Contains(new GeoPoint(2, 2))); Assert.True(points.Contains(new GeoPoint(3, 2))); Assert.True(points.Contains(new GeoPoint(1, 3))); Assert.True(points.Contains(new GeoPoint(2, 3))); Assert.True(points.Contains(new GeoPoint(3, 3))); }
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); }
public void GeneratePoints() { var island = new IslandEntity { Corners = new[] { new GeoPoint(0, 0), new GeoPoint(2, 0), new GeoPoint(2, 2), new GeoPoint(0, 2) } }; var actual = island.GeneratePoints(); var expected = new List <GeoPoint>(); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { expected.Add(new GeoPoint { X = x, Y = y }); } } CollectionAssert.AreEquivalent(expected, actual); }
/// <summary> /// Converts list of island borders to the list of all island tiles. /// </summary> /// <param name="entries"></param> /// <returns></returns> public static GeoPoint[] GeneratePoints(this IslandEntity entries) { return(FillPolygon(entries.Corners) .Select(o => new GeoPoint(o.X, o.Y)) .ToArray()); }