void Start() { //spikeList = new List<GameObject>(); int weightSum = 0; //add configurations to weightedList foreach (ListWrapper configWrap in spikeConfigurationList) { weightedConfigurationList.AddElement(configWrap.items, configWrap.spawnChance); weightSum += configWrap.spawnChance; } weightedConfigurationList.totalWeight = weightSum + noSpikeChance; weightedConfigurationList.nothingValue = new List <GameObject>(); //select random configuration spikeConfiguration = weightedConfigurationList.Grab(); //spawn spikes in selected configuration foreach (ListWrapper configWrap in spikeConfigurationList) { if (configWrap.items == spikeConfiguration) { foreach (GameObject point in configWrap.items) { GameObject newSpike = Instantiate(spikePrefab, point.transform.position, point.transform.rotation); newSpike.transform.SetParent(point.transform.parent); newSpike.transform.localScale = spikeScale; //spikeList.Add(newSpike); if (torchInRoom) { newSpike.GetComponent <TorchEvent>().AddRequiredTorch(torchObject.GetComponent <Torch>()); } } } } foreach (ObjectAndLocation temp in guaranteedSpawns) { GameObject altar = Instantiate(altarPrefab, temp.spawnPoint.transform.position, temp.spawnPoint.transform.rotation); //altar.transform.localScale = altarScale; altar.transform.Rotate(altarRotationOffset); altar.transform.SetParent(transform.Find("Gameplay")); Instantiate(temp.item, temp.spawnPoint.transform.position + new Vector3(0, altarPrefab.transform.localScale.y, 0), temp.spawnPoint.transform.rotation * Quaternion.Euler(0, 0, 90)); } weightSum = 0; foreach (ObjectAndWeight temp in weightedSpawnList) { weightedWeaponList.AddElement(temp.item, temp.weight); weightSum += temp.weight; } weightedWeaponList.totalWeight = weightSum + noWeaponChance; foreach (GameObject point in randomSpawnLocations) { GameObject nextWeapon = weightedWeaponList.FastGrab(); if (nextWeapon != null) { GameObject altar = Instantiate(altarPrefab, point.transform.position, point.transform.rotation); //altar.transform.localScale = altarScale; altar.transform.Rotate(altarRotationOffset); altar.transform.SetParent(transform.Find("Gameplay")); Instantiate(nextWeapon, point.transform.position + new Vector3(0, altarPrefab.transform.localScale.y, 0), point.transform.rotation); } } }