private void DrawScreen(SpriteBatch sb, int x, int y, int i) { Tile tile = null; if (x >= 0 && x < bounds.Width && y >= 0 && y < bounds.Height) { TilePos = new Vector2(x, y); //Background tiles are drawn first if (i == 0) { tile = world.GetBackgroundTile(TilePos); sb.Draw(ContentHandler.DrawnTexture(tile.block.texture), (tile.Position * Tile.Zoom * 16) - (position * Tile.Zoom * 16), null, Color.White, 0, Zero, Tile.Zoom, SpriteEffects.None, 0); } //Units are drawn second else if (i == 1) { tile = (ModifiableTile)world.GetUnit(TilePos); if (tile != null && tile.block.texture != TextureValue.None) { Texture2D texture = ContentHandler.DrawnTexture(tile.block.texture); ((BasicUnit)tile).UpdatePosition(Game.GraphicsDevice, tile.Position); sb.Draw(ContentHandler.DrawnTexture(tile.block.texture), (tile.Position * Tile.Zoom * 16) - (position * Tile.Zoom * 16), null, Color.White, 0, Zero, Tile.Zoom, SpriteEffects.None, 0); DrawHealth(sb, (ModifiableTile)tile); } } //Draw buildings third else { tile = world.GetTile(TilePos); if (tile != null && tile.block.texture != TextureValue.None) { Texture2D texture = ContentHandler.DrawnTexture(tile.block.texture); tile.UpdatePosition(Game.GraphicsDevice, tile.Position); sb.Draw(ContentHandler.DrawnTexture(tile.block.texture), (tile.Position * Tile.Zoom * 16) - (position * Tile.Zoom * 16), null, Color.White, 0, Zero, Tile.Zoom, SpriteEffects.None, 0); if (!(tile is IHarvestable)) { DrawHealth(sb, (ModifiableTile)tile); } } } } }