private IEnumerator Fire(IBulletModel model) { while (GameStateModel.Single.GameState == GameState.NULL) { yield return(new WaitForSeconds(0.2f)); } var audioName = model.AudioName.ToString(); AudioMgr.Single.Play(audioName, true); var start = DateTime.Now; while (true) { yield return(new WaitForSeconds(model.FireTime)); model.Trajectory(data => { for (int i = 0; i < data.Length; i++) { Spawn(i, data.Length, model, data[i]); } }); //开火暂停时间 if ((DateTime.Now - start).TotalSeconds >= Const.FIRE_DURATION) { AudioMgr.Single.PauseDelay(audioName); yield return(new WaitForSeconds(Const.FIRE_CD_TIME)); start = DateTime.Now; AudioMgr.Single.Replay(audioName); } } }
private void InitPos(IBulletModel model) { model.Trajectory((trajectorys) => { var bulletDirection = trajectorys[0].GetDirection(); Vector2 selfDirection = transform.position - transform.parent.position; var angle = Vector2.Angle(selfDirection, bulletDirection); var pos = transform.localPosition; if (angle > 90) { pos.y = -pos.y; } transform.localPosition = pos; }); }