Пример #1
0
        public FollowNPCThenReturn(NPC npc, float lerpTime, int maxTime, float zoom = 1f)
        {
            _type = npc.type;

            // create the camera controller
            var camera =
                new CameraController(0f, new CameraController.EntityRelativePoint(Main.LocalPlayer, Vector2.Zero)
            {
                Zoom = new Vector2(Main.GameZoomTarget)
            })
                .AddPoint(lerpTime, new CameraController.EntityRelativePoint(npc, Vector2.Zero)
            {
                Zoom = new Vector2(zoom)
            }, EaseFunction.EaseQuadInOut);

            camera.AmICompleted = () =>
            {
                if (_setReturn)
                {
                    return(_currentTime >= lerpTime);
                }

                // the npc is dead or the time exceeds the max time
                if (!npc.active || _type != npc.type || _currentTime > maxTime)
                {
                    _currentTime = 0f;

                    // reset camera and make it a different one, this one set to return to the player
                    CameraController.CameraPointData data = camera.CurrentData;
                    camera.Reset();
                    camera.AddPoint(0, new CameraController.StaticPoint(data), EaseFunction.Linear)
                    .AddPoint(lerpTime, new CameraController.EntityRelativePoint(Main.LocalPlayer, Vector2.Zero)
                    {
                        Zoom = new Vector2(Main.GameZoomTarget)
                    }, EaseFunction.EaseQuadInOut);

                    _setReturn = true;
                }
                return(false);
            };
            AddToQueue(camera);
        }
Пример #2
0
        public FollowProjectileThenReturn(Projectile projectile, float lerpTime, float zoom = 1f)
        {
            _type = projectile.type;

            // create the camera controller
            var camera =
                new CameraController(0f, new CameraController.EntityRelativePoint(Main.LocalPlayer, Vector2.Zero))
                .AddPoint(lerpTime, new CameraController.EntityRelativePoint(projectile, Vector2.Zero)
            {
                Zoom = new Vector2(zoom)
            }, EaseFunction.EaseQuadInOut);

            camera.AmICompleted = () =>
            {
                if (_setReturn)
                {
                    return(_currentTime >= lerpTime);
                }

                // the projectile is dead
                if (!projectile.active || _type != projectile.type)
                {
                    _currentTime = 0f;

                    // reset camera and make it a different one, this one set to return to the player
                    CameraController.CameraPointData data = camera.CurrentData;
                    camera.Reset();
                    camera.AddPoint(0f, new CameraController.StaticPoint(data), EaseFunction.Linear)
                    .AddPoint(lerpTime, new CameraController.EntityRelativePoint(Main.LocalPlayer, Vector2.Zero), EaseFunction.EaseQuadInOut);

                    _setReturn = true;
                }
                return(false);
            };
            AddToQueue(camera);
        }