Example #1
0
    public IEnumerator SpawnUnit()
    {
        while (true)
        {
            //would be fun to make a random enemy spawn, rather than always std >>> big.
            //if there is time...
            //would also be nice if they turned to the front...
            if (allUnitsSpawned == false)
            {
                if (currentStdUnitNr < maxStdUnitNr)
                {
                    StandardUnit stdUnit = stdUnitPool.Rent() as StandardUnit;
                    SetUpUnit(stdUnit);
                    currentStdUnitNr++;
                }

                else if (currentBigUnitNr < maxBigUnitNr)
                {
                    BigUnit bigUnit = bigUnitPool.Rent() as BigUnit;
                    SetUpUnit(bigUnit);
                    currentBigUnitNr++;
                }
            }

            if (currentStdUnitNr == maxStdUnitNr && currentBigUnitNr == maxBigUnitNr)
            {
                allUnitsSpawned = true;

                //Making sure all targets are gone before starting next wave.
                if (TowerBase.targets.Count == 0)
                {
                    if (currentWave != maxWaves)
                    {
                        currentWave++;
                        StartWave();
                        yield break;
                    }
                    else
                    {
                        GameManager.StartNextLevel();
                    }
                }
            }

            yield return(new WaitForSeconds(spawnTimer));
        }
    }
Example #2
0
 void ReturnBigUnitToPool(BigUnit unit)
 {
     bigUnitPool.UnRent(unit);
     unit.gameObject.SetActive(false);
 }
Example #3
0
 protected void SetDependency <TDependency>(TDependency dependency)
 {
     BigUnit.SetDependency(dependency);
 }
Example #4
0
 protected TDependency GetDependency <TDependency>()
 {
     return(BigUnit.GetDependency <TDependency>());
 }
Example #5
0
 protected TTestInstance GetTestInstance <TTestInstance>()
 {
     return(BigUnit.GetTestInstance <TTestInstance>());
 }