Esempio n. 1
0
        private void FireAnimationEvents(IMeshAnimation meshAnimation, float totalSpeed, bool finished)
        {
            MeshAnimationBase baseAnimation = meshAnimation as MeshAnimationBase;

            if (baseAnimation.events.Length > 0 && eventReciever != null && previousEventFrame != currentFrame)
            {
                if (finished)
                {
                    if (totalSpeed < 0)
                    {
                        // fire off animation events, including skipped frames
                        for (int i = previousEventFrame; i >= 0; i++)
                        {
                            meshAnimation.FireEvents(eventReciever, i);
                        }
                        previousEventFrame = 0;
                    }
                    else
                    {
                        // fire off animation events, including skipped frames
                        int totalFrames = meshAnimation.TotalFrames;
                        for (int i = previousEventFrame; i <= totalFrames; i++)
                        {
                            meshAnimation.FireEvents(eventReciever, i);
                        }
                        previousEventFrame = -1;
                    }
                    return;
                }
                else
                {
                    if (totalSpeed < 0)
                    {
                        // fire off animation events, including skipped frames
                        for (int i = currentFrame; i > previousEventFrame; i--)
                        {
                            meshAnimation.FireEvents(eventReciever, i);
                        }
                    }
                    else
                    {
                        // fire off animation events, including skipped frames
                        for (int i = previousEventFrame + 1; i <= currentFrame; i++)
                        {
                            meshAnimation.FireEvents(eventReciever, i);
                        }
                    }
                    previousEventFrame = currentFrame;
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Play an animation by index
 /// </summary>
 /// <param name="index">Index of the animation</param>
 public void Play(int index)
 {
     if (index < 0 || animations.Length <= index || currentAnimIndex == index)
     {
         return;
     }
     if (queuedAnims != null)
     {
         queuedAnims.Clear();
     }
     currentAnimIndex   = index;
     currentAnimation   = animations[currentAnimIndex] as MeshAnimationBase;
     currentFrame       = 0;
     currentAnimTime    = 0;
     previousEventFrame = -1;
     pingPong           = false;
     isPaused           = false;
     nextTick           = Time.time;
     OnCurrentAnimationChanged(currentAnimation);
 }