| | |
| | | private void UnloadChunk(Vector2Int chunk) |
| | | { |
| | | int startX = chunk.x * CHUNK_SIZE; |
| | | int startY = chunk.y * CHUNK_SIZE; |
| | | int startY = (chunk.y * CHUNK_SIZE)-1; |
| | | |
| | | for (int x = startX; x < startX + CHUNK_SIZE; x++) |
| | | { |
| | |
| | | { |
| | | // Adjust for tilemap offset |
| | | float adjustedX = worldPosition.x - transform.position.x; |
| | | float adjustedY = worldPosition.y - transform.position.y; |
| | | float adjustedY = (worldPosition.y - transform.position.y) + CHUNK_SIZE; |
| | | |
| | | return new Vector2Int( |
| | | Mathf.FloorToInt(adjustedX / CHUNK_SIZE), |
| | |
| | | private IEnumerator GenerateChunk(Vector2Int chunk, List<Vector3Int> destroyedTiles) |
| | | { |
| | | int startX = chunk.x * CHUNK_SIZE; |
| | | int startY = (chunk.y * CHUNK_SIZE); |
| | | int startY = (chunk.y * CHUNK_SIZE)-1; |
| | | |
| | | // Generate ground in chunk |
| | | for (int x = startX; x < startX + CHUNK_SIZE; x++) |
| | |
| | | 0 |
| | | ); |
| | | |
| | | // Draw chunk boundary |
| | | Gizmos.DrawWireCube( |
| | | worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | new Vector3(CHUNK_SIZE, CHUNK_SIZE, 0) |
| | | ); |
| | | |
| | | // Draw chunk coordinates |
| | | UnityEditor.Handles.Label( |
| | | worldPos + new Vector3(CHUNK_SIZE / 2f, -CHUNK_SIZE / 2f, 0), |
| | | $"({chunk.x}, {chunk.y})" |
| | | ); |
| | | } |
| | | } |
| | | } |