public void RotateTest() { BasicMap map = new BasicMap(42, 42, 1, Distance.EUCLIDEAN); int radius = 20; for (int i = 0; i < map.Width; i++) { for (int j = 0; j < map.Height; j++) { BasicTerrain t = new BasicTerrain(Color.White, Color.Black, (i * j + j) % 256, new Coord(i, j), true, true); map.SetTerrain(t); } } Coord origin = new Coord(21, 21); BasicMap rotated = map.Rotate(origin, radius, 45); List <Coord> nullTerrain = new List <Coord>(); Assert.AreNotEqual(map, rotated, "map.Rotate() did not transform the map in any way."); for (int x = 0; x < map.Width; x++) { for (int y = 0; y < map.Height; y++) { Coord here = new Coord(x, y); Coord delta = origin - here; if (radius > Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y)) { if (rotated.GetTerrain <BasicTerrain>(x, y) == null) { nullTerrain.Add(new Coord(x, y)); } else { //Assert.AreNotEqual(Math.Abs(x * y + y) % 256, rotated.GetTerrain<BasicTerrain>(x, y).Glyph); } Assert.AreEqual(Math.Abs(x * y + y) % 256, map.GetTerrain <BasicTerrain>(x, y).Glyph); } else { Assert.IsNull(rotated.GetTerrain <BasicTerrain>(x, y)); Assert.AreEqual(Math.Abs(x * y + y) % 256, map.GetTerrain <BasicTerrain>(x, y).Glyph); } } } }
private void TestMap() { BasicMap map = new BasicMap(42, 42, 1, Distance.EUCLIDEAN); int radius = 20; for (int i = 0; i < map.Width; i++) { for (int j = 0; j < map.Height; j++) { BasicTerrain t = new BasicTerrain(Color.White, Color.Black, (i + j) % 256, new Coord(i, j), true, true); map.SetTerrain(t); } } Coord origin = new Coord(21, 21); Area room = new Area("wiseau's room", new Coord(30, 30), new Coord(30, 10), new Coord(10, 10), new Coord(10, 30)); foreach (Coord c in room.InnerPoints) { map.SetTerrain(_factory.MediumHardwoodFloor(c)); } foreach (Coord c in room.OuterPoints) { map.SetTerrain(_factory.BathroomLinoleum(c)); if (c.X == map.Width / 2 || c.Y == map.Height / 2) { map.SetTerrain(_factory.ShagCarpet(c)); } else { map.SetTerrain(_factory.DarkHardwoodFloor(c)); } } this.ReplaceTiles(map, new Coord(0, 0)); BasicMap rotated = map.Rotate(origin, radius, 45); this.ReplaceTiles(rotated, new Coord(0, 0)); }