Example #1
0
        private void InitEnemy()
        {
            SpawnEnemy enemyTemp = null;
            int        index     = 1;

            foreach (Transform trams in transform)
            {
                enemyTemp = trams.GetOrAddComponent <SpawnEnemy>();
                enemyTemp.Init(index, RemoveEnemyCallBack);
                inactiveEnemies.Add(enemyTemp);
                index++;
            }
        }
Example #2
0
        public void Spawn()
        {
            int        count     = GetSpawnNum();
            SpawnEnemy enemyTemp = null;

            HashSet <SpawnEnemy> .Enumerator temp = inactiveEnemies.GetEnumerator();
            for (int i = 0; i < count; i++)
            {
                if (temp.MoveNext())
                {
                    enemyTemp = temp.Current;
                    activeEnemies.Add(enemyTemp);
                    enemyTemp.Spawn();
                }
            }

            foreach (SpawnEnemy enemy in activeEnemies)
            {
                inactiveEnemies.Remove(enemy);
            }
        }
Example #3
0
 private void RemoveEnemyCallBack(SpawnEnemy enemy)
 {
     activeEnemies.Remove(enemy);
     Spawn();
 }