/// <summary> /// /// </summary> void Start() { // get all available positions for (int i = 0; i < m_spawnPositions.Count; i++) { Transform spawnTransform = m_spawnPositions[i]; m_availableSpawnPositions.Add(spawnTransform); } // spawn bandits for (int i = 0; i < m_numberToSpawn; i++) { // pick a random spawn point int randomIndex = Random.Range(0, m_availableSpawnPositions.Count); Transform spawnTransform = m_availableSpawnPositions[randomIndex]; m_availableSpawnPositions.RemoveAt(randomIndex); // position no longer available // spawn bandit GameObject bandit = Instantiate(m_banditPrefab, spawnTransform); m_bandits.Add(bandit); // inject bandit spawner dependency into bandit Bandit banditScript = bandit.GetComponent <Bandit>(); banditScript.SetBanditSpawner(this); banditScript.SetFireTime(Mathf.Lerp(m_fireTimeRange.x, m_fireTimeRange.y, i / (float)m_numberToSpawn)); } }