private void PlaceItemsInRoom(bool isFirst, int numberOfItems) { Rectangle room; if (isFirst) { room = _map.Rooms[0]; } else { room = _map.Rooms.Last(); } for (int i = 0; i < numberOfItems; i++) { if (_map.DoesRoomHaveWalkableSpace(room)) { Point randomRoomLocation = _map.GetRandomLocationInFirstRoom(room); if (randomRoomLocation != null) { Item item = ItemGenerator.CreateItem(_level); Point location = _map.GetRandomLocationInFirstRoom(room); _map.AddTreasure(location.X, location.Y, item); } } } }
private void PlaceItems() { foreach (var room in _map.Rooms) { if (Dice.Roll("1D10") > 5) { if (_map.DoesRoomHaveWalkableSpace(room)) { Point randomRoomLocation = _map.GetRandomLocationInRoom(room); if (randomRoomLocation != null) { Item item = ItemGenerator.CreateItem(_level); Point location = _map.GetRandomLocationInRoom(room); _map.AddTreasure(location.X, location.Y, item); } } } } }