public void generate(Rectangle area) { while (level.mapID + 1 > generatedMaps.Count) { generatedMaps.Add(new List <Rectangle>()); } foreach (var rect in generatedMaps[level.mapID]) { if (rect.X == area.X) { return; } } generatedMaps[level.mapID].Add(area); //OBJECTS Tree1 tree = new Tree1(0, 0); Grass grass = new Grass(0, 0); // for (int y = (int)((area.Y / level.CurrentMap.TileHeight) * level.CurrentMap.TileHeight); y < area.Y + area.Height; y += level.CurrentMap.TileHeight) { for (int x = (int)((area.X / level.CurrentMap.TileWidth) * level.CurrentMap.TileWidth); x < area.X + area.Width; x += level.CurrentMap.TileWidth) { if (!tree.Collision(new Vector2(x, y), level)) { if (rdm.Next(0, 20) == 1) { level.AddEntity(new Tree1(x, y)); } } } } for (int y = (int)((area.Y / level.CurrentMap.TileHeight) * level.CurrentMap.TileHeight); y < area.Y + area.Height; y += level.CurrentMap.TileHeight) { for (int x = (int)((area.X / level.CurrentMap.TileWidth) * level.CurrentMap.TileWidth); x < area.X + area.Width; x += level.CurrentMap.TileWidth) { if (!grass.Collision(new Vector2(x, y), level)) { if (rdm.Next(0, 2) == 1) { level.AddEntity(new Grass(x, y)); } } } } }