void OnEnable() { recordings = RecordingFileManager.ListRecordings(); // load in the first recording UpdateRecordingDetails(); }
// public method to handle play vs ghost button behaviour public void GhostButtonHandler() { if (recordingsExist) { Recording recording = null; try{ recording = RecordingFileManager.TryReadRecording(recordings [currentRecordingIndex]); } catch (RecordingFormatException) { // something went wrong reading the recording DisplayMessage("Problem reading recording file."); } catch (PersistentStorageException) { DisplayMessage("Problem reading recording file."); } if (recording == null) { return; } // set up matchmaking for playagainst game, // and start matchmaking! MatchmakingMenuController.options = new MatchmakingMenuController.Options( UIState.RecordingsMenu, GameType.GHOST, recording.level, recording ); UIStateMachine.instance.GoTo(UIState.Matchmaking); } }
// public method to handle confirm-deletion button behaviour public void ConfirmButtonHandler() { try { RecordingFileManager.DeleteRecording(recordings [currentRecordingIndex]); } catch (PersistentStorageException) { DisplayMessage("Problem reading recording file.\n\nTry another."); } confirmationPanel.SetActive(false); // refresh list, also make sure recordings still exists recordings = RecordingFileManager.ListRecordings(); currentRecordingIndex = currentRecordingIndex; // ensures validity of index UpdateRecordingDetails(); }
// public method to handle save recording button behaviour public void SaveRecordingButtonHandler() { if (SceneManager.outs.recording != null) { // and save the recording RecordingFileManager.WriteRecording(SceneManager.outs.recording); // we should set this message to notify the user of success recordingMessage.text = "Recording saved"; } else { // if there's no recording, something must have gone wrong recordingMessage.text = "Failed to save recording"; } }
// public method to handle watch button behaviour public void WatchButtonHandler() { if (recordingsExist) { Recording recording = null; try{ recording = RecordingFileManager.TryReadRecording(recordings [currentRecordingIndex]); } catch (RecordingFormatException) { // something went wrong reading the recording DisplayMessage("Problem reading recording file."); } catch (PersistentStorageException) { DisplayMessage("Problem reading recording file."); } if (recording == null) { return; } SceneManager.StartReplayGame(recording.level, recording); } }