private void Spawn(LootPackage lootPackage) { int amount = lootPackage.amountMin; if (lootPackage.random) { amount = Random.Range(lootPackage.amountMin, lootPackage.amountMax); } StartCoroutine(SpawnTimed(amount, lootPackage)); }
private void InstantiateLootChild(LootPackage lootPackage) { GameObject objToSpawn = new GameObject("LootChild_" + name); //Add Components objToSpawn.AddComponent <LootChild>(); objToSpawn.transform.position = transform.position; objToSpawn.transform.parent = EffectCollection.GetInstance().transform; LootChild lc = objToSpawn.GetComponent <LootChild>(); lc.SpawnLoot(lootPackage); }
IEnumerator SpawnTimed(int amount, LootPackage lootPackage) { Debug.Log("Amount Spawn:" + amount); for (int i = 0; i < amount; i++) { Debug.Log("Spawn " + i); int pos = Random.Range(0, lootPackage.prefabLootList.Length); InstantiateEffect(lootPackage.prefabLootList[pos]); Debug.Log("Instantiate complete "); yield return(new WaitForSeconds(0.01F)); Debug.Log("Waited for seconds " + i); } Destroy(gameObject); }
public void SpawnLoot(LootPackage lootPackage) { Spawn(lootPackage); }