Exemple #1
0
    private async Task MoveCamera(Vector3 delta)
    {
        moving = true;
        PlayerController.Frozen = true;
        var p0 = camera.transform.position;
        var p1 = p0 + delta;

        dayNightCycle.Advance(3);

        var move = Animations.Animate(CameraTime, Animations.EaseInOutQuadratic);

        while (!move.isComplete)
        {
            if (!Physics.IsEnabled)
            {
                await Util.NextFrame(); continue;
            }
            await move.NextFrame();

            if (this == null)
            {
                return;
            }

            var lastPos = camera.transform.position;
            var nextPos = Vector3.Lerp(p0, p1, move.progress);

            camera.transform.position = nextPos;
            Parallax.parallax?.Invoke(nextPos - lastPos);

            levelScreen.alpha = move.progress;
        }

        PlayerController.Frozen = false;
        moving = false;
    }