private void SpawnAstroid() { if (AstroidList.Count >= MaxAstroidCount) { return; } if (SpawnTimer >= SpawnInterval) { GameObject obj = Instantiate(Astroid, transform, false); SC_Astroid astroid = obj.GetComponent <SC_Astroid>(); astroid.MoveSpeed = Random.Range(AstroidMoveSpeed.min, AstroidMoveSpeed.max); astroid.RotateSpeed = Random.Range(AstroidRotateSpeed.min, AstroidRotateSpeed.max); astroid.transform.localScale *= Random.Range(AstroidSizeMultiplier.min, AstroidSizeMultiplier.max); obj.transform.position = transform.position + new Vector3(0, AreaController.SphereRadius + Random.Range(-1, 1), 0); AstroidList.Add(astroid); SpawnTimer = 0; } SpawnTimer += Time.deltaTime; }
public void DestroyAstroid(SC_Astroid astroid) { AstroidList.Remove(astroid); Destroy(astroid.gameObject, 0.1f); }