コード例 #1
0
 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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void ResumeSpawning()
 {
     _isPaused = false;
     if (resumed)
     {
         onResume?.Invoke();
     }
 }
コード例 #4
0
 public void PauseSpawning()
 {
     _isPaused = true;
     if (paused)
     {
         onPause?.Invoke();
     }
 }
コード例 #5
0
        private void Spawning()
        {
            GameObject spawningObject = Instantiate(objectToSpawn);

            spawningObject.transform.position = transform.position;
            spawningObject.transform.rotation = transform.rotation;

            SpawnEvent?.Invoke(spawningObject.transform);
        }
コード例 #6
0
 public void StopSpawning()
 {
     _isPaused  = false;
     _isRunning = false;
     if (_mainloop != null)
     {
         StopCoroutine(_mainloop);
     }
     if (stopped)
     {
         onStop?.Invoke();
     }
 }
コード例 #7
0
ファイル: EnemySpawner.cs プロジェクト: wivanw/JobTest
        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);
            }
        }
コード例 #8
0
ファイル: Mountain.cs プロジェクト: Jjagg/gmtk-jam2017
        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);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
 public void EventSpawn()
 {
     spawnEvent.Invoke();
 }
コード例 #11
0
 public void SpawnEnemies()
 {
     OnSpawnTimer?.Invoke(levelSet.Items[currentLevel]);
     isGamePlayStarted.Value = true;
 }