Ejemplo n.º 1
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];
            }
        }
        /// <private/>
        protected override void _OnClear()
        {
            foreach (var animationState in this._animationStates)
            {
                animationState.ReturnToPool();
            }

            if (this._animationConfig != null)
            {
                this._animationConfig.ReturnToPool();
            }

            this.timeScale = 1.0f;

            this._lockUpdate = false;

            this._animationDirty   = false;
            this._inheritTimeScale = 1.0f;
            this._animationNames.Clear();
            this._animationStates.Clear();
            this._animations.Clear();
            this._armature           = null; //
            this._animationConfig    = null; //
            this._lastAnimationState = null;
        }
        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];
            }
        }
Ejemplo n.º 4
0
        /**
         * @private
         */
        override protected void _onClear()
        {
            foreach (var animationState in _animationStates)
            {
                animationState.ReturnToPool();
            }

            if (_animationConfig != null)
            {
                _animationConfig.ReturnToPool();
            }

            timeScale = 1.0f;

            _isPlaying           = false;
            _animationStateDirty = false;
            _timelineStateDirty  = false;
            _cacheFrameIndex     = -1;
            _animationNames.Clear();
            _animations.Clear();
            _animationStates.Clear();
            _armature           = null;
            _lastAnimationState = null;
            _animationConfig    = null;
        }
Ejemplo n.º 5
0
        /// <internal/>
        /// <private/>
        internal void Init(Armature armature)
        {
            if (this._armature != null)
            {
                return;
            }

            this._armature        = armature;
            this._animationConfig = BaseObject.BorrowObject <AnimationConfig>();
        }
Ejemplo n.º 6
0
        /**
         * @private
         */
        internal void _init(Armature armature)
        {
            if (_armature != null)
            {
                return;
            }

            _armature        = armature;
            _animationConfig = BaseObject.BorrowObject <AnimationConfig>();
        }
Ejemplo n.º 7
0
        private void _fadeOut(AnimationConfig animationConfig)
        {
            int            i = 0, l = _animationStates.Count;
            AnimationState animationState = null;

            switch (animationConfig.fadeOutMode)
            {
            case AnimationFadeOutMode.SameLayer:
                for (; i < l; ++i)
                {
                    animationState = _animationStates[i];
                    if (animationState.layer == animationConfig.layer)
                    {
                        animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.SameGroup:
                for (; i < l; ++i)
                {
                    animationState = _animationStates[i];
                    if (animationState.group == animationConfig.group)
                    {
                        animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.SameLayerAndGroup:
                for (; i < l; ++i)
                {
                    animationState = _animationStates[i];
                    if (animationState.layer == animationConfig.layer &&
                        animationState.group == animationConfig.group
                        )
                    {
                        animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                    }
                }
                break;

            case AnimationFadeOutMode.All:
                for (; i < l; ++i)
                {
                    animationState = _animationStates[i];
                    animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                }
                break;

            case AnimationFadeOutMode.None:
            default:
                break;
            }
        }
        protected override void _onClear()
        {
            if (animationConfig != null)
            {
                animationConfig.ReturnToPool();
            }

            type            = ActionType.Play;
            bone            = null;
            slot            = null;
            animationConfig = null;
        }
 static int Clear(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)ToLua.CheckObject(L, 1, typeof(DragonBones.AnimationConfig));
         obj.Clear();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 10
0
        private void _FadeOut(AnimationConfig animationConfig)
        {
            switch (animationConfig.fadeOutMode)
            {
            case AnimationFadeOutMode.SameLayer:
                foreach (var animationState in this._animationStates)
                {
                    if (animationState.layer == animationConfig.layer)
                    {
                        animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                    }
                }
                break;

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

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

            case AnimationFadeOutMode.All:
                foreach (var animationState in this._animationStates)
                {
                    animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut);
                }
                break;

            case AnimationFadeOutMode.None:
            case AnimationFadeOutMode.Single:
            default:
                break;
            }
        }
 static int ContainsBoneMask(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)ToLua.CheckObject(L, 1, typeof(DragonBones.AnimationConfig));
         string arg0 = ToLua.CheckString(L, 2);
         bool   o    = obj.ContainsBoneMask(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 12
0
 static int PlayConfig(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Animation       obj  = (DragonBones.Animation)ToLua.CheckObject <DragonBones.Animation>(L, 1);
         DragonBones.AnimationConfig arg0 = (DragonBones.AnimationConfig)ToLua.CheckObject <DragonBones.AnimationConfig>(L, 2);
         DragonBones.AnimationState  o    = obj.PlayConfig(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_boneMask(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            System.Collections.Generic.List <string> ret = obj.boneMask;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index boneMask on a nil value" : e.Message));
        }
    }
    static int set_group(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.group = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index group on a nil value" : e.Message));
        }
    }
    static int set_weight(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.weight = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index weight on a nil value" : e.Message));
        }
    }
    static int get_group(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            string ret = obj.group;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index group on a nil value" : e.Message));
        }
    }
Ejemplo n.º 17
0
    static int get_animationConfig(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.Animation       obj = (DragonBones.Animation)o;
            DragonBones.AnimationConfig ret = obj.animationConfig;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index animationConfig on a nil value"));
        }
    }
Ejemplo n.º 18
0
    static int set_animationConfig(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.ActionData      obj  = (DragonBones.ActionData)o;
            DragonBones.AnimationConfig arg0 = (DragonBones.AnimationConfig)ToLua.CheckObject(L, 2, typeof(DragonBones.AnimationConfig));
            obj.animationConfig = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index animationConfig on a nil value" : e.Message));
        }
    }
    static int set_fadeOutMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig      obj  = (DragonBones.AnimationConfig)o;
            DragonBones.AnimationFadeOutMode arg0 = (DragonBones.AnimationFadeOutMode)ToLua.CheckObject(L, 2, typeof(DragonBones.AnimationFadeOutMode));
            obj.fadeOutMode = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fadeOutMode on a nil value" : e.Message));
        }
    }
    static int get_actionEnabled(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            bool ret = obj.actionEnabled;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index actionEnabled on a nil value" : e.Message));
        }
    }
 static int RemoveBoneMask(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         DragonBones.AnimationConfig obj  = (DragonBones.AnimationConfig)ToLua.CheckObject(L, 1, typeof(DragonBones.AnimationConfig));
         DragonBones.Armature        arg0 = (DragonBones.Armature)ToLua.CheckObject(L, 2, typeof(DragonBones.Armature));
         string arg1 = ToLua.CheckString(L, 3);
         bool   arg2 = LuaDLL.luaL_checkboolean(L, 4);
         obj.RemoveBoneMask(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_fadeOutMode(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig      obj = (DragonBones.AnimationConfig)o;
            DragonBones.AnimationFadeOutMode ret = obj.fadeOutMode;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fadeOutMode on a nil value" : e.Message));
        }
    }
    static int get_weight(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            float ret = obj.weight;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index weight on a nil value" : e.Message));
        }
    }
    static int get_layer(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            int ret = obj.layer;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index layer on a nil value" : e.Message));
        }
    }
    static int set_actionEnabled(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.AnimationConfig obj = (DragonBones.AnimationConfig)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.actionEnabled = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index actionEnabled on a nil value" : e.Message));
        }
    }
    static int _CreateDragonBones_AnimationConfig(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                DragonBones.AnimationConfig obj = new DragonBones.AnimationConfig();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: DragonBones.AnimationConfig.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 27
0
        /**
         * @language zh_CN
         * @beta
         * 通过动画配置来播放动画。
         * @param animationConfig 动画配置。
         * @returns 对应的动画状态。
         * @see DragonBones.AnimationConfig
         * @see DragonBones.AnimationState
         * @version DragonBones 5.0
         */
        public AnimationState PlayConfig(AnimationConfig animationConfig)
        {
            if (animationConfig == null)
            {
                DragonBones.Assert(false, DragonBones.ARGUMENT_ERROR);
                return(null);
            }

            var animationName = !string.IsNullOrEmpty(animationConfig.animationName) ? animationConfig.animationName : animationConfig.name;
            var animationData = _animations.ContainsKey(animationName) ? _animations[animationName] : null;

            if (animationData == null)
            {
                DragonBones.Assert(false,
                                   "Non-existent animation.\n" +
                                   "DragonBones name: " + _armature.armatureData.parent.name +
                                   " Armature name: " + _armature.name +
                                   " Animation name: " + animationName
                                   );

                return(null);
            }

            _isPlaying = true;

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

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

            if (animationConfig.fadeOutTime < 0.0f || float.IsNaN(animationConfig.fadeOutTime))
            {
                animationConfig.fadeOutTime = animationConfig.fadeInTime;
            }

            if (animationConfig.timeScale <= -100.0f || float.IsNaN(animationConfig.timeScale)) //
            {
                animationConfig.timeScale = 1.0f / animationData.scale;
            }

            if (animationData.duration > 0.0f)
            {
                if (float.IsNaN(animationConfig.position))
                {
                    animationConfig.position = 0.0f;
                }
                else if (animationConfig.position < 0.0f)
                {
                    animationConfig.position %= animationData.duration;
                    animationConfig.position  = animationData.duration - animationConfig.position;
                }
                else if (animationConfig.position == animationData.duration)
                {
                    animationConfig.position -= 0.000001f;
                }
                else if (animationConfig.position > animationData.duration)
                {
                    animationConfig.position %= animationData.duration;
                }

                if (animationConfig.duration > 0.0f && animationConfig.position + animationConfig.duration > animationData.duration)
                {
                    animationConfig.duration = animationData.duration - animationConfig.position;
                }

                if (animationConfig.duration == 0.0f)
                {
                    animationConfig.playTimes = 1;
                }
                else if (animationConfig.playTimes < 0)
                {
                    animationConfig.playTimes = (int)animationData.playTimes;
                }
            }
            else
            {
                animationConfig.playTimes = 1;
                animationConfig.position  = 0.0f;
                animationConfig.duration  = 0.0f;
            }

            _fadeOut(animationConfig);

            _lastAnimationState = BaseObject.BorrowObject <AnimationState>();
            _lastAnimationState._init(_armature, animationData, animationConfig);
            _animationStates.Add(_lastAnimationState);
            _animationStateDirty = true;
            _cacheFrameIndex     = -1;

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

            // Child armature play same name animation.
            var slots = _armature.GetSlots();

            for (int i = 0, l = slots.Count; i < l; ++i)
            {
                var childArmature = slots[i].childArmature;
                if (
                    childArmature != null && childArmature.inheritAnimation &&
                    childArmature.animation.HasAnimation(animationName) &&
                    childArmature.animation.GetState(animationName) == null
                    )
                {
                    childArmature.animation.FadeIn(animationName); //
                }
            }

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

            return(_lastAnimationState);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// - Play animation with a specific animation config.
        /// The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
        /// </summary>
        /// <param name="animationConfig">- The animation config.</param>
        /// <returns>The playing animation state.</returns>
        /// <see cref="DragonBones.AnimationConfig"/>
        /// <beta/>
        /// <version>DragonBones 5.0</version>
        /// <language>en_US</language>

        /// <summary>
        /// - 通过指定的动画配置来播放动画。
        /// 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。
        /// </summary>
        /// <param name="animationConfig">- 动画配置。</param>
        /// <returns>播放的动画状态。</returns>
        /// <see cref="DragonBones.AnimationConfig"/>
        /// <beta/>
        /// <version>DragonBones 5.0</version>
        /// <language>zh_CN</language>
        public AnimationState PlayConfig(AnimationConfig animationConfig)
        {
            var animationName = animationConfig.animation;

            if (!(this._animations.ContainsKey(animationName)))
            {
                Helper.Assert(false,
                              "Non-existent animation.\n" +
                              "DragonBones name: " + this._armature.armatureData.parent.name +
                              "Armature name: " + this._armature.name +
                              "Animation name: " + animationName
                              );

                return(null);
            }

            var animationData = this._animations[animationName];

            if (animationConfig.fadeOutMode == AnimationFadeOutMode.Single)
            {
                foreach (var aniState in this._animationStates)
                {
                    if (aniState._animationData == animationData)
                    {
                        return(aniState);
                    }
                }
            }

            if (this._animationStates.Count == 0)
            {
                animationConfig.fadeInTime = 0.0f;
            }
            else if (animationConfig.fadeInTime < 0.0f)
            {
                animationConfig.fadeInTime = animationData.fadeInTime;
            }

            if (animationConfig.fadeOutTime < 0.0f)
            {
                animationConfig.fadeOutTime = animationConfig.fadeInTime;
            }

            if (animationConfig.timeScale <= -100.0f)
            {
                animationConfig.timeScale = 1.0f / animationData.scale;
            }

            if (animationData.frameCount > 1)
            {
                if (animationConfig.position < 0.0f)
                {
                    animationConfig.position %= animationData.duration;
                    animationConfig.position  = animationData.duration - animationConfig.position;
                }
                else if (animationConfig.position == animationData.duration)
                {
                    animationConfig.position -= 0.000001f; // Play a little time before end.
                }
                else if (animationConfig.position > animationData.duration)
                {
                    animationConfig.position %= animationData.duration;
                }

                if (animationConfig.duration > 0.0f && animationConfig.position + animationConfig.duration > animationData.duration)
                {
                    animationConfig.duration = animationData.duration - animationConfig.position;
                }

                if (animationConfig.playTimes < 0)
                {
                    animationConfig.playTimes = (int)animationData.playTimes;
                }
            }
            else
            {
                animationConfig.playTimes = 1;
                animationConfig.position  = 0.0f;
                if (animationConfig.duration > 0.0)
                {
                    animationConfig.duration = 0.0f;
                }
            }

            if (animationConfig.duration == 0.0f)
            {
                animationConfig.duration = -1.0f;
            }

            this._FadeOut(animationConfig);

            var animationState = BaseObject.BorrowObject <AnimationState>();

            // Debug.Log("ArmatureAnim: "+_armature.name);
            animationState.Init(this._armature, animationData, animationConfig);
            this._animationDirty            = true;
            this._armature._cacheFrameIndex = -1;

            if (this._animationStates.Count > 0)
            {
                var added = false;
                for (int i = 0, l = this._animationStates.Count; i < l; ++i)
                {
                    if (animationState.layer >= this._animationStates[i].layer)
                    {
                    }
                    else
                    {
                        added = true;
                        this._animationStates.Insert(i, animationState);
                        break;
                    }
                }

                if (!added)
                {
                    this._animationStates.Add(animationState);
                }
            }
            else
            {
                this._animationStates.Add(animationState);
            }

            // Child armature play same name animation.
            foreach (var slot in this._armature.GetSlots())
            {
                var childArmature = slot.childArmature;
                if (childArmature != null &&
                    childArmature.inheritAnimation &&
                    childArmature.animation.HasAnimation(animationName) &&
                    childArmature.animation.GetState(animationName) == null)
                {
                    childArmature.animation.FadeIn(animationName); //
                }
            }

            if (animationConfig.fadeInTime <= 0.0f)
            {
                // Blend animation state, update armature.
                this._armature.AdvanceTime(0.0f);
            }

            this._lastAnimationState = animationState;

            return(animationState);
        }
        /**
         * @private
         * @internal
         */
        internal void Init(Armature armature, AnimationData animationData, AnimationConfig animationConfig)
        {
            if (this._armature != null)
            {
                return;
            }

            this._armature = armature;

            this.animationData    = animationData;
            this.resetToPose      = animationConfig.resetToPose;
            this.additiveBlending = animationConfig.additiveBlending;
            this.displayControl   = animationConfig.displayControl;
            this.actionEnabled    = animationConfig.actionEnabled;
            this.layer            = animationConfig.layer;
            this.playTimes        = animationConfig.playTimes;
            this.timeScale        = animationConfig.timeScale;
            this.fadeTotalTime    = animationConfig.fadeInTime;
            this.autoFadeOutTime  = animationConfig.autoFadeOutTime;
            this.weight           = animationConfig.weight;
            this.name             = animationConfig.name.Length > 0 ? animationConfig.name : animationConfig.animation;
            this.group            = animationConfig.group;

            if (animationConfig.pauseFadeIn)
            {
                this._playheadState = 2; // 10
            }
            else
            {
                this._playheadState = 3; // 11
            }

            if (animationConfig.duration < 0.0f)
            {
                this._position = 0.0f;
                this._duration = this.animationData.duration;
                if (animationConfig.position != 0.0f)
                {
                    if (this.timeScale >= 0.0f)
                    {
                        this._time = animationConfig.position;
                    }
                    else
                    {
                        this._time = animationConfig.position - this._duration;
                    }
                }
                else
                {
                    this._time = 0.0f;
                }
            }
            else
            {
                this._position = animationConfig.position;
                this._duration = animationConfig.duration;
                this._time     = 0.0f;
            }

            if (this.timeScale < 0.0f && this._time == 0.0f)
            {
                this._time = -0.000001f; // Turn to end.
            }

            if (this.fadeTotalTime <= 0.0f)
            {
                this._fadeProgress = 0.999999f; // Make different.
            }

            if (animationConfig.boneMask.Count > 0)
            {
                this._boneMask.ResizeList(animationConfig.boneMask.Count);
                for (int i = 0, l = this._boneMask.Count; i < l; ++i)
                {
                    this._boneMask[i] = animationConfig.boneMask[i];
                }
            }

            this._actionTimeline = BaseObject.BorrowObject <ActionTimelineState>();
            this._actionTimeline.Init(this._armature, this, this.animationData.actionTimeline);
            this._actionTimeline.currentTime = this._time;
            if (this._actionTimeline.currentTime < 0.0f)
            {
                this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime;
            }

            if (this.animationData.zOrderTimeline != null)
            {
                this._zOrderTimeline = BaseObject.BorrowObject <ZOrderTimelineState>();
                this._zOrderTimeline.Init(this._armature, this, this.animationData.zOrderTimeline);
            }
        }
Ejemplo n.º 30
0
        /**
         * @private
         */
        internal void _init(Armature armature, AnimationData animationData, AnimationConfig animationConfig)
        {
            _armature      = armature;
            _animationData = animationData;
            _name          = !string.IsNullOrEmpty(animationConfig.name) ? animationConfig.name : animationConfig.animationName;

            actionEnabled    = animationConfig.actionEnabled;
            additiveBlending = animationConfig.additiveBlending;
            displayControl   = animationConfig.displayControl;
            playTimes        = (uint)animationConfig.playTimes;
            timeScale        = animationConfig.timeScale;
            fadeTotalTime    = animationConfig.fadeInTime;
            autoFadeOutTime  = animationConfig.autoFadeOutTime;
            weight           = animationConfig.weight;

            if (animationConfig.pauseFadeIn)
            {
                _playheadState = 2; // 10
            }
            else
            {
                _playheadState = 3; // 11
            }

            _fadeState    = -1;
            _subFadeState = -1;
            _layer        = animationConfig.layer;
            _time         = animationConfig.position;
            _group        = animationConfig.group;

            if (animationConfig.duration < 0.0f)
            {
                _position = 0.0f;
                _duration = _animationData.duration;
            }
            else
            {
                _position = animationConfig.position;
                _duration = animationConfig.duration;
            }

            if (fadeTotalTime <= 0.0f)
            {
                _fadeProgress = 0.999999f;
            }

            if (animationConfig.boneMask.Count > 0)
            {
                DragonBones.ResizeList(_boneMask, animationConfig.boneMask.Count, null);
                for (int i = 0, l = _boneMask.Count; i < l; ++i)
                {
                    _boneMask[i] = animationConfig.boneMask[i];
                }
            }

            _timeline = BaseObject.BorrowObject <AnimationTimelineState>();
            _timeline._init(_armature, this, _animationData);

            if (_animationData.zOrderTimeline != null)
            {
                _zOrderTimeline = BaseObject.BorrowObject <ZOrderTimelineState>();
                _zOrderTimeline._init(_armature, this, _animationData.zOrderTimeline);
            }

            _updateTimelineStates();
        }