public void GetTilesAtLocation() { TileGridLayer layer = new MultiTileGridLayer("tiles", 16, 16, 10, 10); layer.AddTile(2, 3, _tile1); layer.AddTile(6, 7, _tile2); Assert.AreEqual(1, layer.TilesAt(new TileCoord(2, 3)).Count()); Assert.AreEqual(0, layer.TilesAt(new TileCoord(1, 3)).Count()); Assert.AreEqual(0, layer.TilesAt(new TileCoord(3, 3)).Count()); Assert.AreEqual(0, layer.TilesAt(new TileCoord(1, 2)).Count()); Assert.AreEqual(0, layer.TilesAt(new TileCoord(1, 4)).Count()); }
public void AddTile() { TileGridLayer layer = new MultiTileGridLayer("tiles", 16, 16, 10, 10); AttachEvents(layer); layer.TileAdded += (s, e) => { Assert.AreEqual(2, e.X); Assert.AreEqual(4, e.Y); Assert.AreSame(_tile1, e.Tile); Assert.AreEqual(1, layer.Tiles.Count()); Assert.AreEqual(1, layer.TilesAt(new TileCoord(2, 4)).Count()); }; layer.AddTile(2, 4, _tile1); Assert.AreEqual(EventFlags.TileAdded | EventFlags.Modified, _eventsFired); }
public void GetTilesInRegion() { TileGridLayer layer = new MultiTileGridLayer("tiles", 16, 16, 10, 10); layer.AddTile(2, 3, _tile1); layer.AddTile(6, 7, _tile2); Assert.AreEqual(2, layer.TilesAt(new Rectangle(2, 2, 5, 6)).Count()); Assert.AreEqual(1, layer.TilesAt(new Rectangle(3, 2, 5, 6)).Count()); Assert.AreEqual(1, layer.TilesAt(new Rectangle(2, 4, 5, 6)).Count()); Assert.AreEqual(1, layer.TilesAt(new Rectangle(2, 2, 4, 6)).Count()); Assert.AreEqual(1, layer.TilesAt(new Rectangle(2, 2, 5, 5)).Count()); Assert.AreEqual(0, layer.TilesAt(new Rectangle(3, 2, 5, 5)).Count()); }