public static void CreateItemsOnTurnCycleStart(int itemsToCreate) { for (int i = 0; i < itemsToCreate; i++) { // Get a random valid spawn location for the item Tile spawnLocation = WorldController.GetAllValidNewItemLocationTiles(WorldController.currentWorld) [new Random().Next(0, WorldController.GetAllValidNewItemLocationTiles(WorldController.currentWorld).Count)]; // Was a valid spawning tile actually found? if (spawnLocation != null) { // Create a new random item Item newRandomItem = ItemController.CreateItemFromItemData(ItemLibrary.GetRandomItemData()); // Place item at the spawn location ItemController.PlaceItemOnTile(spawnLocation, newRandomItem); } } }