/**
         * @private
         */
        protected override void _onClear()
        {
            pauseFadeOut  = true;
            fadeOutMode   = AnimationFadeOutMode.All;
            fadeOutTime   = -1.0f;
            fadeOutEasing = 0.0f;

            additiveBlending = false;
            displayControl   = true;
            pauseFadeIn      = true;
            actionEnabled    = true;
            playTimes        = -1;
            layer            = 0;
            position         = 0.0f;
            duration         = -1.0f;
            timeScale        = -100.0f;
            fadeInTime       = -1.0f;
            autoFadeOutTime  = -1.0f;
            fadeInEasing     = 0.0f;
            weight           = 1.0f;
            name             = null;
            animationName    = null;
            group            = null;
            boneMask.Clear();
        }
        public void CopyFrom(AnimationConfig value)
        {
            pauseFadeOut    = value.pauseFadeOut;
            fadeOutMode     = value.fadeOutMode;
            autoFadeOutTime = value.autoFadeOutTime;
            fadeOutEasing   = value.fadeOutEasing;

            additiveBlending = value.additiveBlending;
            displayControl   = value.displayControl;
            pauseFadeIn      = value.pauseFadeIn;
            actionEnabled    = value.actionEnabled;
            playTimes        = value.playTimes;
            layer            = value.layer;
            position         = value.position;
            duration         = value.duration;
            timeScale        = value.timeScale;
            fadeInTime       = value.fadeInTime;
            fadeOutTime      = value.fadeOutTime;
            fadeInEasing     = value.fadeInEasing;
            weight           = value.weight;
            name             = value.name;
            animationName    = value.animationName;
            group            = value.group;

            DragonBones.ResizeList(boneMask, value.boneMask.Count, null);
            for (int i = 0, l = boneMask.Count; i < l; ++i)
            {
                boneMask[i] = value.boneMask[i];
            }
        }
예제 #3
0
        /// <private/>
        public void CopyFrom(AnimationConfig value)
        {
            this.pauseFadeOut     = value.pauseFadeOut;
            this.fadeOutMode      = value.fadeOutMode;
            this.autoFadeOutTime  = value.autoFadeOutTime;
            this.fadeOutTweenType = value.fadeOutTweenType;

            this.actionEnabled    = value.actionEnabled;
            this.additiveBlending = value.additiveBlending;
            this.displayControl   = value.displayControl;
            this.pauseFadeIn      = value.pauseFadeIn;
            this.resetToPose      = value.resetToPose;
            this.playTimes        = value.playTimes;
            this.layer            = value.layer;
            this.position         = value.position;
            this.duration         = value.duration;
            this.timeScale        = value.timeScale;
            this.fadeInTime       = value.fadeInTime;
            this.fadeOutTime      = value.fadeOutTime;
            this.fadeInTweenType  = value.fadeInTweenType;
            this.weight           = value.weight;
            this.name             = value.name;
            this.animation        = value.animation;
            this.group            = value.group;

            boneMask.ResizeList(value.boneMask.Count, null);
            for (int i = 0, l = boneMask.Count; i < l; ++i)
            {
                boneMask[i] = value.boneMask[i];
            }
        }
예제 #4
0
        /// <private/>
        protected override void _OnClear()
        {
            this.pauseFadeOut     = true;
            this.fadeOutMode      = AnimationFadeOutMode.All;
            this.fadeOutTweenType = TweenType.Line;
            this.fadeOutTime      = -1.0f;

            this.actionEnabled    = true;
            this.additiveBlending = false;
            this.displayControl   = true;
            this.pauseFadeIn      = true;
            this.resetToPose      = true;
            this.fadeInTweenType  = TweenType.Line;
            this.playTimes        = -1;
            this.layer            = 0;
            this.position         = 0.0f;
            this.duration         = -1.0f;
            this.timeScale        = -100.0f;
            this.weight           = 1.0f;
            this.fadeInTime       = -1.0f;
            this.autoFadeOutTime  = -1.0f;
            this.name             = "";
            this.animation        = "";
            this.group            = "";
            this.boneMask.Clear();
        }
예제 #5
0
        public void SetAnimation(int index, bool force            = false, int playTimes = -1, float fadeInTime = -1.0f, string group = null,
                                 AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup)
        {
            if (animations == null || animations.Length <= index)
            {
                Debug.LogError("Index no found");
                return;
            }
            string animationName = animations [index];

            if (avatar.animation == null)
            {
                return;
            }
            var state = avatar.animation.GetState(animationName);

            if (state != null && (state.isPlaying && !force))
            {
                return;
            }
            var config = avatar.animation.animationConfig;

            config.playTimes   = playTimes;
            config.resetToPose = false;
            config.animation   = animationName;
            config.layer       = 1;
            config.fadeInTime  = fadeInTime;
            config.group       = group != null ? group : string.Empty;
            config.fadeOutMode = fadeOutMode;
            avatar.animation.PlayConfig(config);
        }
예제 #6
0
        /**
         * @private
         */
        protected void _fadeOut(float fadeOutTime, float layer, string group, AnimationFadeOutMode fadeOutMode, bool pauseFadeOut)
        {
            switch (fadeOutMode)
            {
            case AnimationFadeOutMode.SameLayer:
                foreach (var animationState in _animationStates)
                {
                    if (animationState.layer == layer)
                    {
                        animationState.FadeOut(fadeOutTime, pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.SameGroup:
                foreach (var animationState in _animationStates)
                {
                    if (animationState.group == group)
                    {
                        animationState.FadeOut(fadeOutTime, pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.All:
                foreach (var animationState in _animationStates)
                {
                    animationState.FadeOut(fadeOutTime, pauseFadeOut);
                    if (fadeOutTime == 0.0f)
                    {
                        animationState.ReturnToPool();
                    }
                    else
                    {
                        animationState.FadeOut(fadeOutTime, pauseFadeOut);
                    }
                }

                if (fadeOutTime == 0.0f)
                {
                    _animationStates.Clear();
                }
                break;

            case AnimationFadeOutMode.SameLayerAndGroup:
                foreach (var animationState in _animationStates)
                {
                    if (animationState.layer == layer && animationState.group == group)
                    {
                        animationState.FadeOut(fadeOutTime, pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.None:
            default:
                break;
            }
        }
예제 #7
0
 public void SetAnimation(string name, bool force          = false, int playTimes = -1, float fadeInTime = -1.0f, string group = null,
                          AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup)
 {
     for (int i = 0, animationsLength = animations.Length; i < animationsLength; i++)
     {
         if (animations [i] == name)
         {
             SetAnimation(i, force, playTimes, fadeInTime, group, fadeOutMode);
             return;
         }
     }
 }
예제 #8
0
        /// <summary>
        /// - Fade in a specific animation.
        /// </summary>
        /// <param name="animationName">- The name of animation data.</param>
        /// <param name="fadeInTime">- The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1)</param>
        /// <param name="playTimes">- playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1)</param>
        /// <param name="layer">- The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0)</param>
        /// <param name="group">- The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null)</param>
        /// <param name="fadeOutMode">- The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup)</param>
        /// <returns>The playing animation state.</returns>
        /// <example>
        /// TypeScript style, for reference only.
        /// <pre>
        ///     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
        ///     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
        /// </pre>
        /// </example>
        /// <version>DragonBones 4.5</version>
        /// <language>en_US</language>

        /// <summary>
        /// - 淡入播放指定的动画。
        /// </summary>
        /// <param name="animationName">- 动画数据名称。</param>
        /// <param name="fadeInTime">- 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1)</param>
        /// <param name="playTimes">- 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)</param>
        /// <param name="layer">- 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0)</param>
        /// <param name="group">- 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null)</param>
        /// <param name="fadeOutMode">- 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup)</param>
        /// <returns>播放的动画状态。</returns>
        /// <example>
        /// TypeScript 风格,仅供参考。
        /// <pre>
        ///     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
        ///     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
        /// </pre>
        /// </example>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>
        public AnimationState FadeIn(string animationName, float fadeInTime = -1.0f, int playTimes = -1,
                                     int layer = 0, string group = null,
                                     AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup)
        {
            this._animationConfig.Clear();
            this._animationConfig.fadeOutMode = fadeOutMode;
            this._animationConfig.playTimes   = playTimes;
            this._animationConfig.layer       = layer;
            this._animationConfig.fadeInTime  = fadeInTime;
            this._animationConfig.animation   = animationName;
            this._animationConfig.group       = group != null ? group : "";

            return(this.PlayConfig(this._animationConfig));
        }
예제 #9
0
        /**
         * @language zh_CN
         * 淡入播放动画。
         * @param animationName 动画数据名称。
         * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位)
         * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
         * @param layer 混合图层,图层高会优先获取混合权重。
         * @param group 混合组,用于动画状态编组,方便控制淡出。
         * @param fadeOutMode 淡出模式。
         * @returns 对应的动画状态。
         * @see DragonBones.AnimationFadeOutMode
         * @see DragonBones.AnimationState
         * @version DragonBones 4.5
         */
        public AnimationState FadeIn(
            string animationName, float fadeInTime = -1.0f, int playTimes = -1,
            int layer             = 0, string group = null, AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup,
            bool additiveBlending = false, bool displayControl = true,
            bool pauseFadeOut     = true, bool pauseFadeIn     = true
            )
        {
            _animationConfig.Clear();
            _animationConfig.fadeOutMode   = fadeOutMode;
            _animationConfig.playTimes     = playTimes;
            _animationConfig.layer         = layer;
            _animationConfig.fadeInTime    = fadeInTime;
            _animationConfig.animationName = animationName;
            _animationConfig.group         = group;

            return(PlayConfig(_animationConfig));
        }
        /**
         * @language zh_CN
         * 淡入播放指定名称的动画。
         * @param animationName 动画数据的名称。
         * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次]
         * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位)
         * @param layer 混合的图层,图层高会优先获取混合权重。
         * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。
         * @param fadeOutMode 淡出的模式。
         * @param additiveBlending 以叠加的形式混合。
         * @param displayControl 是否对显示对象属性可控。
         * @param pauseFadeOut 暂停需要淡出的动画。
         * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。
         * @returns 返回控制这个动画数据的动画状态。
         * @see dragonBones.AnimationFadeOutMode
         * @see dragonBones.AnimationState
         * @version DragonBones 4.5
         */
        public AnimationState FadeIn(
            string animationName, float fadeInTime = -1.0f, int playTimes = -1,
            int layer             = 0, string group = null, AnimationFadeOutMode fadeOutMode = AnimationFadeOutMode.SameLayerAndGroup,
            bool additiveBlending = false, bool displayControl = true,
            bool pauseFadeOut     = true, bool pauseFadeIn     = true
            )
        {
            if (!_animations.ContainsKey(animationName))
            {
                _time = 0;
                DragonBones.Warn(
                    "Non-existent animation. " +
                    " DragonBones: " + _armature.armatureData.parent.name +
                    " Armature: " + _armature.name +
                    " Animation: " + animationName
                    );
                return(null);
            }

            var animationData = _animations[animationName];

            if (float.IsNaN(_time))
            {
                _time = 0.0f;
            }

            _isPlaying = true;

            if (fadeInTime < 0.0f || float.IsNaN(fadeInTime))
            {
                if (_lastAnimationState != null)
                {
                    fadeInTime = animationData.fadeInTime;
                }
                else
                {
                    fadeInTime = 0.0f;
                }
            }

            if (playTimes < 0)
            {
                playTimes = (int)animationData.playTimes;
            }

            _fadeOut(fadeInTime, layer, group, fadeOutMode, pauseFadeOut);

            _lastAnimationState                  = BaseObject.BorrowObject <AnimationState>();
            _lastAnimationState._layer           = layer;
            _lastAnimationState._group           = group;
            _lastAnimationState.additiveBlending = additiveBlending;
            _lastAnimationState.displayControl   = displayControl;
            _lastAnimationState._fadeIn(
                _armature, animationData.animation != null ? animationData.animation : animationData, animationName,
                (uint)playTimes, animationData.position, animationData.duration, _time, 1 / animationData.scale, fadeInTime,
                pauseFadeIn
                );
            _animationStates.Add(_lastAnimationState);
            _animationStateDirty = true;
            _time = 0.0f;
            _armature._cacheFrameIndex = -1;

            if (_animationStates.Count > 1)
            {
                _animationStates.Sort(_sortAnimationState);
            }

            foreach (var slot in _armature.GetSlots())
            {
                if (slot.inheritAnimation)
                {
                    var childArmature = slot.childArmature;
                    if (
                        childArmature != null &&
                        childArmature.animation.HasAnimation(animationName) &&
                        childArmature.animation.GetState(animationName) == null
                        )
                    {
                        childArmature.animation.FadeIn(animationName);
                    }
                }
            }

            if (fadeInTime <= 0.0f)
            {
                _armature.AdvanceTime(0.0f); // Blend animation state, update armature. (pass actions and events)
            }

            return(_lastAnimationState);
        }