void Update() { if (Input.GetKeyDown(KeyCode.Z)) { SoundManager.Instance().Play("Shoot"); } if (!gaming) { //游戏没开始 if (Input.GetMouseButtonDown(0) && readyToStart) { readyToStart = false; GameStart(); } } else { //游戏进行中 if (bottomY > zyf.GetWorldScreenSize().y / 2 * -1) { //降低底线 bottomY -= BrickManager.Instance().fallingSpeed *Time.deltaTime; redLine.transform.position = new Vector2(0, bottomY + BrickManager.Instance().brickSize.y / 11); //redLine.GetComponent<RectTransform>().position = Camera.main.WorldToScreenPoint(new Vector2(0, bottomY + BrickManager.Instance().brickSize.y / 11)); } else { //失败 GameOver(); } } }
IEnumerator IEShoot(int _index) { //创建飞弹 float launchY = zyf.GetWorldScreenSize().y / 2 * -1 - 1; Vector2 launchPos = new Vector2(BrickManager.Instance().generateX[_index], launchY); GameObject missile = ObjectPoolManager.Instance().SpawnObject("Missile", launchPos, Quaternion.identity); //发射飞弹 float targetY = GameManager.Instance().bottomY - BrickManager.Instance().brickSize.y / 2; while (missile.transform.position.y < targetY) { missile.transform.Translate(speed * Vector2.up * Time.deltaTime); targetY += BrickManager.Instance().fallingSpeed *Time.deltaTime; yield return(null); } //命中后 SoundManager.Instance().Play("Boom"); ParticleManager.Instance().InstantiateParticle("Impact_Missile", missile.transform.position); //回收 missile.SetActive(false); //命中空缺 if (BrickManager.Instance().rows.Peek().types[_index] == 0) { BrickManager.Instance().ClearFirstRow(); } }
public void ClearRow() { bottomY += BrickManager.Instance().brickSize.y; score++; text_score.text = score.ToString(); }