Beispiel #1
0
        public void Update(FrameTime frameTime)
        {
            if (isComplete)
            {
                return;
            }

            time += frameTime.DeltaSeconds;
            if (!storyPath.HasFinished)
            {
                storyPath.Update(frameTime);
                completeTime = Math.Max(1f, time + storyPath.MaxRemainingTime);
            }

            visualProps = storyPath.GetCurrentCameraProps();

            var acceleratingTime = MathHelper.Clamp(completeTime, 0f, 1f);

            if (time < acceleratingTime)
            {
                visualProps = CameraProps.Lerp(initialCameraProps, visualProps, time / acceleratingTime);
            }
            var actualFinalCameraProps = finalCameraProps ?? storyPath.GetCurrentCameraProps();
            var brakingTime            = MathHelper.Clamp(completeTime - acceleratingTime, 0f, 1f);
            var remainingTime          = brakingTime + completeTime - time;

            if (remainingTime < brakingTime)
            {
                visualProps = CameraProps.Lerp(visualProps, actualFinalCameraProps, (brakingTime - remainingTime) / brakingTime);
            }
            if (remainingTime < 0)
            {
                visualProps = actualFinalCameraProps;
                onComplete();
                isComplete = true;
            }
        }
        private CameraProps GetCameraAt(float timestamp)
        {
            var amount = GetLerpAmount(timestamp);

            return(CameraProps.Lerp(StartCameraProps, EndCameraProps, amount));
        }