private void Update() { if (partition != null) { if (pads != null) { pads.Update(); for (int i = 0; i < 4; i++) { if (pads.GetKeyDown(i)) { //Send TrackKey input partition.PlayerInputted(i); } } } else { if (ControllerId >= 0) { for (int i = 0; i < trackKey.Length; i++) { if (Input.GetKeyDown(trackKey[i]) && partition != null) { //Send TrackKey input partition.PlayerInputted(i); } } } else { if (Input.GetKeyDown(KeyCode.A)) { partition.PlayerInputted(0); } if (Input.GetKeyDown(KeyCode.Z)) { partition.PlayerInputted(1); } if (Input.GetKeyDown(KeyCode.E)) { partition.PlayerInputted(2); } if (Input.GetKeyDown(KeyCode.R)) { partition.PlayerInputted(3); } } } if (partition != null && Personnage.AvailableRole.Length > 1) { if (pads != null) { if (pads.GetKeyDown(4)) { if (!BossManager.Instance.goHurlement) { SwitchRole(); } else { SoundMgr.Instance.PlaySound("Snd_Cant_Switch"); } } } else if (ControllerId >= 0) { if (Input.GetKeyDown(KeyCodeUtils.GetKeyCode("Joystick" + ControllerId + "Button5"))) { if (!BossManager.Instance.goHurlement) { SwitchRole(); } else { SoundMgr.Instance.PlaySound("Snd_Cant_Switch"); } } } else { if (Input.GetKeyDown(KeyCode.Space)) { if (!BossManager.Instance.goHurlement) { SwitchRole(); } else { SoundMgr.Instance.PlaySound("Snd_Cant_Switch"); } } } } } }
void Update() { //UI //Slider sliderTime.value = audios.time; txtTps.text = (audios.time).ToString("0") + "/" + song.length.ToString("0"); cameraTransform.transform.position = new Vector3(Mathf.Lerp(0, TrackLength, audios.time / audios.clip.length) + offsetX, 0, -10); //if TrackLength Change -> resizeTracks if (System.Math.Round(crotchetSize, 4) != System.Math.Round(TrackLength / crotchetCount, 4)) { ResizeTracks(); } //Key Event //Click Add/Destroy if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { //Debug.Log(OffsetYTracks[0] - hit.point.y); float closest = Mathf.Infinity; int TrackIdClosest = -1; for (int i = 0; i < OffsetYTracks.Length; i++) { if (Mathf.Abs(OffsetYTracks[i] - hit.point.y) < closest) { TrackIdClosest = i; closest = Mathf.Abs(OffsetYTracks[i] - hit.point.y); } } if (hit.transform.tag == "PrimaryBeat") { hit.transform.GetComponent <PrimaryBeat>().OnClick(TrackIdClosest, 0); } else { hit.transform.GetComponent <subbeat>().OnClick(TrackIdClosest); } } } //PlayPause if (Input.GetKeyDown(KeyCode.Space)) { play(); } //PlayMode input if (PlayMode) { if (Input.GetKeyDown(KeyCode.Joystick1Button0) || Input.GetKeyDown(KeyCode.A)) { LookForNode(0); } if (Input.GetKeyDown(KeyCode.Joystick1Button1) || Input.GetKeyDown(KeyCode.Z)) { LookForNode(1); } if (Input.GetKeyDown(KeyCode.Joystick1Button2) || Input.GetKeyDown(KeyCode.E)) { LookForNode(2); } if (Input.GetKeyDown(KeyCode.Joystick1Button3) || Input.GetKeyDown(KeyCode.R)) { LookForNode(3); } pads.Update(); for (int i = 0; i < 4; i++) { if (pads.GetKeyDown(i)) { //Send TrackKey input LookForNode(i); } } } }