private IEnumerator Player() { Recording recording = playerVCR.GetRecording(); if (recording == null) { yield break; } Debug.Log(recording.ToString()); curPlayer = (InputVCR)Instantiate(playbackCharacterPrefab, recordingStartPos, recordingStartRot); curPlayer.Play(Recording.ParseRecording(recording.ToString())); SwapTex(); float playTime = recording.recordingLength; float curTime = 0f; isPlaying = true; while (curTime < playTime) { if (isPlaying) { curTime += Time.deltaTime; } yield return(0); } // Play finished isPlaying = false; Destroy(curPlayer.gameObject); curPlayer = null; SwapTex(); }
public void Save(Recording r, Settings s, Stream fs) { var sw = new StreamWriter(fs); sw.WriteLine(s.ToString()); sw.WriteLine(r.ToString()); sw.Close(); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } if (DomainName != null) { p.Add(new KeyValuePair <string, string>("DomainName", DomainName)); } if (DisasterRecoveryUrl != null) { p.Add(new KeyValuePair <string, string>("DisasterRecoveryUrl", Serializers.Url(DisasterRecoveryUrl))); } if (DisasterRecoveryMethod != null) { p.Add(new KeyValuePair <string, string>("DisasterRecoveryMethod", DisasterRecoveryMethod.ToString())); } if (Recording != null) { p.Add(new KeyValuePair <string, string>("Recording", Recording.ToString())); } if (TransferMode != null) { p.Add(new KeyValuePair <string, string>("TransferMode", TransferMode.ToString())); } if (Secure != null) { p.Add(new KeyValuePair <string, string>("Secure", Secure.Value.ToString().ToLower())); } if (CnamLookupEnabled != null) { p.Add(new KeyValuePair <string, string>("CnamLookupEnabled", CnamLookupEnabled.Value.ToString().ToLower())); } return(p); }
public override String ToString() { String desStr = ""; try { desStr = "Name: " + CameraName + ", " + "Previewing: " + Previewing.ToString() + ", " + "Streamming: " + Streaming.ToString() + ", " + "Analysing: " + Analysing.ToString() + ", " + "Recording: " + Recording.ToString() + ", " + "DataAlerting: " + DataAlerting.ToString() + ", " + "EventAlerting: " + EventAlerting.ToString(); } catch (Exception err) { logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; } return(desStr); }
/// <summary> /// Uploads the ghost replay JSON file to a server. /// </summary> IEnumerator UploadGhost() { // Get object used to communicate with server FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://buckeye.dreamhost.com/sgpx.coldencullen.com/ghosts/" + upload.text); request.Method = WebRequestMethods.Ftp.UploadFile; // Login //NOTE: Hardcoding our login credentials here is not a smart idea. request.Credentials = new NetworkCredential(FTP_USER, FTP_PASSWORD); // Upload to server byte[] fileContents = Encoding.UTF8.GetBytes(fastestRecording.ToString()); request.ContentLength = fileContents.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Close(); Debug.Log((request.GetResponse() as FtpWebResponse).StatusDescription); yield return(null); }
private IEnumerator Player() { // Get the previous recording Recording recording = playerVCR.GetRecording(); // Gets selected length and cuts it down if too long int framePos = recording.frames.Count - playFrom; if (framePos != 0) { recording.frames.RemoveRange(0, framePos); } playFrom = 0; Debug.Log("Testing - There are " + recording.frames.Count + " recorded! - Spawning"); // Add previous recording to list playerRecordings.Add(recording); // Start new recording after delay StartCoroutine(StartRecordingDelay(2f)); if (recording == null) { yield break; } Debug.Log("Recording Start Pos: " + recordingStartPos + " Recording Start Rot: " + recordingStartRot); Debug.Log("Num of Frames Rec: " + recording.frames.Count); // Creates the clone Debug.Log(recording.ToString()); curPlayer = Instantiate(GameObject.Find("Player")); curPlayer.GetComponent <PlayerBehaviour>().isClone = true; Destroy(curPlayer.GetComponent <playerTutorial>()); curPlayer.GetComponent <Timeline>().mode = TimelineMode.Global; curPlayer.GetComponent <Timeline>().globalClockKey = "RecordedClones"; curPlayer.transform.Find("Animator").GetComponent <Timeline>().mode = TimelineMode.Global; curPlayer.transform.Find("Animator").GetComponent <Timeline>().globalClockKey = "RecordedClones"; curPlayer.GetComponent <PlayerBehaviour>().ResetRigidBody(); curPlayer.tag = "RecordedPlayer"; curPlayer.transform.Find("Camera").gameObject.SetActive(false); Destroy(curPlayer.transform.Find("InputRecorder").gameObject); GameObject displayName, cloneDigitalCode; displayName = Instantiate(displayNameObject); displayName.transform.SetParent(curPlayer.transform); displayName.transform.rectTransform().localPosition = new Vector3(0, 2.079996f, 0); displayName.name = "DisplayInfoAbove"; Material[] ghostMaterials = new Material[] { ghostMaterial, ghostMaterial, ghostMaterial, ghostMaterial, ghostMaterial, ghostMaterial, ghostMaterial }; curPlayer.transform.FindDeepChild("VBOT_:VBOT_LOD3").transform.parent = curPlayer.transform.Find("Animator"); curPlayer.transform.FindDeepChild("VBOT_:VBOT_LOD3").GetComponent <Renderer>().materials = ghostMaterials; curPlayer.transform.FindDeepChild("VBOT_:VBOT_LOD3").gameObject.AddComponent <Outline>(); curPlayer.transform.FindDeepChild("VBOT_:VBOT_LOD3").name = "PlayerMesh"; Destroy(curPlayer.transform.FindDeepChild("Mesh_LOD").gameObject); cloneDigitalCode = Instantiate(cloneDigitalCodeObject); cloneDigitalCode.transform.SetParent(curPlayer.gameObject.transform.FindDeepChild("PlayerMesh"), false); cloneDigitalCode.name = "DigitalCodeGhostParticles"; // Sets the starting camera rotation float cameraX = playerVCR.gameObject.transform.FindDeepChild("Z").transform.rotation.x; float cameraZ = playerVCR.gameObject.transform.FindDeepChild("Y").transform.rotation.y; curPlayer.gameObject.GetComponent <CameraBehaviour>().SetRotationX(cameraX); curPlayer.gameObject.GetComponent <CameraBehaviour>().SetRotationZ(cameraZ); // Set Health & Energy curPlayer.gameObject.GetComponent <PlayerBehaviour>().life = playerVCR.gameObject.GetComponent <PlayerBehaviour>().life; curPlayer.gameObject.GetComponent <PlayerBehaviour>().energy = playerVCR.gameObject.GetComponent <PlayerBehaviour>().energy; curPlayer.GetComponent <InputVCR>().Play(Recording.ParseRecording(recording.ToString())); recPlayerNum++; curPlayer.name = "RecordedPlayer" + recPlayerNum; curPlayer.GetComponent <InputVCR>().recordingNumber = recPlayerNum; curPlayer.GetComponent <InputVCR>().startPos = recordingStartPos; curPlayer.GetComponent <InputVCR>().startRot = recordingStartRot; displayName.transform.FindDeepChild("RecordingNumber").GetComponent <FaceObject>().SetRecordingText(curPlayer.gameObject.GetComponent <InputVCR>().recordingNumber); CreateCurrentCloneCopy(); float playTime = recording.recordingLength; float curTime = 0f; isPlaying = true; while (curTime < playTime) { if (isPlaying) { curTime += Time.deltaTime; } yield return(0); } }
public string StopRecording() { status = TestStatus.STOP; return(currentRecording.ToString()); }
void LateUpdate() { if (_mode == InputVCRMode.Playback) { // update last frame and this frame // this way, all changes are transmitted, even if a button press lasts less than a frame (like in Input) lastFrameInputs = thisFrameInputs; int lastFrame = currentFrame; currentFrame = currentRecording.GetClosestFrame(playbackTime); if (currentFrame >= currentRecording.totalFrames) { string filePath = Application.persistentDataPath + "/Ghost.txt"; StreamWriter file = new StreamWriter(filePath); //Store recording in to a file file.WriteLine(currentRecording.ToString()); file.Close(); // end of recording if (finishedPlayback != null) { finishedPlayback( ); } Stop(); } else { // go through all changes in recorded input since last frame var changedInputs = new Dictionary <string, InputInfo>(); for (int frame = lastFrame; frame < currentFrame; frame++) { foreach (InputInfo input in currentRecording.GetInputs(frame)) { // thisFrameInputs only updated once per game frame, so all changes, no matter how brief, will be marked // if button has changed if (!thisFrameInputs.ContainsKey(input.inputName) || !thisFrameInputs[input.inputName].Equals(input)) { if (changedInputs.ContainsKey(input.inputName)) { changedInputs[input.inputName] = input; } else { changedInputs.Add(input.inputName, input); } } } if (snapToSyncedLocation) // custom code more effective, but this is enough sometimes { string posString = currentRecording.GetProperty(frame, "position"); if (!string.IsNullOrEmpty(posString)) { transform.position = ParseVector3(posString); } string rotString = currentRecording.GetProperty(frame, "rotation"); if (!string.IsNullOrEmpty(rotString)) { transform.eulerAngles = ParseVector3(rotString); } } } // update input to be used tihs frame foreach (KeyValuePair <string, InputInfo> changedInput in changedInputs) { if (thisFrameInputs.ContainsKey(changedInput.Key)) { thisFrameInputs[changedInput.Key] = changedInput.Value; } else { thisFrameInputs.Add(changedInput.Key, changedInput.Value); } } playbackTime += Time.deltaTime; } } else if (_mode == InputVCRMode.Record) { realRecordingTime += Time.deltaTime; // record current input to frames, until recording catches up with realtime while (currentTime < realRecordingTime) { // mouse position & buttons if required if (recordMouseEvents) { currentRecording.AddProperty(currentFrame, new FrameProperty("mousePos", Input.mousePosition.x.ToString() + "," + Input.mousePosition.y)); for (int i = 0; i < 3; i++) { InputInfo mouseInput = new InputInfo(); mouseInput.inputName = "mousebutton" + i; mouseInput.isAxis = false; mouseInput.mouseButtonNum = i; currentRecording.AddInput(currentFrame, mouseInput); } } // and buttons foreach (InputInfo input in inputsToRecord) { if (input.isAxis) { input.axisValue = Input.GetAxis(input.inputName); } else if (input.mouseButtonNum >= 0) // mouse buttons recorded above { input.buttonState = Input.GetButton(input.inputName); } currentRecording.AddInput(currentFrame, input); } // synced location if (syncRecordLocations && Time.time > nextPosSyncTime) { SyncPosition(); // add position to properties nextPosSyncTime = Time.time + 1f / autoSyncLocationRate; } // and any other properties foreach (FrameProperty prop in nextPropertiesToRecord) { currentRecording.AddProperty(currentFrame, prop); } nextPropertiesToRecord.Clear(); currentFrame++; } } }