public void drawTiles(Camera cam, SpriteBatch sb) { int z = 1; for (int y = cam.getCameraY(0); y < cam.getCameraY(screenHeight + 16); y++) { for (int x = cam.getCameraX(-16); x < cam.getCameraX(screenWidth + 16); x++) { if (x < 0 || y < 0 || x >= levelTileWidth || y >= levelTileHeight) { continue; } if (tileLayers[z, y, x] != null && tileLayers[z, y, x].render) { switch (tileLayers[1, y, x].tileType) { case TileType.Dirt: sb.Draw(tileDirt, tileLayers[z, y, x].position - cam.position, new Rectangle(16 * (int)tileLayers[z, y, x].tileOrientation, 16 * (int)tileLayers[z, y, x].damage, 16, 16), Color.White); break; case TileType.Decoration: sb.Draw(tileGrassTop, tileLayers[z, y, x].position - cam.position, new Rectangle(16 * tileLayers[z, y, x].decorationValue, 0, 16, 16), Color.White); break; case TileType.Sand: sb.Draw(sandTex, tileLayers[z, y, x].position - cam.position, new Rectangle(16 * (int)tileLayers[z, y, x].tileOrientation, 0, 16, 16), Color.White); break; case TileType.Metal: sb.Draw(tileMetal, tileLayers[z, y, x].position - cam.position, new Rectangle(16 * (int)tileLayers[z, y, x].tileOrientation, 16 * (int)tileLayers[z, y, x].damage, 16, 16), Color.White); break; } sb.Draw(darkTex, tileLayers[z, y, x].position - cam.position, new Color(0, 0, 0, (1.0f - tileLayers[z, y, x].lightValue))); } } } }
public void drawDroplets(Camera cam, SpriteBatch sb) { for (int y = cam.getCameraY(0); y < cam.getCameraY(screenHeight); y++) { for (int x = cam.getCameraX(0); x < cam.getCameraX(screenWidth); x++) { if (x < levelWidth - 1 && x > 0 && y <= levelHeight - 1 && y > 0) { if (droplets[y, x].topMost && droplets[y, x].waterSand) droplets[y, x].Draw(cam.position, sb, ref waterSandTop); else if (droplets[y, x].topMost && droplets[y, x].waterSand == false) droplets[y, x].Draw(cam.position, sb, ref topMost); else if (droplets[y, x].waterSand && droplets[y, x].topMost == false) droplets[y, x].Draw(cam.position, sb, ref waterSand); else droplets[y, x].Draw(cam.position, sb, ref WaterDropTex); } } } }
public void updateWater(Camera cam, ref Tile[,,] tiles, float totalElapsed) { if (pauseWater) return; for (int y = cam.getCameraY(0); y < cam.getCameraY(screenHeight); y++) { for (int x = cam.getCameraX(0); x < cam.getCameraX(screenWidth); x++) { if (x < levelWidth - 1 && x > 0 && y <= levelHeight - 1 && y > 0) { droplets[y, x].Update(ref tiles, ref droplets, totalElapsed); } } } }