예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SceneObject"/> class.
        /// </summary>
        protected SceneObject()
        {
            m_targetDetailLevel = DetailLevel.All;

            m_children = new List <SceneObject>();
            m_parent   = null;

            m_behaviors        = new List <SceneObjectBehavior>();
            m_animationHandler = new AnimationHandler(this);
            m_visibilityData   = new IndexBasedDynamicCollection <VisibilityCheckData>();

            //Create a dynamic container for custom data
            m_customData = new ExpandoObject();

            this.TransormationChanged = true;
            this.IsPickingTestVisible = true;
        }
예제 #2
0
 /// <summary>
 /// Builds a lazy animation object using the given child sequence.
 /// </summary>
 /// <param name="builder">The AnimationSequenceBuilder object.</param>
 /// <param name="childSequenceBuilder">A SequenceBuilder building a child sequence.</param>
 public static IAnimationSequenceBuilder <ObjectType> Lazy <ObjectType>(this IAnimationSequenceBuilder <ObjectType> builder, Action <IAnimationSequenceBuilder <ObjectType> > childSequenceBuilder)
     where ObjectType : class
 {
     return(builder.Lazy(() =>
     {
         AnimationHandler result = new AnimationHandler(builder.AnimationHandler.Owner);
         IAnimationSequenceBuilder <ObjectType> childBuilder = new AnimationSequenceBuilder <ObjectType>(result);
         childSequenceBuilder(childBuilder);
         if ((childBuilder.ItemCount == 0) && (!childBuilder.Applied))
         {
             childBuilder.Apply();
         }
         if (!childBuilder.Applied)
         {
             throw new InvalidOperationException("Child sequence was not correctly applied (call to Apply is missing!)");
         }
         return result;
     }));
 }
예제 #3
0
        /// <summary>
        /// Updates all animations within the given animation queue.
        /// Returns true if any animation was finished or canceled.
        /// </summary>
        /// <param name="updateState">Current update state.</param>
        /// <param name="animationState">Current animation state.</param>
        /// <param name="animationQueue">The queue which should be updated.</param>
        private bool UpdateQueueInternal(IAnimationUpdateState updateState, AnimationState animationState, Queue <IAnimation> animationQueue)
        {
            bool           anyFinishedOrCanceled = false;
            AnimationState animationStateInner   = new AnimationState();
            int            actIndex   = 0;
            TimeSpan       actMaxTime = TimeSpan.Zero;

            // Loop over all animations and update them till next blocking animation
            foreach (IAnimation actAnimation in animationQueue)
            {
                if (actAnimation.Canceled)
                {
                    continue;
                }
                if (actAnimation.Finished)
                {
                    continue;
                }

                try
                {
                    animationStateInner.RunningAnimationsIndex = actIndex;
                    actIndex++;

                    // Call update of the animation
                    updateState.IgnorePauseState = actAnimation.IgnorePauseState;
                    actAnimation.Update(updateState, animationStateInner);

                    // Decrement current animation index if the current one is finished now
                    if (actAnimation.Finished || actAnimation.Canceled)
                    {
                        actIndex--;
                        anyFinishedOrCanceled = true;
                    }

                    // Break on blocking animations
                    if (actAnimation.IsBlockingAnimation)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    //Log error
                    AnimationHandler animHandler = this as AnimationHandler;

                    // Raise the animation failed event
                    AnimationFailed.Raise(this, new AnimationFailedEventArgs(actAnimation, ex));

                    //Query for reaction
                    AnimationFailedReaction reaction = OnAnimationFailed(actAnimation, ex);
                    switch (reaction)
                    {
                    case AnimationFailedReaction.ThrowException:
                        throw;

                    //Remove the animation and
                    case AnimationFailedReaction.RemoveAndContinue:
                        actAnimation.Canceled = true;
                        anyFinishedOrCanceled = true;
                        break;
                    }
                }
            }

            return(anyFinishedOrCanceled);
        }
 /// <summary>
 /// Initializes a new instance of the AnimationSequenceBuilder class.
 /// </summary>
 /// <param name="owner">The owner object.</param>
 /// <param name="animatedObject">The object which gets animated.</param>
 /// <exception cref="System.ArgumentException">Unable to cast target object of this AnimationSequenceBuilder to the generic type parameter!</exception>
 internal AnimationSequenceBuilder(AnimationHandler owner, TargetType animatedObject)
     : this()
 {
     m_ownerAnimationHandler = owner;
     m_animatedObject        = animatedObject;
 }
 /// <summary>
 /// Initializes a new instance of the AnimationSequenceBuilder class.
 /// </summary>
 /// <param name="owner">The owner object.</param>
 /// <exception cref="System.ArgumentException">Unable to cast target object of this AnimationSequenceBuilder to the generic type parameter!</exception>
 internal AnimationSequenceBuilder(AnimationHandler owner)
     : this()
 {
     m_ownerAnimationHandler = owner;
     m_animatedObject        = owner.Owner as TargetType;
 }