コード例 #1
0
        public void PlayAnim(UnitAnim unitAnim, float frameRateModModifier, OnAnimComplete onAnimComplete, OnAnimTrigger onAnimTrigger, OnAnimInterrupted onAnimInterrupted)
        {
            if (this.onAnimInterrupted != null)
            {
                OnAnimInterrupted tmpAnimInterrupted = this.onAnimInterrupted;
                this.onAnimInterrupted = null;
                tmpAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                if (OnAnyAnimInterrupted != null)
                {
                    OnAnyAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                }
            }

            this.onAnimComplete    = onAnimComplete;
            this.onAnimTrigger     = onAnimTrigger;
            this.onAnimInterrupted = onAnimInterrupted;

            lastUnitAnim = unitAnim;

            alreadyLooped = false;

            // Dynamic anim
            V_Skeleton_Updater newSkeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);

            newSkeletonUpdater.TestFirstFrameTrigger();
            skeletonUpdater = newSkeletonUpdater;


            if (OnAnyPlayAnim != null)
            {
                OnAnyPlayAnim(unitAnim);
            }
        }
コード例 #2
0
 public bool PlayAnimIfOnCompleteMatches(UnitAnim unitAnim, OnAnimComplete onAnimComplete)
 {
     if (this.onAnimComplete == onAnimComplete)
     {
         // Matches!, Play anim
         PlayAnim(unitAnim, 1f, null, null, null);
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public void Update(float deltaTime)
        {
            V_ISkeleton_Updater activeSkeletonUpdater = skeletonUpdater;
            bool allLooped = skeletonUpdater.Update(deltaTime);

            if (activeSkeletonUpdater != skeletonUpdater)
            {
                // Skeleton Updater changed during update
                return;
            }

            refreshTimer -= deltaTime;
            if (refreshTimer <= 0f)
            {
                refreshTimer = refreshTimerMax;
                skeletonUpdater.Refresh();
            }

            if (allLooped)
            {
                alreadyLooped = true;
            }
            if (allLooped && onAnimComplete != null)
            {
                OnAnimComplete backOnAnimComplete = onAnimComplete;
                onAnimComplete = null;
                backOnAnimComplete(lastUnitAnim);
                if (OnAnyAnimComplete != null)
                {
                    OnAnyAnimComplete(lastUnitAnim);
                }
            }
            else
            {
                //UpdatePlay();
                //Play();
            }
        }
コード例 #4
0
        public void PlayAnimContinueFrames(UnitAnim unitAnim, float frameRateModModifier, OnAnimComplete onAnimComplete, OnAnimTrigger onAnimTrigger, OnAnimInterrupted onAnimInterrupted)
        {
            //Play new anim starting from same frames
            if (this.onAnimInterrupted != null)
            {
                OnAnimInterrupted tmpAnimInterrupted = this.onAnimInterrupted;
                this.onAnimInterrupted = null;
                tmpAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                if (OnAnyAnimInterrupted != null)
                {
                    OnAnyAnimInterrupted(lastUnitAnim, unitAnim, alreadyLooped);
                }
            }

            this.onAnimComplete    = onAnimComplete;
            this.onAnimTrigger     = onAnimTrigger;
            this.onAnimInterrupted = onAnimInterrupted;

            lastUnitAnim = unitAnim;

            alreadyLooped = false;

            // Dynamic anim
            if (skeletonUpdater is V_Skeleton_Updater)
            {
                // Continuing from normal updater
                V_Skeleton_Updater newSkeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
                newSkeletonUpdater.SetFramesToSame((skeletonUpdater as V_Skeleton_Updater).GetAnims());
                skeletonUpdater = newSkeletonUpdater;
            }
            else
            {
                // Previous was cached updater, ignore continue frames
                skeletonUpdater = new V_Skeleton_Updater(mesh, unitAnim.GetAnims(), frameRateMod, frameRateModModifier, onAnimTrigger, OnAnyAnimTrigger);
            }
        }