Пример #1
0
 protected override void _OnClear()
 {
     this.name = "";
     this.path = "";
     this.transform.Identity();
     this.parent = null; //
 }
Пример #2
0
        /**
         * 更换骨架皮肤。
         * @param armature 骨架。
         * @param skin 皮肤数据。
         * @param exclude 不需要更新的插槽。
         * @see dragonBones.Armature
         * @see dragonBones.SkinData
         * @version DragonBones 5.1
         * @language zh_CN
         */
        public void ChangeSkin(Armature armature, SkinData skin, List <string> exclude = null)
        {
            foreach (var slot in armature.GetSlots())
            {
                if (exclude != null && exclude.Contains(slot.name))
                {
                    continue;
                }

                var displays = skin.GetDisplays(slot.name);
                if (displays == null)
                {
                    continue;
                }

                var displayCount = displays.Count;
                var displayList  = slot.displayList;  // Copy.
                displayList.ResizeList(displayCount); // Modify displayList length.
                for (int i = 0, l = displayCount; i < l; ++i)
                {
                    var displayData = displays[i];
                    if (displayData != null)
                    {
                        displayList[i] = this._GetSlotDisplay(null, displayData, null, slot);
                    }
                    else
                    {
                        displayList[i] = null;
                    }
                }

                slot.rawDisplayDatas = displays;
                slot.displayList     = displayList;
            }
        }
Пример #3
0
        /**
         * @inheritDoc
         */
        protected override void _onClear()
        {
            base._onClear();

            displayIndex = 0;
            skin         = null;
            slot         = null;
        }
        /// <summary>
        /// - Share specific skin data with specific armature.
        /// </summary>
        /// <param name="armature">- The armature.</param>
        /// <param name="skin">- The skin data.</param>
        /// <param name="isOverride">- Whether it completely override the original skin. (Default: false)</param>
        /// <param name="exclude">- A list of slot names that do not need to be replace.</param>
        /// <example>
        /// TypeScript style, for reference only.
        /// <pre>
        ///     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
        ///     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
        ///     if (armatureDataB && armatureDataB.defaultSkin) {
        ///     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
        ///     }
        /// </pre>
        /// </example>
        /// <see cref="DragonBones.Armature"/>
        /// <see cref="DragonBones.SkinData"/>
        /// <version>DragonBones 5.6</version>
        /// <language>en_US</language>

        /// <summary>
        /// - 将特定的皮肤数据共享给特定的骨架使用。
        /// </summary>
        /// <param name="armature">- 骨架。</param>
        /// <param name="skin">- 皮肤数据。</param>
        /// <param name="isOverride">- 是否完全覆盖原来的皮肤。 (默认: false)</param>
        /// <param name="exclude">- 不需要被替换的插槽名称列表。</param>
        /// <example>
        /// TypeScript 风格,仅供参考。
        /// <pre>
        ///     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
        ///     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
        ///     if (armatureDataB && armatureDataB.defaultSkin) {
        ///     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
        ///     }
        /// </pre>
        /// </example>
        /// <see cref="DragonBones.Armature"/>
        /// <see cref="DragonBones.SkinData"/>
        /// <version>DragonBones 5.6</version>
        /// <language>zh_CN</language>
        public bool ReplaceSkin(Armature armature, SkinData skin, bool isOverride = false, List <string> exclude = null)
        {
            var success     = false;
            var defaultSkin = skin.parent.defaultSkin;

            foreach (var slot in armature.GetSlots())
            {
                if (exclude != null && exclude.Contains(slot.name))
                {
                    continue;
                }

                var displays = skin.GetDisplays(slot.name);
                if (displays == null)
                {
                    if (defaultSkin != null && skin != defaultSkin)
                    {
                        displays = defaultSkin.GetDisplays(slot.name);
                    }

                    if (displays == null)
                    {
                        if (isOverride)
                        {
                            slot.rawDisplayDatas = null;
                            slot.displayList.Clear(); //
                        }

                        continue;
                    }
                }
                var displayCount = displays.Count;
                var displayList  = slot.displayList;  // Copy.
                displayList.ResizeList(displayCount); // Modify displayList length.
                for (int i = 0, l = displayCount; i < l; ++i)
                {
                    var displayData = displays[i];
                    if (displayData != null)
                    {
                        displayList[i] = this._GetSlotDisplay(null, displayData, null, slot);
                    }
                    else
                    {
                        displayList[i] = null;
                    }
                }

                success = true;
                slot.rawDisplayDatas = displays;
                slot.displayList     = displayList;
            }

            return(success);
        }
Пример #5
0
        /**
         * @private
         */
        protected override void _onClear()
        {
            foreach (var pair in bones)
            {
                pair.Value.ReturnToPool();
            }

            foreach (var pair in slots)
            {
                pair.Value.ReturnToPool();
            }

            foreach (var pair in skins)
            {
                pair.Value.ReturnToPool();
            }

            foreach (var pair in animations)
            {
                pair.Value.ReturnToPool();
            }

            foreach (var action in actions)
            {
                action.ReturnToPool();
            }

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

            frameRate      = 0;
            type           = ArmatureType.None;
            cacheFrameRate = 0;
            scale          = 1.0f;
            name           = null;
            aabb.Clear();
            bones.Clear();
            slots.Clear();
            skins.Clear();
            animations.Clear();
            actions.Clear();
            parent = null;

            _boneDirty = false;
            _slotDirty = false;
            _animationNames.Clear();
            _sortedBones.Clear();
            _sortedSlots.Clear();
            _bonesChildren.Clear();
            _defaultSkin      = null;
            _defaultAnimation = null;
        }
 /**
  * @private
  */
 public void AddSkin(SkinData value)
 {
     if (value != null && value.name != null && !skins.ContainsKey(value.name))
     {
         skins[value.name] = value;
         if (_defaultSkin == null)
         {
             _defaultSkin = value;
         }
     }
     else
     {
         DragonBones.Warn("");
     }
 }
 static int AddSkin(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.ArmatureData obj  = (DragonBones.ArmatureData)ToLua.CheckObject(L, 1, typeof(DragonBones.ArmatureData));
         DragonBones.SkinData     arg0 = (DragonBones.SkinData)ToLua.CheckObject(L, 2, typeof(DragonBones.SkinData));
         obj.AddSkin(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetSkin(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.ArmatureData obj = (DragonBones.ArmatureData)ToLua.CheckObject(L, 1, typeof(DragonBones.ArmatureData));
         string arg0            = ToLua.CheckString(L, 2);
         DragonBones.SkinData o = obj.GetSkin(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #9
0
        /**
         * @private
         */
        public void AddSkin(SkinData value)
        {
            if (value != null && !string.IsNullOrEmpty(value.name) && !skins.ContainsKey(value.name))
            {
                skins[value.name] = value;

                if (_defaultSkin == null)
                {
                    _defaultSkin = value;
                }
            }
            else
            {
                DragonBones.Assert(false, DragonBones.ARGUMENT_ERROR);
            }
        }
Пример #10
0
    static int ReplaceSkin(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                DragonBones.BaseFactory obj  = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                DragonBones.Armature    arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2);
                DragonBones.SkinData    arg1 = (DragonBones.SkinData)ToLua.CheckObject <DragonBones.SkinData>(L, 3);
                bool o = obj.ReplaceSkin(arg0, arg1);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 4)
            {
                DragonBones.BaseFactory obj  = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                DragonBones.Armature    arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2);
                DragonBones.SkinData    arg1 = (DragonBones.SkinData)ToLua.CheckObject <DragonBones.SkinData>(L, 3);
                bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
                bool o    = obj.ReplaceSkin(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 5)
            {
                DragonBones.BaseFactory obj  = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                DragonBones.Armature    arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2);
                DragonBones.SkinData    arg1 = (DragonBones.SkinData)ToLua.CheckObject <DragonBones.SkinData>(L, 3);
                bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
                System.Collections.Generic.List <string> arg3 = (System.Collections.Generic.List <string>)ToLua.CheckObject(L, 5, typeof(System.Collections.Generic.List <string>));
                bool o = obj.ReplaceSkin(arg0, arg1, arg2, arg3);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.ReplaceSkin"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int get_defaultSkin(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.ArmatureData obj = (DragonBones.ArmatureData)o;
            DragonBones.SkinData     ret = obj.defaultSkin;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index defaultSkin on a nil value" : e.Message));
        }
    }
Пример #12
0
        /**
         * @private
         */
        public void AddSkin(SkinData value)
        {
            if (value != null && !string.IsNullOrEmpty(value.name))
            {
                if (this.skins.ContainsKey(value.name))
                {
                    Helper.Assert(false, "Replace slot: " + value.name);
                    this.skins[value.name].ReturnToPool();
                }

                value.parent           = this;
                this.skins[value.name] = value;
                if (this.defaultSkin == null)
                {
                    this.defaultSkin = value;
                }
            }
        }
Пример #13
0
        /**
         * @private
         */
        internal void _init(
            ArmatureData armatureData, SkinData skinData,
            object display, IArmatureProxy proxy, IEventDispatcher <EventObject> eventManager
            )
        {
            if (_armatureData != null)
            {
                return;
            }

            _armatureData = armatureData;
            _skinData     = skinData;
            _animation    = BaseObject.BorrowObject <Animation>();
            _display      = display;
            _proxy        = proxy;
            _eventManager = eventManager;

            _animation._init(this);
            _animation.animations = _armatureData.animations;
        }
        /**
         * @inheritDoc
         */
        protected override void _onClear()
        {
            foreach (var bone in _bones)
            {
                bone.ReturnToPool();
            }

            foreach (var slot in _slots)
            {
                slot.ReturnToPool();
            }

            foreach (var evt in _events)
            {
                evt.ReturnToPool();
            }

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

            if (_eventDispatcher != null && _eventDispatcher != _display) // May be _eventDispatcher and _display is the same one.
            {
                _eventDispatcher._onClear();
            }

            if (_display != null)
            {
                var armatureDisplay = _display as IArmatureDisplay;
                if (armatureDisplay != null)
                {
                    armatureDisplay._onClear();
                }
            }

            if (_clock != null)
            {
                _clock.Remove(this);
            }

            userData = null;

            _bonesDirty      = false;
            _flipX           = false;
            _flipY           = false;
            _cacheFrameIndex = -1;
            _armatureData    = null;
            _skinData        = null;
            _animation       = null;
            _eventDispatcher = null;
            _display         = null;
            _eventManager    = null;
            _parent          = null;
            _clock           = null;
            _replacedTexture = null;

            _delayDispose = false;
            _lockDispose  = false;
            _slotsDirty   = false;
            _bones.Clear();
            _slots.Clear();
            _actions.Clear();
            _events.Clear();
        }
Пример #15
0
        protected override void _OnClear()
        {
            foreach (var action in this.defaultActions)
            {
                action.ReturnToPool();
            }

            foreach (var action in this.actions)
            {
                action.ReturnToPool();
            }

            foreach (var k in this.bones.Keys)
            {
                this.bones[k].ReturnToPool();
            }

            foreach (var k in this.slots.Keys)
            {
                this.slots[k].ReturnToPool();
            }

            foreach (var k in this.constraints.Keys)
            {
                this.constraints[k].ReturnToPool();
            }

            foreach (var k in this.skins.Keys)
            {
                this.skins[k].ReturnToPool();
            }

            foreach (var k in this.animations.Keys)
            {
                this.animations[k].ReturnToPool();
            }

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

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

            this.type           = ArmatureType.Armature;
            this.frameRate      = 0;
            this.cacheFrameRate = 0;
            this.scale          = 1.0f;
            this.name           = "";
            this.aabb.Clear();
            this.animationNames.Clear();
            this.sortedBones.Clear();
            this.sortedSlots.Clear();
            this.defaultActions.Clear();
            this.actions.Clear();
            this.bones.Clear();
            this.slots.Clear();
            this.constraints.Clear();
            this.skins.Clear();
            this.animations.Clear();
            this.defaultSkin      = null;
            this.defaultAnimation = null;
            this.canvas           = null;
            this.userData         = null;
            this.parent           = null; //
        }
Пример #16
0
 public bool ChangeSkin(Armature armature, SkinData skin, List <string> exclude = null)
 {
     return(ReplaceSkin(armature, skin, false, exclude));
 }
Пример #17
0
        /**
         * @private
         */
        protected override void _onClear()
        {
            foreach (var bone in _bones)
            {
                bone.ReturnToPool();
            }

            foreach (var slot in _slots)
            {
                slot.ReturnToPool();
            }

            foreach (var evt in _events)
            {
                evt.ReturnToPool();
            }

            if (_clock != null)
            {
                _clock.Remove(this);
            }

            if (_proxy != null)
            {
                _proxy._onClear();
            }

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

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

            inheritAnimation = true;
            userData         = null;

            _delayDispose = false;
            _lockDispose  = false;
            _bonesDirty   = false;
            _slotsDirty   = false;
            _zOrderDirty  = false;
            _flipX        = false;
            _flipY        = false;
            _bones.Clear();
            _slots.Clear();
            _actions.Clear();
            _events.Clear();
            _armatureData            = null;
            _skinData                = null;
            _animation               = null;
            _proxy                   = null;
            _display                 = null;
            _eventManager            = null;
            _parent                  = null;
            _clock                   = null;
            _replaceTextureAtlasData = null;
            _replacedTexture         = null;
        }