public static CameraCue[] GetCameraCues(string data) { var cameraCuesJSON = JSON.Parse(data); CameraCue[] cameraCues = new CameraCue[cameraCuesJSON["cameraCues"].Count]; for (int i = 0; i < cameraCuesJSON["cameraCues"].Count; i++) { CameraCue cameraCue = new CameraCue { tick = cameraCuesJSON["cameraCues"][i]["tick"], tickLength = cameraCuesJSON["cameraCues"][i]["tickLength"], xPos = cameraCuesJSON["cameraCues"][i]["xPos"], yPos = cameraCuesJSON["cameraCues"][i]["yPos"], zPos = cameraCuesJSON["cameraCues"][i]["zPos"], xRot = cameraCuesJSON["cameraCues"][i]["xRot"], yRot = cameraCuesJSON["cameraCues"][i]["yRot"], zRot = cameraCuesJSON["cameraCues"][i]["zRot"] }; cameraCues[i] = cameraCue; } return(cameraCues); }
public override void OnUpdate() { //Tracking menu state menuState = MenuState.GetState(); //If menu changes if (menuState != oldMenuState) { MelonLogger.Log("Menu: " + menuState.ToString()); if (menuState == MenuState.State.MainPage) { CheckCamera(); } if (menuState == MenuState.State.LaunchPage) { scriptExists = LoadCameraCues(); } if (menuState == MenuState.State.Launched && !KataConfig.I.practiceMode) { if (scriptExists) { LoadFOV(); } Camera thirdPersonCam = spectatorCam.cam; startPointPos = thirdPersonCam.gameObject.transform.position; startPointRot = thirdPersonCam.gameObject.transform.rotation.eulerAngles; } if (oldMenuState == MenuState.State.Launched && menuState == MenuState.State.SongPage) { SetFOV(fovSetting); } oldMenuState = menuState; } //If playing a song if (menuState == MenuState.State.Launched && !KataConfig.I.practiceMode) { //Update midi tick lastTick = ScoreKeeper.I.mLastTick; if (lastTick != oldLastTick) { if (camOK && scriptExists) { Camera thirdPersonCam = spectatorCam.cam; CameraCue cameraCue = cameraCues[currentCameraCueIndex]; if (!ended && lastTick >= cameraCue.tick && timer <= cameraCue.tickLength && lastTick <= cameraCue.tick + cameraCue.tickLength) { timer += lastTick - oldLastTick; percent = timer / cameraCue.tickLength; Vector3 destinationPos = new Vector3(cameraCue.xPos, cameraCue.yPos, cameraCue.zPos); thirdPersonCam.gameObject.transform.position = startPointPos + (destinationPos - startPointPos) * percent; Vector3 destinationRot = new Vector3(cameraCue.xRot, cameraCue.yRot, cameraCue.zRot); thirdPersonCam.gameObject.transform.rotation = Quaternion.Euler( startPointRot.y + (destinationRot.y - startPointRot.y) * percent, startPointRot.x + (destinationRot.x - startPointRot.x) * percent, startPointRot.z + (destinationRot.z - startPointRot.z) * percent ); } if (!ended && lastTick >= cameraCue.tick + cameraCue.tickLength) { if (timer != 0) { Vector3 destinationPos = new Vector3(cameraCue.xPos, cameraCue.yPos, cameraCue.zPos); thirdPersonCam.gameObject.transform.position = destinationPos; Vector3 destinationRot = new Vector3(cameraCue.xRot, cameraCue.yRot, cameraCue.zRot); thirdPersonCam.gameObject.transform.rotation = Quaternion.Euler(destinationRot.y, destinationRot.x, destinationRot.z); startPointPos = thirdPersonCam.gameObject.transform.position; startPointRot = thirdPersonCam.gameObject.transform.rotation.eulerAngles; timer = 0; if (cameraCues.Length > currentCameraCueIndex + 1) { currentCameraCueIndex += 1; } else { ended = true; } } } } oldLastTick = lastTick; } } if (Input.GetKeyDown(KeyCode.R)) { Camera thirdPersonCam = spectatorCam.cam; Vector3 homePos = new Vector3(0.0f, 2.4f, -2.6f); thirdPersonCam.gameObject.transform.position = homePos; } if (Input.GetKeyDown(KeyCode.T)) { Camera thirdPersonCam = spectatorCam.cam; Vector3 homePos = new Vector3(0.0f, 2.4f, 22.4f); thirdPersonCam.gameObject.transform.position = homePos; } if (Input.GetKeyDown(KeyCode.Y)) { Camera thirdPersonCam = spectatorCam.cam; Vector3 homePos = new Vector3(0.0f, 2.4f, -60.6f); thirdPersonCam.gameObject.transform.position = homePos; } if (Input.GetKeyDown(KeyCode.F)) { Camera thirdPersonCam = spectatorCam.cam; Vector3 camPos = thirdPersonCam.gameObject.transform.position; MelonLogger.Log("Cam Pos: " + camPos.ToString()); Vector3 euler = thirdPersonCam.gameObject.transform.rotation.eulerAngles; MelonLogger.Log("Cam Rot: " + euler.ToString()); } }