private void fillTiles(TileRectangle tiles) { var i = 0; foreach (var tile in this.game.Level.TilesIn(tiles)) { var node = this.nodes[i++]; node.Tile = tile; tile.Value.ProjectileColliders.AddLast(node.Node); } }
public IEnumerable <Tile <TileInfo> > TilesIn(TileRectangle rectangle) { var x0 = rectangle.X0; var y0 = rectangle.Y0; var x1 = rectangle.X1; var y1 = rectangle.Y1; for (var y = y0; y <= y1; y++) { for (var x = x0; x <= x1; x++) { yield return(new Tile <TileInfo>(this.tilemap, x, y)); } } }
public void Update() { var p = this.collider.Position; var r = this.collider.Radius; var d = new Difference2(r, r); var tiles = this.game.Level.RectangleIntersecting(p - d, d * 2); if (tiles == this.currentTiles) { return; } this.clearTuples(); this.tileCount = tiles.Tiles; this.ensureTuples(); this.fillTiles(tiles); this.currentTiles = tiles; }