Exemple #1
0
    private IEnumerator SpawnEnemiesRoutine(RedemptionTDSpawnInfo spawnInfo)
    {
        yield return(new WaitForSeconds(spawnInfo.StartSpawnDelay));

        var enemies = objectPool.GetUnits(spawnInfo.EnemyType, spawnInfo.NumberToSpawn);

        foreach (var enemy in enemies)
        {
            var enemyMode = UnitMode.CreateUnitMode();
            enemy.SpawnObject(currentSpawnCount, spawnInfo.SpawnPosition.transform.position, enemyMode);

            if (currentSpawnCount < currentSpawns.Count)
            {
                currentSpawns[currentSpawnCount] = enemy;
            }
            else
            {
                currentSpawns.Add(enemy);
            }

            currentSpawnCount++;

            enemy.ObjectReturned += HandleEnemyReturned;

            var movement = enemy.GetComponent <EnemyMovement>();

            movement.Initialize(spawnInfo.SpawnPosition);
            movement.Move();

            yield return(new WaitForSeconds(spawnInfo.TimeBetweenSpawns));
        }

        yield return(new WaitForSeconds(spawnInfo.StopSpawnDelay));
    }
Exemple #2
0
    private void SpawnWeapon(Vector2 position)
    {
        if (!ResourcesOverseer.DecreaseResourceEvent(currentWeapon.WeaponCost))
        {
            return;
        }

        var weapons    = objectPool.GetUnits(currentWeapon.WeaponType, 1);
        var weaponMode = UnitMode.CreateUnitMode(currentWeapon.WeaponMode);

        foreach (var weapon in weapons)
        {
            weapon.SpawnObject(0, position, weaponMode);
        }
    }
Exemple #3
0
    private void SpawnResourceDrops(LiteUnit liteUnit, Vector3 pos)
    {
        var enemy = liteUnit.HeavyReference as Enemy;

        if (enemy == null)
        {
            return;
        }

        var numToSpawn   = UnityEngine.Random.Range(0, enemy.MaxResourceDrops);
        var units        = objectPool.GetUnits(objectPool.GetResourceDropType(enemy.Color), numToSpawn);
        var count        = 0;
        var resourceMode = UnitMode.CreateUnitMode();

        foreach (var resourceDrop in units)
        {
            var position = new Vector3(pos.x + UnityEngine.Random.Range(-0.1f, 0.1f),
                                       pos.y + UnityEngine.Random.Range(-0.1f, 0.1f),
                                       -1f);
            resourceDrop.SpawnObject(count, position, resourceMode);
            count++;
        }
    }