public void SpawnPotions() { int mightSpawnPotion; int randX, randY; int whileCount = 0; for (int i = 0; i < roomsScript.roomsInPlay.Count; i++) { BaseRoom br = roomsScript.roomsInPlay[i]; whileCount = 0; mightSpawnPotion = Random.Range(0, potionRarity); if (mightSpawnPotion == 0) { do { whileCount += 1; randX = Random.Range(0, br.width); randY = Random.Range(0, br.length); } while (br.GetRoomSectionArray()[randX, randY].hasTownsfolk == true && whileCount < 10); if (whileCount < 10) { br.GetRoomSectionArray()[randX, randY].hasPotion = true; Potion p = new Potion(); GameObject go = Instantiate(potionObject, br.GetRoomSectionArray()[randX, randY].position, br.GetRoomSectionArray()[randX, randY].rotation); p.SetPotionObject(go); potionList.Add(p); } } } }