/// <summary> /// 球体弾幕 /// </summary> /// <returns></returns> IEnumerator FireBallBulle() { Vector3 bulletDir = firPoint.transform.up; //发射方向 Quaternion rotateQuate = Quaternion.AngleAxis(10, Vector3.forward); float distance = 1.0f; for (int j = 0; j < 8; j++) { for (int i = 0; i < 36; i++) { Vector3 creatPoint = firPoint.transform.position + bulletDir * distance; BulletCharacter tempBullet = CreatBullet(bulletDir, creatPoint); tempBullet.isMove = false; StartCoroutine(tempBullet.DirChangeMoveMode(10.0f, 0.4f, 15)); bulletDir = rotateQuate * bulletDir; var clones = GameObject.FindGameObjectsWithTag("bullet"); foreach (var clone in clones) { Destroy(clone, 5f); } } yield return(new WaitForSeconds(0.2f)); } yield return(null); }
public IEnumerator DrawWoLunPath() { yield return(new WaitForSeconds(1.2f)); float distance = 0.6f; float addVaule = 0.2f; Vector3 dir = Vector3.up * -1; Quaternion tempQua = Quaternion.AngleAxis(20, Vector3.forward); lookText.text = "首先发射一个生成半径不断增长圆形弹幕"; List <BulletCharacter> bullets = new List <BulletCharacter>(); for (int i = 0; i < 18; i++) { Debug.DrawLine(transform.position, transform.position + dir * distance, Color.black, 0.3f); BulletCharacter bullet = Instantiate(round, transform.position + dir * distance, Quaternion.identity); bullet.transform.SetParent(parent); bullet.speed = 0; bullets.Add(bullet); yield return(new WaitForSeconds(0.2f)); Debug.DrawLine(transform.position, transform.position + dir * distance, Color.red, 30f); dir = tempQua * dir; distance += addVaule; } lookText.text = "然后在每一个点的位置发射圆形弹幕"; for (int i = 0; i < bullets.Count; i++) { StartCoroutine(DrawRoundPath(bullets[i].transform.position)); yield return(new WaitForSeconds(0.2f)); } yield return(new WaitForSeconds(7.2f)); lookText.text = "涡轮型弹幕完成!"; }
public BulletCharacter CreatBullet(Vector3 dir, Vector3 creatPoint) { BulletCharacter bulletCharacter = Instantiate(bulletTemplate, creatPoint, Quaternion.identity); bulletCharacter.gameObject.SetActive(true); bulletCharacter.dir = dir; return(bulletCharacter); }
IEnumerator DrawLineRoundsPath() { float distance = 1.0f; lookText.text = "首先朝8个方向发射一个圆形弹幕"; yield return(new WaitForSeconds(1.5f)); Vector3 dir = Vector3.up * -1; Quaternion tempQua = Quaternion.AngleAxis(45, Vector3.forward); for (int i = 0; i < 8; i++) { dir = tempQua * dir; Debug.DrawLine(transform.position, transform.position + dir * distance, Color.black, 0.3f); yield return(new WaitForSeconds(0.2f)); Debug.DrawLine(transform.position, transform.position + dir * distance, Color.red, 30f); } List <BulletCharacter> bullets = new List <BulletCharacter>(); for (int i = 0; i < 8; i++) { dir = tempQua * dir; BulletCharacter bullet = Instantiate(round, transform.position, Quaternion.identity); bullet.transform.SetParent(parent); bullet.dir = dir; bullet.speed = 2.0f; bullets.Add(bullet); } yield return(new WaitForSeconds(1.3f)); lookText.text = "到达目标点,开始发射多播多方向圆形弹幕!"; for (int i = 0; i < bullets.Count; i++) { bullets[i].speed = 0; StartCoroutine(DrawRoundPath(bullets[i].transform.position)); } yield return(new WaitForSeconds(7.2f)); lookText.text = "自此弹幕完成"; yield return(null); }
//變大變小圓形彈幕 IEnumerator FireBallBulle() { Vector3 bulletDir = firPoint.transform.up; Quaternion rotateQuate = Quaternion.AngleAxis(10, Vector3.forward); float distance = 1.0f; for (int j = 0; j < 8; j++) { for (int i = 0; i < 36; i++) { Vector3 creatPoint = firPoint.transform.position + bulletDir * distance; BulletCharacter tempBullet = CreatBullet(bulletDir, creatPoint); tempBullet.isMove = false; StartCoroutine(tempBullet.DirChangeMoveMode(10.0f, 0.4f, 15)); bulletDir = rotateQuate * bulletDir; } yield return(new WaitForSeconds(0.2f)); } yield return(null); }