private void UpdateTiles(int x, int y) { for (int i = Mathf.Max(0, x - 30); i < Mathf.Min(mapWidth * 10, x + 30); i++) { for (int j = Mathf.Max(0, y - 30); j < Mathf.Min(mapHeight * 10, y + 30); j++) { if (i < x - 20 || i > x + 20 || j < y - 20 || j > y + 20) { if (tileMapTiles[i, j] != null) { tilePool.ReplaceTile(tileMap[i, j], tileMapTiles[i, j]); tileMapTiles[i, j] = null; } } else { if (tileMapTiles[i, j] == null) { tileMapTiles[i, j] = tilePool.GetTile(tileMap[i, j]); tileMapTiles[i, j].transform.position = new Vector3(i - mapWidth * 5, -j, 1); } } if (i < x - 10 || i > x + 10 || j < y - 10 || j > y + 10) { if (enemyMapCreatures[i, j] != null) { creaturePool.ReplaceCreature(0, enemyMapCreatures[i, j]); enemyMapCreatures[i, j] = null; } } else { if (enemyMap[i, j] >= 0 && enemyMapCreatures[i, j] == null) { enemyMapCreatures[i, j] = creaturePool.GetCreature(enemyMap[i, j]); enemyMapCreatures[i, j].transform.position = new Vector3(i - mapWidth * 5, -j, 1); enemyMapCreatures[i, j].MultiplyHealth(Mathf.Max(1, (int)((j - 3) / 10))); } } } } }