Example #1
0
 /// <summary>
 /// Immediately finish any transition, and copy current target information
 /// to its equivalent 'old' field
 /// </summary>
 private void FinishTransition()
 {
     oldTarget = target;
     oldTargetPos = targetPos;
     transitionPos = Vector2.Zero;
     transitionRemaining = 0;
 }
Example #2
0
 /// <summary>
 /// Lock the camera onto the specified target.
 /// </summary>
 /// <param name="target">The GameplayObject to follow or "lock on" to</param>
 /// <param name="immediate">If the lock is not immediate, the last transition position is saved and the transition finishes from transition position to the new target</param>
 public void LockTarget(GameObject target, bool immediate)
 {
     if (immediate)
     {
         // End the transition, set the pos as the current vector lock
         FinishTransition();
         mode = CameraMode.LockedTarget;
         this.target = target;
     }
     else
     {
         switch (mode)
         {
             case CameraMode.LockedPos:
                 oldTargetPos = targetPos;
                 break;
             case CameraMode.LockedTarget:
                 oldTargetPos = target.Position;
                 break;
             case CameraMode.TtTTransition:
             case CameraMode.TtVTransition:
             case CameraMode.VtTTransition:
             case CameraMode.VtVTransition:
                 oldTargetPos = transitionPos;
                 break;
         }
         //Complete the transition from its current position
         this.target = target;
         mode = CameraMode.VtTTransition;
     }
     isTransformDirty = true;
 }
Example #3
0
 /// <summary>
 /// Very much like LockTarget(target, immediate) except it allows a specification of duration.
 /// </summary>
 /// <param name="target">The GameplayObject to follow or "lock on" to</param>
 /// <param name="duration">Amount of time for the transition from last target or pos, or transition position (depending on last mode)</param>
 /// <param name="immediate">If the lock is not immediate, the last transition position is saved and the transition finishes from transition position to the new target</param>
 public void TransitionTo(GameObject target, float duration, bool immediate)
 {
     LockTarget(target, immediate);
     if (!immediate)
         transitionRemaining = transitionTime = duration;
 }
Example #4
0
        /// <summary>
        /// Copy Constructor
        /// </summary>
        /// <param name="camera">The camera to copy</param>
        public Camera(Camera camera)
        {
            dt = camera.dt;

            mode = camera.mode;

            oldTarget = camera.oldTarget;
            target = camera.target;
            oldTargetPos = camera.oldTargetPos;
            targetPos = camera.targetPos;

            transitionPos = camera.transitionPos;
            transitionRemaining = camera.transitionRemaining;
            transitionTime = camera.transitionTime;

            lastFramePos = camera.lastFramePos;

            effects = new List<CameraEffect>(camera.effects);

            isTransformDirty = camera.isTransformDirty;
            transformMatrix = camera.transformMatrix;
        }