Beispiel #1
0
        protected virtual IEnumerator WaveProcedure()
        {
            PopupLabel.Show("WAVE " + waveNumber);

            var spawnCount = 10 * waveNumber / 2;

            var deathCount = 0;

            Entity.DeathDelegate deathAction = (Entity damager) =>
            {
                deathCount++;
            };

            for (int i = 0; i < spawnCount; i++)
            {
                yield return(SpawnProcedure(deathAction));
            }

            while (true)
            {
                if (deathCount >= spawnCount)
                {
                    break;
                }

                yield return(new WaitForEndOfFrame());
            }
        }
Beispiel #2
0
        protected virtual IEnumerator WaveProcedure()
        {
            PopupLabel.Show("WAVE " + PopupLabel.Colorize(waveNumber.ToString(), "red"));

            var spawnCount = 10 * waveNumber / 2;

            var deathCount = 0;

            Entity.DeathDelegate deathAction = (Entity damager) =>
            {
                deathCount++;
            };

            for (int i = 0; i < spawnCount; i++)
            {
                Spawn(deathAction);
                yield return(new WaitForSeconds(spawnDelay / waveNumber));
            }

            while (true)
            {
                if (deathCount >= spawnCount)
                {
                    break;
                }

                yield return(new WaitForEndOfFrame());
            }
        }
Beispiel #3
0
        protected virtual IEnumerator SpawnProcedure(Entity.DeathDelegate deathAction)
        {
            var element = GetElement();

            var rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
            var position = Level.Instance.Planet.transform.position + rotation * Vector3.back * range.Random;

            var instance = Instantiate(element.Prefab, position, rotation);

            var entity = instance.GetComponent <Entity>();

            entity.OnDeath += deathAction;

            yield return(new WaitForSeconds(spawnDelay / waveNumber));
        }
Beispiel #4
0
        protected virtual Entity Spawn(Entity.DeathDelegate deathAction)
        {
            var prefab = GetPrefab();

            var rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
            var position = Vector3.zero + rotation * Vector3.back * range.Random;

            var instance = Instantiate(prefab, position, rotation);

            var entity = instance.GetComponent <Entity>();

            entity.OnDeath += deathAction;

            return(entity);
        }