コード例 #1
0
        protected void UpdateBaseAnimation( string animationBaseName, bool allowRandomAnimationNumber,
            bool loop, float velocity)
        {
            if( forceAnimationRemainingTime != 0 )
                Log.Fatal( "Dynamic: UpdateBaseAnimation: forceAnimationRemainingTime != 0." );

            if( currentAnimationItem != null )
            {
                if (currentAnimationItem.Loop == true)
                {
                     // The new animation is different from the last animations
                     if(currentAnimationItem.Removed ||
                        currentAnimationItem.AnimationBaseName != animationBaseName ||
                        currentAnimationItem.AllowRandomAnimationNumber != allowRandomAnimationNumber ||
                        currentAnimationItem.Loop != loop)
                    {
                        animationController.Remove(currentAnimationItem);
                        currentAnimationItem = null;
                    }
                }
                else
                {
                    if (// The new animation is different from the last animations
                        (currentAnimationItem.Removed ||
                        currentAnimationItem.AnimationBaseName != animationBaseName ||
                        currentAnimationItem.AllowRandomAnimationNumber != allowRandomAnimationNumber ||
                        currentAnimationItem.Loop != loop) &&
                        // and the animation has stopped playing
                        currentAnimationItem.TimePosition == currentAnimationItem.Length)
                    {
                        animationController.Remove(currentAnimationItem);
                        currentAnimationItem = null;
                    }
                }
            }

            if( currentAnimationItem == null )
            {
                currentAnimationItem = animationController.Add( animationBaseName,
                    allowRandomAnimationNumber, loop );

                if (currentAnimationItem != null)
                    currentAnimationItem.Velocity = velocity;
            }
        }
コード例 #2
0
        protected override void OnRenderFrame()
        {
            base.OnRenderFrame();

            if( EntitySystemWorld.Instance.IsClientOnly() )
            {
                if( Type.NetworkType == EntityNetworkTypes.Synchronized )
                    Client_UpdatePositionsBySnapshots( true );
            }

            //animation management
            if( animationController != null )
            {
                if( EntitySystemWorld.Instance.Simulation &&
                    !EntitySystemWorld.Instance.SystemPauseOfSimulation )
                {
                    animationController.DoRenderFrame();

                    if( currentAnimationItem != null && currentAnimationItem.Removed )
                        currentAnimationItem = null;
                    if( forceAnimationRemainingTime != 0 && currentAnimationItem == null )
                        forceAnimationRemainingTime = 0;

                    if( forceAnimationRemainingTime == 0 )
                        OnUpdateBaseAnimation();
                }
            }
        }
コード例 #3
0
        public void SetForceAnimation( string animationBaseName, bool allowRandomAnimationNumber )
        {
            //!!!!!should to disable animation for disabled renderer

            if( animationController == null )
                return;

            //remove old animation
            if( currentAnimationItem != null )
            {
                animationController.Remove( currentAnimationItem );
                currentAnimationItem = null;
            }
            forceAnimationRemainingTime = 0;

            //activate new animation
            currentAnimationItem = animationController.Add( animationBaseName,
                allowRandomAnimationNumber, false );
            if( currentAnimationItem != null )
                forceAnimationRemainingTime = currentAnimationItem.Length;
        }
コード例 #4
0
 public bool CurrentAnimationIsEnabled()
 {
     if( currentAnimationItem != null && currentAnimationItem.Removed )
         currentAnimationItem = null;
     return currentAnimationItem != null;
 }
コード例 #5
0
        void LoadAnimationState( TextBlock block )
        {
            TextBlock itemBlock = block.FindChild( "currentAnimationItem" );
            if( itemBlock != null )
            {
                string animationBaseName =
                    itemBlock.GetAttribute( "animationBaseName" );
                bool allowRandomAnimationNumber = bool.Parse(
                    itemBlock.GetAttribute( "allowRandomAnimationNumber", "true" ) );
                bool loop = bool.Parse( itemBlock.GetAttribute( "loop", "true" ) );

                currentAnimationItem = animationController.Add( animationBaseName,
                    allowRandomAnimationNumber, loop );
                if( currentAnimationItem != null )
                {
                    MeshObjectAnimationController.AnimationItem item = currentAnimationItem;

                    if( itemBlock.IsAttributeExist( "velocity" ) )
                        item.Velocity = float.Parse( itemBlock.GetAttribute( "velocity" ) );
                    if( itemBlock.IsAttributeExist( "weight" ) )
                        item.Weight = float.Parse( itemBlock.GetAttribute( "weight" ) );
                    if( itemBlock.IsAttributeExist( "timePosition" ) )
                        item.TimePosition = float.Parse( itemBlock.GetAttribute( "timePosition" ) );
                }
            }

            if( block.IsAttributeExist( "forceAnimationRemainingTime" ) )
            {
                forceAnimationRemainingTime = float.Parse(
                    block.GetAttribute( "forceAnimationRemainingTime" ) );
            }
        }
コード例 #6
0
ファイル: Dynamic.cs プロジェクト: CITS4242B2010/project2010
        protected void UpdateBaseAnimation( string animationBaseName, bool allowRandomAnimationNumber,
			bool loop, float velocity )
        {
            if( forceAnimationRemainingTime != 0 )
                Log.Fatal( "Dynamic: UpdateBaseAnimation: forceAnimationRemainingTime != 0." );

            if( currentAnimationItem != null )
            {
                if( currentAnimationItem.Removed ||
                    currentAnimationItem.AnimationBaseName != animationBaseName ||
                    currentAnimationItem.AllowRandomAnimationNumber != allowRandomAnimationNumber ||
                    currentAnimationItem.Loop != loop )
                {
                    animationController.Remove( currentAnimationItem );
                    currentAnimationItem = null;
                }
            }

            if( currentAnimationItem == null )
            {
                currentAnimationItem = animationController.Add( animationBaseName,
                    allowRandomAnimationNumber, loop );
            }

            if( currentAnimationItem != null )
                currentAnimationItem.Velocity = velocity;
        }