public void SpawnShooters(int capacity) { if (capacity == 0) { Debug.Log("No Risk"); return; } while (capacity > 0) { ShooterRisk sr = PickShooter(capacity); if (sr.risk == -1) { // No valid choices return; } BulletRisk br = PickBullet(capacity); if (br.risk == -1) { // No valid choices return; } float xpos = Random.Range(minPos, maxPos); float ypos = Random.Range(minPos, maxPos); Vector3 screenPosition = Camera.main.ViewportToWorldPoint(new Vector3(xpos, ypos, 0)); GameObject g = Instantiate(sr.prefab, new Vector3(screenPosition.x, screenPosition.y, 0), Quaternion.identity); StaticShooter ss = g.GetComponent <StaticShooter>(); List <Vector3> playerColours = GameStores.GetPlayerColours(); Vector3 col = playerColours[Random.Range(0, playerColours.Count)]; ss.setColour(col); ss.missile = br.prefab; ss.dropOnDeath = drops; ss.dropChance = dropChance; capacity -= Mathf.Max(sr.risk, br.risk); } }
// Start is called before the first frame update void Start() { timer = 0; shooter = gameObject.GetComponent <StaticShooter>(); au = GetComponent <AudioSource>(); }