public void InitBarByScore(int pieceIndex, int barIndex, UIBar uiBar) { uiBar.startBeat = occupiedBeats; //QTE BAR if (QTEbarIndex >= 0) { uiBar.type = UIBar.barType.QTEBar; uiBar.ReadScore(QTEscore.QTEscore[QTEbarIndex].notes); uiBar.beatsThisBar = QTEscore.QTEscore[QTEbarIndex].beatsThisBar; } if (QTEbarIndex < 0) { uiBar.type = UIBar.barType.inputBar; //判断当前所在的段落,读取单小节乐谱 OneBarScore _barScore = pieceIndex > 0 ? score.mainlude[barIndex] : score.prelude[barIndex]; uiBar.ReadScore(_barScore.notes); uiBar.beatsThisBar = _barScore.beatsThisBar; } // Debug.Log("startbeat=" + uiBar.startBeat); // Debug.Log("occupiedBeats=" + occupiedBeats); uiBar.Init(); uiBar.GetComponent <UIBar>().SetPinAlpha(0); uiBar.GetComponent <UIBar>().active = true; currentEnergyNotes.AddRange(uiBar.GetComponent <UIBar>().noteList_energy); currentQTENotes.AddRange(uiBar.GetComponent <UIBar>().noteList_QTE); occupiedBeats += uiBar.beatsThisBar; }
//普通BAR转换为QTEBAR,用于QTE触发 public void TurnBarIntoQTE(UIBar uIBar, List <Note> notes) { uIBar.type = UIBar.barType.QTEBar; uIBar.bg.sprite = uIBar.bgQTE; //清除普通阶段的遗留音符 currentEnergyNotes.Clear(); InputSequenceController.Instance.CurInputSequence.Clear(); uIBar.Empty(); uIBar.InitLines(); uIBar.ReadScore(notes); uIBar.InitNotes(); currentQTENotes.AddRange(uIBar.GetComponent <UIBar>().noteList_QTE); }
// Update is called once per frame void Update() { if (Active.Active) { // movement if (_jumpPossible) { if (Input.GetKeyDown(KeyCode.W)) { _flipped = !_flipped; if (_flipped) { GetComponent <SpriteRenderer>().sprite = _sprite[1]; } if (!_flipped) { GetComponent <SpriteRenderer>().sprite = _sprite[0]; } _rayDir = -_rayDir; _source.PlayOneShot(_turnSound, 1); } if (Input.GetKeyDown(KeyCode.Space) && !_wallHit) { if (_flipped) { gameObject.transform.position += new Vector3(-2, 0, 0); } else { gameObject.transform.position += new Vector3(2, 0, 0); } _stamina -= 10; _source.PlayOneShot(_moveSound, 1); } if (Input.GetKeyDown(KeyCode.A)) { _exhaustCloud.Play(); } //Joystick Action?! if (Input.GetKeyDown(KeyCode.Joystick1Button0) || Input.GetKeyDown(KeyCode.Joystick1Button4)) { _source.PlayOneShot(_turnSound, 1); _flipped = !_flipped; if (_flipped) { GetComponent <SpriteRenderer>().sprite = _sprite[1]; } if (!_flipped) { GetComponent <SpriteRenderer>().sprite = _sprite[0]; } _rayDir = -_rayDir; } if ((Input.GetKeyDown(KeyCode.Joystick1Button1) || Input.GetKeyDown(KeyCode.Joystick1Button5)) && !_wallHit) { _source.PlayOneShot(_moveSound, 1); if (_flipped) { gameObject.transform.position += new Vector3(-2, 0, 0); } else { gameObject.transform.position += new Vector3(2, 0, 0); } _stamina -= 10; } } } // stamina if (_stamina < 0) { _jumpPossible = false; } if (_stamina > 25) { _jumpPossible = true; } _bar.GetComponent <UIBar>().Bar(_stamina, 1, 100, 0, 1); if (_stamina <= 100) { _stamina += Time.deltaTime * 15; } if (_jumpPossible) { _exhaustCloud.Stop(); } else if (!_exhaustCloud.isPlaying) { _exhaustCloud.Play(); } //hiding _rayBlack = Physics2D.Raycast(gameObject.transform.position, gameObject.transform.forward, 10f, LayerMask.GetMask("Black")); _rayWhite = Physics2D.Raycast(gameObject.transform.position, gameObject.transform.forward, 10f, LayerMask.GetMask("White")); if (_rayBlack && _flipped) { _hidden = true; } else if (_rayWhite && !_flipped) { _hidden = true; } else { _hidden = false; } if (_hidden) { Vignette.enabled = true; } else { Vignette.enabled = false; } //raycast wall _wallHit = Physics2D.Raycast(gameObject.transform.position, _rayDir, 2, LayerMask.GetMask("Wall")); Debug.DrawRay(gameObject.transform.position, _rayDir, Color.green); }