Ejemplo n.º 1
0
        public void SeekReplayHighlightsNormalized(float normalizedOffset)
        {
            if (isReplayingHighlights == true)
            {
                float totalDuration = 0;

                for (int i = 0; i < highlightsStorage.Count; i++)
                {
                    totalDuration += highlightsStorage[i].Duration;
                }

                float targetTime = Mathf.Lerp(0, totalDuration, Mathf.Clamp01(normalizedOffset));

                for (int i = 0; i < highlightsStorage.Count; i++)
                {
                    if (targetTime < highlightsStorage[i].Duration)
                    {
                        ReplayManager.StopPlayback(ref replayHighlightHandle);
                        replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[i]);
                        ReplayManager.SetPlaybackTime(replayHighlightHandle, targetTime);
                        break;
                    }

                    targetTime -= highlightsStorage[i].Duration;
                }
            }
        }
        // Methods
        public IEnumerator Start()
        {
            // Create a record scene for the record object
            ReplayScene recordScene = new ReplayScene(recordObject);

            // Start recording the single object
            ReplayHandle recordHandle = ReplayManager.BeginRecording(null, recordScene);

            // Allow some data to be recorded for 1 second
            yield return(new WaitForSeconds(1f));

            // Stop recording
            ReplayManager.StopRecording(ref recordHandle);


            // Clone the identity which allows the replayObject to be replayed as the recordObject
            ReplayObject.CloneReplayObjectIdentity(recordObject, replayObject);


            // Create a playback scene for the replay object
            ReplayScene playbackScene = new ReplayScene(replayObject);

            // Start playback
            ReplayManager.BeginPlayback(null, playbackScene);
        }
Ejemplo n.º 3
0
        // Methods
        public void Start()
        {
            // Load an existing replay file from the specified file path
            ReplayFileTarget replayFile = ReplayFileTarget.ReadReplayFile("C:/ReplayFiles/Example.replay");

            // Start replaying
            ReplayManager.BeginPlayback(replayFile);
        }
Ejemplo n.º 4
0
        public void Start()
        {
            // This example assumes that this stream already has valid replay data stored within it.
            // This could be any stream that supports reading, seeking and getting Position.
            MemoryStream stream = new MemoryStream();


            // Create a replay stream target for the specified stream object
            ReplayStreamTarget replayStream = ReplayStreamTarget.CreateReplayStream(stream);

            // Start replaying from the stream
            ReplayHandle playbackHandle = ReplayManager.BeginPlayback(replayStream);
        }
Ejemplo n.º 5
0
        public void ReplayHighlights()
        {
            if (replayHighlightIndex >= 0 && replayHighlightIndex < highlightsStorage.Count)
            {
                isReplayingHighlights = true;
                replayHighlightIndex  = 0;

                // Start replaying highlights
                replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[replayHighlightIndex]);

                // Add listener for playback finished
                ReplayManager.AddPlaybackEndListener(replayHighlightHandle, OnHighlightPlaybackFinished);
            }
        }
Ejemplo n.º 6
0
    /// <summary>
    /// playback an old recording
    /// </summary>
    /// <param name="name"></param>
    public void SelectandStartReplay(string name)
    {
        //check for valid name
        if (!RecordingDictionaryClass.RecordingDictionary.ContainsKey(name))
        {
            Debug.Log("name dose not exist");
            return;
        }

        string replayname;
        string replayAudio;
        string data = RecordingDictionaryClass.RecordingDictionary[name];

        string[] Data = data.Split(',');
        replayname  = Data[0];
        replayAudio = Data[1];
        Debug.Log(replayAudio);
        AudioClip clip = Resources.Load <AudioClip>(name);

        Debug.Log(clip);
        AudioSource.clip = clip;
        // Get the active record target from the replay manager

        ReplayFileTarget target = ReplayManager.Target as ReplayFileTarget;



        // Set the location/name of the replay file to load

        if (!replayname.EndsWith(".replay"))
        {
            replayname += ".replay";
        }
        Debug.Log(name);
        target.FileOutputName = replayname;



        // Begin playback as normal and the file will be loaded

        ReplayManager.BeginPlayback();
        AudioSource.Play();

        // Instantiate(replayprefab);
    }
        public void PlayKillcam()
        {
            // Stop recording
            if (ReplayManager.IsRecording(killcamHandle) == true)
            {
                ReplayManager.StopRecording(ref killcamHandle);
            }

            // Start replaying
            killcamHandle = ReplayManager.BeginPlayback(killcamStorage);
            isReplaying   = true;

            // Activate camera
            killcamViewCamera.enabled = true;
            killcamViewCanvas.gameObject.SetActive(true);
            killcamViewCamera.GetComponent <AudioListener>().enabled = true;

            ReplayManager.AddPlaybackEndListener(killcamHandle, OnKillcamEnd);
        }
Ejemplo n.º 8
0
        // Methods
        public IEnumerator Start()
        {
            ReplayMemoryTarget storage = new ReplayMemoryTarget();

            // Record as normal
            ReplayHandle handle = ReplayManager.BeginRecording(storage);

            // Allow recording to run for 1 second
            yield return(new WaitForSeconds(1f));

            // Stop recording
            // We need to pass the handle to the recording as a reference which will cause the handle to become invalid
            ReplayManager.StopRecording(ref handle);


            // Begin playback of the recording that we captured in the storage target
            // Again this method will return a replay handle that is required for many other playback operations
            playbackHandle = ReplayManager.BeginPlayback(storage);
        }
Ejemplo n.º 9
0
        private void OnHighlightPlaybackFinished()
        {
            // Increase storage index
            replayHighlightIndex++;

            if (replayHighlightIndex >= 0 && replayHighlightIndex < highlightsStorage.Count)
            {
                // Start replaying highlights
                replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[replayHighlightIndex]);

                // Add listener for playback finished
                ReplayManager.AddPlaybackEndListener(replayHighlightHandle, OnHighlightPlaybackFinished);
            }
            else
            {
                isReplayingHighlights = false;
                replayHighlightIndex  = 0;
                replayHighlightHandle = ReplayHandle.invalid;
            }
        }
Ejemplo n.º 10
0
    public void LevelComplete()
    {
        Replaying = true;
        var x = GameObject.FindGameObjectsWithTag("Enemy");


        ReplayManager.StopRecording();
        ReplayManager.BeginPlayback();
        Time.timeScale = 2;
        TimeManager.Instance.ResetTimers();
        mc.gameObject.SetActive(true);
        mc.img.gameObject.SetActive(false);
        mc.start.text = "PRESS BUTTON TO START";
        if (currentLevel != 3)
        {
            mc.start.text += "\nLEVEL " + (currentLevel + 1);
        }

        StartCoroutine(WaitForReplayFinish());
        //todo: display gameover screen;
        //Started = false;
        //SceneManager.LoadScene(0);
    }
Ejemplo n.º 11
0
        public void OnTriggerEnter(Collider other)
        {
            Debug.LogWarning("Trigger");

            // Stop replaying
            if (ReplayManager.IsReplaying(playbackHandle) == true)
            {
                ReplayManager.StopPlayback(ref playbackHandle);
            }

            // Stop recording
            if (ReplayManager.IsRecording(recordHandle) == true)
            {
                // Stop recording
                ReplayManager.StopRecording(ref recordHandle);

                playbackStorage = recordStorage;
                recordStorage   = new ReplayMemoryTarget();

                Debug.Log("Recording Length: " + playbackStorage.Duration);

                // Enable the ghost car
                ghostCar.gameObject.SetActive(true);

                // Clone identities - This allows the ghost car to be replayed as the player car
                ReplayObject.CloneReplayObjectIdentity(playerCar, ghostCar);

                // Start replaying
                playbackHandle = ReplayManager.BeginPlayback(playbackStorage, playbackScene);

                // Add end playback listener
                ReplayManager.AddPlaybackEndListener(playbackHandle, OnGhostVehiclePlaybackComplete);
            }

            // Start recording
            recordHandle = ReplayManager.BeginRecording(recordStorage, recordScene);
        }
 public void StartPlayback()
 {
     ReplayManager.BeginPlayback();
 }