void SpawnBonus(ref PickupSpawnerData spawnData) { foreach (Transform t in spawnData.spawnPoints) { if (UnityEngine.Random.value < spawnData.probability) { var go = _factory.Build(spawnData.bonus); _entityFactory.BuildEntity(go.GetInstanceID(), go.GetComponent <IEntityDescriptorHolder>().BuildDescriptorType()); var transform = go.transform; transform.position = t.position; transform.rotation = t.rotation; } } spawnData.timer = 0; }
void Tick(float deltaTime) { for (int i = 0; _bonusToSpawn.Count > i; i++) { if (_bonusToSpawn[i].timer > _bonusToSpawn[i].time) { PickupSpawnerData data = _bonusToSpawn[i]; SpawnBonus(ref data); _bonusToSpawn[i] = data; } else { _bonusToSpawn[i].timer += deltaTime; } } }