public void Spawn(Vector3 position, Vector3 velocity) { ShmupPlane e = Enemies.FirstOrDefault(en => !en.gameObject.activeSelf); if (e) { e.Init(position, velocity); } }
// Use this for initialization void Start() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } for (int i = 0; i < MAX_ENEMIES; i++) { ShmupPlane e = ((GameObject)Instantiate(PlanePrefab)).GetComponent <ShmupPlane>(); e.transform.parent = transform; e.gameObject.SetActive(false); Enemies.Add(e); } }