private IEnumerator MainLoop() { _isRunning = true; if (autoStartOn != AutoStartOn.Never) { yield return(new WaitForSeconds(startDelay)); } if (started) { onStart?.Invoke(); } while (config.CanSpawn()) { while (_isPaused) { yield return(null); } config.Spawn(); yield return(Cooldown()); } if (completed) { onComplete?.Invoke(); } if (despawnOnComplete) { Despawn(); } _isRunning = false; }
protected GameObject Instantiate(GameObject thingToSpawn, Vector3 position, Quaternion rotation) { ++spawnCount; GameObject spawned = UnityEngine.Object.Instantiate(thingToSpawn, position, rotation, parent.transform); OnSpawn?.Invoke(spawned); return(spawned); }
public void ResumeSpawning() { _isPaused = false; if (resumed) { onResume?.Invoke(); } }
public void PauseSpawning() { _isPaused = true; if (paused) { onPause?.Invoke(); } }
private void Spawning() { GameObject spawningObject = Instantiate(objectToSpawn); spawningObject.transform.position = transform.position; spawningObject.transform.rotation = transform.rotation; SpawnEvent?.Invoke(spawningObject.transform); }
public void StopSpawning() { _isPaused = false; _isRunning = false; if (_mainloop != null) { StopCoroutine(_mainloop); } if (stopped) { onStop?.Invoke(); } }
private IEnumerator SpawnDamage() { while (true) { var time = Random.Range(_settings.MaxDamageSpawnFrequency, _settings.MaxDamageSpawnFrequency); yield return(new WaitForSeconds(time)); var pos = RandPos(); var damageView = _enemyPool.Pop(Enemy.Damage, pos, Quaternion.identity); _activeEnemies.Add(damageView); damageView.DieEvent += DieEventHandler; _asyncProcessor.StartCoroutine(Die(damageView)); SetSize(damageView); SpawnEvent?.Invoke(damageView); } }
public bool Update(float left, TRight right) { var lastNode = _objects.Last; if (!SpawnRight(right)) { return(false); // side effects! } // invoke event for each newly added item while (lastNode?.Next != null) { lastNode = lastNode.Next; SpawnEvent?.Invoke(lastNode.Value, left, right); } DespawnLeft(left, right); return(true); }
internal void OnSpawn(SpawnMessage msg) { if (msg.assetId == Guid.Empty && msg.sceneId == 0) { throw new InvalidOperationException("OnObjSpawn netId: " + msg.netId + " has invalid asset Id"); } if (logger.LogEnabled()) { logger.Log($"Client spawn handler instantiating netId={msg.netId} assetID={msg.assetId} sceneId={msg.sceneId} pos={msg.position}"); } bool spawned = false; // was the object already spawned? NetworkIdentity identity = GetExistingObject(msg.netId); if (identity == null) { //is the object on the prefab or scene object lists? identity = msg.sceneId == 0 ? SpawnPrefab(msg) : SpawnSceneObject(msg); spawned = true; } if (identity == null) { //object could not be found. throw new InvalidOperationException($"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}"); } ApplySpawnPayload(identity, msg); if (spawned) { Spawned.Invoke(identity); } }
public void EventSpawn() { spawnEvent.Invoke(); }
public void SpawnEnemies() { OnSpawnTimer?.Invoke(levelSet.Items[currentLevel]); isGamePlayStarted.Value = true; }