private void OnTriggerEnter(Collider other) { if (IsOnCooldown) { return; } currentCooldown += Time.deltaTime; if (thisControl == Controls.INVERT) { map.InvertNotes(); } else if (thisControl == Controls.PAUSE) { map.PauseSong(); } else if (thisControl == Controls.PLAY) { map.ResumeSong(); } else if (thisControl == Controls.REWIND) { map.Rewind(); } else if (thisControl == Controls.SAVE) { map.SaveCurrentMapToDisk(); } }
private void ProcessControls(bool vrControls) { bool triggerCooldown = false; BeatMap.EditorState currentState = BeatMap.GetCurrentState(); if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_SteamVR_Trigger) || Input.GetKeyDown(KeyCode.Space) && !vrControls) { triggerDown = true; if (!BeatMap.Inverted) { map.InvertNotes(); } } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger) || Input.GetKeyUp(KeyCode.Space) && !vrControls) { triggerDown = false; if (BeatMap.Inverted) { map.InvertNotes(); } } else if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_ApplicationMenu) || Input.GetKeyDown(KeyCode.A) && !vrControls) { menuButtonDown = true; bool bothControllersPressing = otherSaber.menuButtonDown; if (bothControllersPressing) { if (currentState == BeatMap.EditorState.Editing || currentState == BeatMap.EditorState.PlaybackPaused) { map.ResumeSong(); triggerCooldown = true; return; } else if (currentState == BeatMap.EditorState.Playback || currentState == BeatMap.EditorState.Recording) { map.PauseSong(); triggerCooldown = true; return; } } else { if (currentState == BeatMap.EditorState.Editing) { if (selector.GetAttachedObject() != null) { Note note = selector.GetAttachedObject().GetComponent <Note>(); if (note != null) { if (!note.noteDetails.inverted) { note.MakeNeutral(); if (isLeft) { note.Invert(true); } DetachSelector(); triggerCooldown = true; } } } } } } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_ApplicationMenu) || Input.GetKeyUp(KeyCode.A) && !vrControls) { menuButtonDown = false; } if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyDown(KeyCode.Y) && !vrControls) { } if (vrControls && steamVRController.GetTouchDown(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyDown(KeyCode.T) && !vrControls) { if (currentState == BeatMap.EditorState.Recording) { BeatMap.currentNoteMode = BeatMap.NoteMode.HalfNote; } } else if (vrControls && steamVRController.GetTouchUp(EVRButtonId.k_EButton_SteamVR_Touchpad) || Input.GetKeyUp(KeyCode.T) && !vrControls) { if (currentState == BeatMap.EditorState.Recording) { BeatMap.currentNoteMode = BeatMap.NoteMode.WholeNote; } } if (vrControls && steamVRController.GetPressDown(EVRButtonId.k_EButton_Grip) || Input.GetKeyDown(KeyCode.G) && !vrControls) { if (gripHeldFor == 0) // Fresh push { if (selector.HasTarget()) { BeatMap.Log("Calling Grab on object " + selector.GetAttachedObject().name); Grab(selector.GetAttachedObject()); if (selector.GetAttachedObject().GetComponent <MiniMap>() != null) { map.PauseSong(); } triggerCooldown = true; } } gripHeldFor += Time.deltaTime; } else if (vrControls && steamVRController.GetPressUp(EVRButtonId.k_EButton_Grip) || Input.GetKeyUp(KeyCode.G) && !vrControls) { BeatMap.Log("Grip let go, grabbing? " + grabbing); gripHeldFor = 0; if (grabbing) { UnGrab(); triggerCooldown = true; } } // KEYBOARD ONLY // if (!vrControls) { if (Input.GetKeyDown(KeyCode.W)) { transform.position += transform.forward; } else if (Input.GetKeyDown(KeyCode.A)) { transform.position += -transform.right; } else if (Input.GetKeyDown(KeyCode.S)) { transform.position += -transform.forward; } else if (Input.GetKeyDown(KeyCode.D)) { transform.position += transform.right; } else if (Input.GetKeyDown(KeyCode.Q)) { transform.position += transform.up; } else if (Input.GetKeyDown(KeyCode.E)) { transform.position += -transform.up; } else if (Input.GetKeyDown(KeyCode.RightArrow)) { BeatMap.SkipToBeat(BeatMap.GetCurrentBeat() + 10); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { BeatMap.SkipToBeat(BeatMap.GetCurrentBeat() - 10); } else if (Input.GetKeyDown(KeyCode.P) && !IsOnCoolDown() && isLeft) { triggerCooldown = true; if (BeatMap.GetCurrentState() == BeatMap.EditorState.Editing) { map.ResumeSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.PlaybackPaused) { map.ResumeSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.Playback) { map.PauseSong(); } else if (BeatMap.GetCurrentState() == BeatMap.EditorState.Recording) { map.PauseSong(); } } } if (triggerCooldown) { currentCooldown += Time.deltaTime; } }