Пример #1
0
    IEnumerator SpawnNewEnemy()
    {
        while (true)
        {
            int     randomIndex = Random.Range(0, spawnPoints.Length - 1);
            Vector3 newLocation = spawnPoints[randomIndex].position;
            spawnFX.transform.position = newLocation;
            spawnFX.transform.rotation = spawnPoints[randomIndex].rotation;
            spawnPoints[randomIndex].GetChild(0).gameObject.SetActive(true);

            yield return(new WaitForSeconds(PortalToSpawnDelay));

            GameObject go           = enemyPoolSpawner.Spawn(transform, newLocation);
            Transform  newTransform = go.transform;

            Enemy newEnemy = newTransform.GetComponent <Enemy>();
            if (newEnemy != null)
            {
                enemies.Add(newEnemy);
                newEnemy.spawner = this;
                newEnemy.GetComponent <EnemyHealth>().spawner = this;
                if (target != null)
                {
                    newEnemy.target = target;
                }
            }

            yield return(new WaitForSeconds(PortalDeactivateDelay));

            spawnPoints[randomIndex].GetChild(0).gameObject.SetActive(false);

            float waitTime = SpawnInterval - PortalToSpawnDelay - PortalDeactivateDelay;
            yield return(new WaitForSeconds(waitTime > 0f ? waitTime : PortalToSpawnDelay + PortalDeactivateDelay));
        }
    }
Пример #2
0
    IEnumerator CreateCells()
    {
        int i, j = 0;

        for (i = -(size / 2); i <= (size / 2); i++)
        {
            for (j = -(size / 2); j <= (size / 2); j++)
            {
                GameObject go = cellSpawner.Spawn(cellParent, new Vector3(i, 0, j));
                go.transform.name = "Cell" + i + "|" + j;
                go.SetActive(true);
            }
            yield return(null);
        }

        yield return(null);
    }
Пример #3
0
 public Projectile Spawn(Projectile prefab)
 {
     return(_spawner.Spawn(prefab));
 }