// stack version private void SpawnOneEnemy() { if (spawnStack.Count == 0) { spawnStack = ListUtils.CreateShuffledStack(spawnPoints); } var enemy = Instantiate(enemyPrefab, enemyParent.transform); var sp = spawnStack.Pop(); enemy.transform.position = sp.transform.position; //Set Enemy Parametres enemy.GetComponent <EnemyBehaviour>().SetMoveSpeed(waveConfig.GetEnemySpeed()); enemy.GetComponent <Enemy>().ScoreValue = waveConfig.GetScoreValue(); enemy.GetComponent <Enemy>().DamageValue = waveConfig.GetDamageValue(); //use new sprite enemy.GetComponent <SpriteRenderer>().sprite = waveConfig.GetEnemySprite(); PublishOnEnemySpawnedEvent(); // tell the system }