Beispiel #1
0
    private IEnumerator SpawnTarget()
    {
        // Wait before spawning
        yield return(new WaitForSeconds(spawnDelay));

        // Spawning loop
        while (this.isActiveAndEnabled)
        {
            if (inactiveTargets.Count > 0)
            {
                // Get inactive target from queue
                Target target = inactiveTargets.Dequeue();

                // Move target to position and make sure it is visible for the player
                Vector3 position;

                do
                {
                    position = transform.position + Random.onUnitSphere * spawnRadius;
                } while(position.y < transform.position.y || position.y > maxSpawnHeight);

                target.transform.position = position;

                // Activate target
                target.Activate();
            }

            // Get random wait time
            float waitTime = Random.Range(timeBetweenSpawnsMin, timeBetweenSpawnsMax);

            yield return(new WaitForSeconds(waitTime));
        }
    }
Beispiel #2
0
 public void Activate() => Target.Activate();
 public virtual void Activate()
 {
     Target.Activate();
 }
Beispiel #4
0
 public void Activate()
 {
     Target.Activate();
 }