public void UpdateWindow(Rectangle newWindow) { if (CurrentTerrain != null) { CurrentTerrain.ChangeWindow(newWindow); } if (chunks.Count > 0) { for (int i = 0; i < chunks.Count; i++) { chunks[i].UpdateWindow(newWindow); } int oldamountOfTowers = (window.Width / groundWidth) + extraLength + 1; int newamountOfTowers = (newWindow.Width / groundWidth) + extraLength + 1; int towersToCreate = Math.Abs(newamountOfTowers - oldamountOfTowers) + 1; float x = CurrentTerrain.Last().CurrentX + groundWidth; for (int i = 0; i < towersToCreate; i++) { BlockChunk current = CurrentTerrain.Construct((int)x); current.Generate(); chunks.Add(current); x += groundWidth; TowersCreated++; } } window = newWindow; }