Beispiel #1
0
        private IEnumerator NextEnemy(float pouseTime)
        {
            while (enemyCount > 0)
            {
                int enemyIndex = chanceList[Random.Range(0, chanceList.Count)];

                GameObject tempEnemy = Instantiate(enemyPrefabs[enemyIndex], startPoints[startPointIndex], Quaternion.identity);

                Path.Way tempWay = path.GetWay(startPointIndex);

                tempEnemy.GetComponent <Enemy>().SetWave(waveCount);
                tempEnemy.GetComponent <Enemy>().SetWay(tempWay);
                tempEnemy.GetComponent <Enemy>().SetSpawner(this);

                tempEnemy.transform.forward = (tempWay.wayPoints[1].position - tempWay.wayPoints[0].position).normalized;

                tempEnemy.transform.parent = enemyParent.transform;

                livedEnemy.Add(tempEnemy);

                startPointIndex++;

                if (startPointIndex >= startPoints.Count)
                {
                    startPointIndex = 0;
                }

                enemyCount--;
                yield return(new WaitForSeconds(pouseTime));
            }
        }
Beispiel #2
0
 public void SetWay(Path.Way way)
 {
     this.way = way;
     wayGeted = true;
 }