Beispiel #1
0
    IEnumerator SpawnPickups(SpawnerWave item)
    {
        yield return(new WaitForSeconds(Random.Range(item.delayMin, item.delayMax)));

        if (playerInRange)
        {
            SpawnAround(item);
        }
    }
Beispiel #2
0
    private IEnumerator spawnWaveMobs(SpawnerWave wave, float delayTime)
    {
        yield return(new WaitForSeconds(delayTime));

        float maxTimeInterval = wave.SpawnTime / waveSize;
        float delay           = 0f;

        for (int i = 0; i < waveSize; i++)
        {
            delay += Random.Range(0f, maxTimeInterval);
            SpawnType type = wave.GetSpawnType();
            StartCoroutine(SpwanMob(type.mob, type.GetTransform(), delay));
        }
    }
Beispiel #3
0
    void SpawnAround(SpawnerWave wave)
    {
        int count = Random.Range(wave.countMin, wave.countMax);

        for (int i = 0; i < count; i++)
        {
            var   position = transform.position;
            var   range    = wave.spawnerRange;
            float spawnX   = Random.Range(position.x - range.x, position.x + range.x);
            float spawnY   = Random.Range(position.y - range.y, position.y + range.y);

            Instantiate(wave.prefab, new Vector3(spawnX, spawnY), Quaternion.identity);
        }
    }
Beispiel #4
0
    private void SpawnWave(int waveNumber)
    {
        SpawnerWave wave = waves[waveNumber];

        waveSize = wave.mobNumer;
        mobDead  = 0;
        if (wave.eventName != null)
        {
            IEvent ev = (IEvent)gameObject.GetComponent(wave.eventName);
            if (ev != null)
            {
                ev.Trigger();
            }
        }
        if (waveSize > 0)
        {
            StartCoroutine(spawnWaveMobs(wave, wave.WaveDelay));
        }
    }
    IEnumerator SpawnUnits(SpawnerWave waveToSpawn)
    {
        foreach (var spawnSet in waveToSpawn.spawnList)
        {
            if (spawnSet.spawnDelay > 0)
                yield return new WaitForSeconds(spawnSet.spawnDelay);

            for (int i = 0; i < spawnSet.objectCount; i++)
            {
                GameObject obj = GenericPooler.current.GetPooledObject(spawnSet.objectToSpawn.name);

                if (obj == null)
                    Debug.Log("Object not found in pool");

                else
                {
                    obj.GetComponent<EnemyScript>().navPath = navigationPath;
                    obj.transform.position = transform.position;
                    obj.transform.rotation = transform.rotation;
                    obj.SetActive(true);
                }

                yield return new WaitForSeconds(0.2f);
            }
        }

        yield return null;
    }
 public void RemoveWave(SpawnerWave wave)
 {
     waves.Remove(wave);
 }