Beispiel #1
0
    void Update()
    {
        if (currentState == RecorderState.Replaying)
        {
            replayTimeText.text = "Replay started: " + playbackStartTime + ", current game time: " + Time.realtimeSinceStartup.ToString();

            if (nextEventAlreadyServiced)
            {
                if (!currentFlythrough.NothingToReplay())
                {
                    var e = currentFlythrough.GetNextEvent();
                    nextEvent                = e.triggeredEvent;
                    nextEventTime            = e.triggerTime;
                    nextEventAlreadyServiced = false;
                    nextEventMousePos        = e.triggeredEvent.mousePosition;
                    nextEventCameraPos       = e.cameraPosition;
                    nextEventCameraRot       = e.cameraRotation;
                }
                else
                {
                    StopReplaying();
                    return;
                }
            }

            NewSelectionManager.Instance.MousePosition = nextEventMousePos;
            replayTimeText.text += ", nextEventTime = " + nextEventTime;

            if (Time.realtimeSinceStartup >= playbackStartTime + nextEventTime)
            {
                var triggeredTime = Time.realtimeSinceStartup - playbackStartTime;
                eventsTriggeredTimes.Add(triggeredTime);
                var eventTriggeredDelay = triggeredTime - nextEventTime;
                //NewSelectionManager.Instance.MousePosition =
                //CameraController.ProcessEvent(nextEvent, eventTriggeredDelay);

                // might look like shit but we'll see
                CameraController.transform.position            = nextEventCameraPos;
                CameraController.transform.rotation            = nextEventCameraRot;
                CameraController.MainCamera.transform.position = nextEventCameraPos;
                CameraController.MainCamera.transform.rotation = nextEventCameraRot;

                CameraController.ProcessEvent(nextEvent);
                nextEventAlreadyServiced = true;
            }
        }
    }