Esempio n. 1
0
        public static bool TestAnimComplete(ISPAnim anim)
        {
            if (anim == null)
            {
                throw new System.ArgumentNullException("anim");
            }

            if (!anim.IsPlaying)
            {
                return(true);
            }

            var a = anim as SPAnim;

            if (a != null)
            {
                if (a.Controller == null || !a.Controller.isActiveAndEnabled)
                {
                    return(true);
                }

                switch (a.WrapMode)
                {
                case WrapMode.Default:
                case WrapMode.Once:
                    return(Time.time > (a.StartTime + a.ScaledDuration));

                case WrapMode.Loop:
                case WrapMode.PingPong:
                case WrapMode.ClampForever:
                default:
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
        public override bool Trigger(object sender, object arg)
        {
            if (!this.CanTrigger)
            {
                return(false);
            }

            var anim = _targetAnimator.GetTarget <ISPAnimationSource>(arg);

            if (anim == null || !anim.CanPlayAnim)
            {
                return(false);
            }

            var id = _clipIDs.PickRandom();

            _currentAnimState = anim.GetAnim(id);
            if (_currentAnimState == null)
            {
                //this.Invoke(() => { this.OnAnimCompleteCallback(null); }, 0f);
                if (_triggerCompleteIfNoAnim)
                {
                    this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f);
                }
                return(false);
            }

            _currentAnimState.TimeSupplier = _timeSupplier.TimeSupplier;
            _currentAnimState.Play(_speed, _startTime, QueueMode.PlayNow, _playMode);
            _currentAnimState.Schedule((s) =>
            {
                _currentAnimState = null;
                _onAnimComplete.ActivateTrigger(this, arg);
            });

            return(true);
        }
Esempio n. 3
0
 internal StateData(LinearAnimationBlend owner, ISPAnim anim, float pos)
 {
     _owner = owner;
     _anim  = anim;
     _pos   = pos;
 }