/* * Draws a single tile, incrementally if needed * * @param tile the tile to draw * @param viewRect the view to consider */ protected virtual void drawTile(Tile tile, RectangleF viewRect) { if (tile.texture.key != "") { //Get the size of the tile in increments of Tile.size int tilesWide = (int)((float)tile.imageWidth / Tile.size); int tilesHigh = (int)((float)tile.imageHeight / Tile.size); int fTilesWide = tilesWide; int fTilesHigh = tilesHigh; if (tile.xIndex + fTilesWide > tile.world.width) { fTilesWide -= ((tile.xIndex + fTilesWide) - tile.world.width); } if (tile.yIndex + fTilesHigh > tile.world.height) { fTilesHigh -= ((tile.yIndex + fTilesHigh) - tile.world.height); } //Draw the single tile by increments of Tile.size, in order to draw larger-than-a-tile tiles for (int x = 0; x < fTilesWide; x++) { for (int y = 0; y < fTilesHigh; y++) { //Merge the lighting of the current tile and the incremental tile Tile t = tile.world.tileArray[tile.xIndex + x, tile.yIndex + y]; if (t != tile && t.texture.key != "") { continue; } if (t.color.a < 0.0001f) { continue; } //Final tint Color tint = t.getFinalColor();//glowOutput; //getfinalcolor //Get the specific bounds for this increment RectangleF bounds = new RectangleF((float)x * Tile.size / tile.imageWidth, (float)y * Tile.size / tile.imageHeight, (float)Tile.size / tile.imageWidth, (float)Tile.size / tile.imageHeight); Color tint1 = Color.Avg((t.left == null) ? tint : t.left.getFinalColor(), (t.up == null) ? tint : t.up.getFinalColor()); Color tint2 = Color.Avg((t.right == null) ? tint : t.right.getFinalColor(), (t.up == null) ? tint : t.up.getFinalColor()); Color tint3 = Color.Avg((t.left == null) ? tint : t.left.getFinalColor(), (t.down == null) ? tint : t.down.getFinalColor()); Color tint4 = Color.Avg((t.right == null) ? tint : t.right.getFinalColor(), (t.down == null) ? tint : t.down.getFinalColor()); drawTex(tile.texture, t.x, t.y, Tile.size, Tile.size, Color.Avg(tint, tint1), Color.Avg(tint, tint2), Color.Avg(tint, tint3), Color.Avg(tint, tint4), bounds); } } } }