Exemple #1
0
    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();
    }
Exemple #2
0
        void Update()
        {
            if (haveAbility)
            {
                if (abilityFirstActivate)
                {
                    StartRecording();
                    abilityFirstActivate = false;
                }

                if (playerVCR.GetRecording() != null)
                {
                    if ((playerVCR.GetRecording().frames.Count / recFPS) < minRewind)
                    {
                        canActivate = false;
                    }
                    else
                    {
                        canActivate = true;
                    }
                }
                else
                {
                    Debug.Log("There is no player recording to access!");
                }

                if (allRecordedClones.Count < maxActiveClones && canActivate)
                {
                    if (hardInput.GetKeyDown("RecordPlayer"))
                    {
                        canDeactivate = false;

                        if (firstPress)
                        {
                            Clock globalClock = Timekeeper.instance.Clock("Root");
                            firstPress     = false;
                            rewindStart    = true;
                            countDownEarly = false;
                            playerVCR.Stop();
                            globalClock.localTimeScale = -1;
                            playerVCR.gameObject.GetComponent <CameraBehaviour>().isActive = false;

                            Debug.Log("Testing - There are " + playerVCR.GetRecording().recordingLength + " recorded! - Activated Start");
                            // Starts the rewinding of the frames
                            InvokeRepeating("RewindToFrame", 0.0f, 1.0f / recFPS);

                            playerVCR.gameObject.GetComponent <PlayerBehaviour>().stopKeyInput = true;
                            playerCamera.gameObject.GetComponent <ChangeCameraEffects>().ChangeFOV(100, 2);
                            playerCamera.gameObject.GetComponent <ChangeCameraEffects>().ChangeGrain(1, 2);
                            AudioManager.instance.Play("Ability_TimeRewind");

                            if (minDelay != null)
                            {
                                StopCoroutine(minDelay);
                            }

                            minDelay = StartCoroutine(MinRewindDelay(minRewind));
                        }
                    }
                    if (hardInput.GetKeyUp("RecordPlayer") && canDeactivate && haveAbility)
                    {
                        canDeactivate = false;

                        if (!triggeredEarly)
                        {
                            RewindStuff();
                        }
                        else
                        {
                            triggeredEarly = false;
                        }
                    }
                    if (!hardInput.GetKey("RecordPlayer") && canDeactivate && haveAbility)
                    {
                        canDeactivate = false;

                        if (!triggeredEarly)
                        {
                            RewindStuff();
                        }
                        else
                        {
                            triggeredEarly = false;
                        }
                    }
                }
                else
                {
                    if (hardInput.GetKeyDown("RecordPlayer"))
                    {
                        AudioManager.instance.Play("Ability_TimeRewindDisabled");

                        // Start new recording, to make sure it doesn't get stuck.
                        Debug.Log("There are " + playerVCR.GetRecording().frames.Count + " frames in current recording!");
                        if (playerVCR.GetRecording().recordingLength < 5)
                        {
                            StartRecording();
                        }
                    }
                }
            }
            else
            {
                if (hardInput.GetKeyDown("RecordPlayer"))
                {
                    AudioManager.instance.Play("Ability_TimeRewindDisabled");
                    Debug.Log("You do not have the ability!");
                }
            }

            // if (hardInput.GetKeyDown("SaveRecordings"))
            // {
            //     SaveRecordingsToFile();
            // }
        }