Ejemplo n.º 1
0
 public void PlayAnim(NAnimation anim)
 {
     if (currentAnimPlaying != null)
     {
         StopCoroutine(currentAnimPlaying);
     }
     currentAnimPlaying = StartCoroutine(Play(anim));
 }
Ejemplo n.º 2
0
 public static void Release(NAnimation animation)
 {
     if (animation == null)
     {
         return;
     }
     animation.target.ClearValue();
     pool.Enqueue(animation);
 }
Ejemplo n.º 3
0
    private IEnumerator Play(NAnimation anim)
    {
        int frameIndex     = 0;
        int loopsRemaining = anim.loopCount;

        if (!anim.events.callStartEveryLoop)
        {
            anim.events.OnStart.Invoke();
        }

        while (anim.frames.Length > 0)
        {
            while (WorldControl.IsPaused)
            {
                yield return(null);
            }
            if (anim.events.callStartEveryLoop)
            {
                anim.events.OnStart.Invoke();
            }

            SetAnimSprite(anim.frames[frameIndex]);
            anim.CallEvents(frameIndex);

            yield return(StartCoroutine(WorldControl.PauseableWait(1f / anim.framerate)));

            if (frameIndex == anim.frames.Length - 1)               // end of the animation?
            {
                if (anim.events.callFinishEveryLoop)
                {
                    anim.events.OnFinish.Invoke();
                }

                if (!anim.lööp || loopsRemaining <= 0 && anim.loopCount != 0)
                {
                    break;
                }
                else if (anim.loopCount != 0)
                {
                    loopsRemaining--;
                }
            }
            frameIndex = (frameIndex + 1) % anim.frames.Length;
        }

        if (!anim.events.callFinishEveryLoop)
        {
            anim.events.OnFinish.Invoke();
        }

        currentAnimPlaying = null;
        if (anim.nextAnim != "")
        {
            PlayAnim(anim.nextAnim);
        }
    }
Ejemplo n.º 4
0
 public void PlayAnim(string name)
 {
     if (animations.ContainsKey(name))
     {
         NAnimation a = animations[name];
         animIndex = a.index;
         if (currentAnimPlaying != null)
         {
             StopCoroutine(currentAnimPlaying);
         }
         currentAnimPlaying = StartCoroutine(Play(a));
     }
     else if (showWarnings)
     {
         Debug.LogError($"Can't play {name} cause its not in the list of anims");
     }
 }