public void Apply(SPAnim anim)
 {
     anim.Weight       = this.weight;
     anim.Speed        = this.speed;
     anim.Layer        = this.layer;
     anim.WrapMode     = this.wrapMode;
     anim.BlendMode    = this.blendMode;
     anim.TimeSupplier = this.timeSupplier.TimeSupplier;
 }
 public static AnimSettings From(SPAnim anim)
 {
     return(new AnimSettings()
     {
         weight = anim.Weight,
         speed = anim.Speed,
         layer = anim.Layer,
         wrapMode = anim.WrapMode,
         blendMode = anim.BlendMode,
         timeSupplier = new SPTime(anim.TimeSupplier)
     });
 }
Example #3
0
        private SPAnim CreateAuxiliarySPAnim_Imp(AnimationClip clip)
        {
            string id = "aux*" + clip.GetInstanceID();
            var    a  = _animation[id];

            if (a == null || a.clip != clip)
            {
                _animation.AddClip(clip, id);
            }

            return(SPAnim.Create(_animation, id));
        }
        public SPAnim Clone()
        {
            var a = SPAnim.Create(_controller, _clipId);

            a._weight       = _weight;
            a._speed        = _speed;
            a._layer        = _layer;
            a._wrapMode     = _wrapMode;
            a._blendMode    = _blendMode;
            a._mask         = _mask;
            a._timeSupplier = _timeSupplier;
            return(a);
        }
Example #5
0
        public SPAnim CreateAuxiliarySPAnim(AnimationClip clip, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }

            var id = this.AddAuxiliaryClip(clip, auxId);

            return(SPAnim.Create(_animation, id));
        }
        //***SEE NOTES IN CLASS DESCRIPTION

        //public void SetFrameClamp(int firstFrame, int lastFrame)
        //{
        //    if (_container != null) throw new System.InvalidOperationException("The frame clamp can only be set on a clip that has not been initialized.");

        //    _firstFrame = firstFrame;
        //    _lastFrame = lastFrame;
        //    if (_firstFrame < 0) _firstFrame = 0;
        //    if (_lastFrame < 0) _lastFrame = -1;
        //    else if (_lastFrame < _firstFrame) _lastFrame = _firstFrame + 1;
        //}

        //public void ResetFrameClamp()
        //{
        //    _firstFrame = 0;
        //    _lastFrame = -1;
        //}

        /// <summary>
        /// Creates a state for use in animating.
        /// </summary>
        /// <returns></returns>
        public ISPAnim CreateAnimatableState()
        {
            if (_controller == null)
            {
                throw new System.InvalidOperationException("This clip has not been initialized.");
            }
            if (_controller.ControllerMask != null && !_controller.ControllerMask.CanPlay(this))
            {
                return(null);
            }

            if (_clip is AnimationClip)
            {
                if (_state == null)
                {
                    //this.Dispose();
                    //throw new System.InvalidOperationException("This clip was unexpectedly destroyed, make sure the animation hasn't been destroyed, or another clip was added with the same name.");
                    return(null);
                }

                var a = SPAnim.Create(_controller, _id);
                a.Weight    = _weight;
                a.Speed     = _speed;
                a.Layer     = _layer;
                a.WrapMode  = _wrapMode;
                a.BlendMode = _blendMode;
                a.Mask      = this.Mask;
                if (_timeSupplier.IsCustom)
                {
                    a.TimeSupplier = _timeSupplier.TimeSupplier as ITimeSupplier;
                }
                return(a);
            }
            else if (_clip is IScriptableAnimationClip)
            {
                var a = (_clip as IScriptableAnimationClip).CreateState(_controller) ?? SPAnim.Null;
                a.Speed = _speed;
                a.Layer = _layer;
                if (_timeSupplier.IsCustom)
                {
                    a.TimeSupplier = _timeSupplier.TimeSupplier as ITimeSupplier;
                }
                return(a);
            }

            return(null);
        }
Example #7
0
        public SPAnim CrossFadeAuxiliary(AnimationClip clip, float fadeLength, QueueMode queueMode = QueueMode.PlayNow, PlayMode playMode = PlayMode.StopSameLayer, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }

            var id   = this.AddAuxiliaryClip(clip, auxId);
            var anim = SPAnim.Create(_animation, id);

            anim.CrossFade(fadeLength, queueMode, playMode);
            return(anim);
        }
Example #8
0
        public ISPAnim CrossFadeAuxiliary(SPAnimClip clip, float fadeLength, QueueMode queueMode = QueueMode.PlayNow, PlayMode playMode = PlayMode.StopSameLayer, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }
            if (!_initialized)
            {
                this.Init();
            }

            if (clip.Clip is AnimationClip)
            {
                if (this.ControllerMask != null && !this.ControllerMask.CanPlay(clip))
                {
                    return(null);
                }

                var id   = this.AddAuxiliaryClip(clip.Clip as AnimationClip, auxId);
                var anim = SPAnim.Create(_animation, id);
                anim.Weight       = clip.Weight;
                anim.Speed        = clip.Speed;
                anim.Layer        = clip.Layer;
                anim.WrapMode     = clip.WrapMode;
                anim.BlendMode    = clip.BlendMode;
                anim.TimeSupplier = (clip.TimeSupplier != SPTime.Normal) ? anim.TimeSupplier : null;
                anim.CrossFade(fadeLength, queueMode, playMode);
                return(anim);
            }
            else if (clip.Clip is IScriptableAnimationClip)
            {
                return(this.Play(clip.Clip as IScriptableAnimationClip, playMode));
            }
            else
            {
                return(null);
            }
        }
        public SPAnim PlayAuxiliary(AnimationClip clip, QueueMode queueMode = QueueMode.PlayNow, PlayMode playMode = PlayMode.StopSameLayer, string auxId = null)
        {
            if (_animation == null)
            {
                throw new AnimationInvalidAccessException();
            }
            if (clip == null)
            {
                throw new System.ArgumentNullException("clip");
            }
            if (!_initialized)
            {
                this.Init();
            }

            var id   = this.AddAuxiliaryClip(clip, auxId);
            var anim = SPAnim.Create(_animation, id);

            anim.Play(queueMode, playMode);
            return(anim);
        }