public void reward() { GameObject present = rewards.getObject(); if (_powerupContainer && present && Random.value <= rewardChance) { GameObject powerup = _boundManager.bsInstantiate(present, transform.position, Quaternion.identity); powerup.transform.parent = _powerupContainer.transform; } }
IEnumerator TimedSpawn(Spawnable spawnable) { yield return(new WaitForSeconds(3f)); generateContainerIfNoneAvaliable(spawnable); while (_spawnActive) { Transform container = spawnable.container.transform; bool iAmActive = spawnable.getActive(); float spawnTime = getSpawnTime(spawnable.timeRange); yield return(new WaitForSeconds(spawnTime)); if (_gameManager.isPaused()) { continue; } GameObject item; Transform parent = null; bool specialSpawn = spawnQueue.Count > 0; if (specialSpawn) { GameObjectWP special = spawnQueue.Dequeue(); item = special.item; parent = special.parent; } else { item = spawnable.getObject(); } enemyHasFirstSpawn_superCheck(item, spawnable); int spawnCount = spawnable.spawnCount; int itemCount = container.childCount + 1; bool canSpawn = spawnCount >= itemCount || spawnCount == -1 || _gameManager.isEndlessModeUnlocked(); if (item && (specialSpawn || canSpawn && iAmActive) && _spawnActive) { Vector3 spawnPos = generateSpawnPosition(spawnable); setPausible(item, _managers); setEnemy(item, _managers); setPowerup(item, _managers); GameObject newItem = Instantiate(item, spawnPos, Quaternion.identity, parent ? parent : container); } } }