Exemplo n.º 1
0
    static int ReplaceAnimation(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.ArmatureData arg1 = (DragonBones.ArmatureData)ToLua.CheckObject <DragonBones.ArmatureData>(L, 3);
                bool o = obj.ReplaceAnimation(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.ArmatureData arg1 = (DragonBones.ArmatureData)ToLua.CheckObject <DragonBones.ArmatureData>(L, 3);
                bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
                bool o    = obj.ReplaceAnimation(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.ReplaceAnimation"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 2
0
        /// <private/>
        protected override void _OnClear()
        {
            this.globalTransformMatrix.Identity();
            this.global.Identity();
            this.offset.Identity();
            this.origin   = null; //
            this.userData = null;

            this._globalDirty = false;
            this._armature    = null; //
        }
Exemplo n.º 3
0
    static int BuildArmature(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                string arg0            = ToLua.CheckString(L, 2);
                DragonBones.Armature o = obj.BuildArmature(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                string arg0            = ToLua.CheckString(L, 2);
                string arg1            = ToLua.CheckString(L, 3);
                DragonBones.Armature o = obj.BuildArmature(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4)
            {
                DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                string arg0            = ToLua.CheckString(L, 2);
                string arg1            = ToLua.CheckString(L, 3);
                string arg2            = ToLua.CheckString(L, 4);
                DragonBones.Armature o = obj.BuildArmature(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 5)
            {
                DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject <DragonBones.BaseFactory>(L, 1);
                string arg0            = ToLua.CheckString(L, 2);
                string arg1            = ToLua.CheckString(L, 3);
                string arg2            = ToLua.CheckString(L, 4);
                string arg3            = ToLua.CheckString(L, 5);
                DragonBones.Armature o = obj.BuildArmature(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.BuildArmature"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        /// <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);
        }
Exemplo n.º 5
0
        /// <private/>
        protected void _BuildBones(BuildArmaturePackage dataPackage, Armature armature)
        {
            var bones = dataPackage.armature.sortedBones;

            for (int i = 0, l = bones.Count; i < l; ++i)
            {
                var boneData = bones[i];
                var bone     = BaseObject.BorrowObject <Bone>();
                bone.Init(boneData, armature);
            }
        }
        /**
         * @private
         */
        void OnDestroy()
        {
            if (_armature != null)
            {
                var armature = _armature;
                _armature = null;
                armature.Dispose();
            }

            _armature          = null;
            _disposeGameObject = true;
        }
Exemplo n.º 7
0
 /**
  * @inheritDoc
  */
 protected override void _onClear()
 {
     type = null;
     name = null;
     // data = null;
     armature       = null;
     bone           = null;
     slot           = null;
     animationState = null;
     frame          = null;
     userData       = null;
 }
Exemplo n.º 8
0
        /**
         * @inheritDoc
         */
        override protected void _onClear()
        {
            foreach (var boneTimelineState in _boneTimelines)
            {
                boneTimelineState.ReturnToPool();
            }

            foreach (var slotTimelineState in _slotTimelines)
            {
                slotTimelineState.ReturnToPool();
            }

            foreach (var ffdTimelineState in _ffdTimelines)
            {
                ffdTimelineState.ReturnToPool();
            }

            displayControl   = true;
            additiveBlending = false;
            actionEnabled    = false;
            playTimes        = 1;
            timeScale        = 1.0f;
            weight           = 1.0f;
            autoFadeOutTime  = -1.0f;
            fadeTotalTime    = 0.0f;

            _isFadeOutComplete = false;
            _layer             = 0;
            _position          = 0.0f;
            _duration          = 0.0f;
            _weightResult      = 0.0f;
            _fadeProgress      = 0.0f;
            _group             = null;

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

            _isPlaying       = true;
            _isPausePlayhead = false;
            _isFadeOut       = false;
            _fadeTime        = 0.0f;
            _time            = 0.0f;
            _name            = null;
            _armature        = null;
            _animationData   = null;
            _boneMask.Clear();
            _boneTimelines.Clear();
            _slotTimelines.Clear();
            _ffdTimelines.Clear();
        }
Exemplo n.º 9
0
        /**
         * @private
         */
        void OnDestroy()
        {
            if (_armature != null)
            {
                var armature = _armature;
                _armature = null;
                armature.Dispose();
            }

            _disposeProxy = true;
            _armature     = null;
        }
        /// <private/>
        protected void _BuildConstraints(BuildArmaturePackage dataPackage, Armature armature)
        {
            var constraints = dataPackage.armature.constraints;

            foreach (var constraintData in constraints.Values)
            {
                // TODO more constraint type.
                var constraint = BaseObject.BorrowObject <IKConstraint>();
                constraint.Init(constraintData, armature);
                armature._AddConstraint(constraint);
            }
        }
Exemplo n.º 11
0
    public void SwitchWeaponR()
    {
        this._weaponR.eventDispatcher.RemoveDBEventListener(DragonBones.EventObject.FRAME_EVENT, this._OnFrameEventHandler);

        this._weaponRIndex++;
        this._weaponRIndex %= WEAPON_R_LIST.Length;
        var weaponName = WEAPON_R_LIST[this._weaponRIndex];

        this._weaponR = UnityFactory.factory.BuildArmature(weaponName);
        this._armature.GetSlot("weapon_r").childArmature = this._weaponR;
        this._weaponR.eventDispatcher.AddDBEventListener(DragonBones.EventObject.FRAME_EVENT, this._OnFrameEventHandler);
    }
        /**
         * @inheritDoc
         */
        protected override void _onClear()
        {
            userData = null;
            name     = null;
            global.Identity();
            origin.Identity();
            offset.Identity();
            globalTransformMatrix.Identity();

            _armature = null;
            _parent   = null;
        }
Exemplo n.º 13
0
        /**
         * @private
         */
        protected void _BuildBones(BuildArmaturePackage dataPackage, Armature armature)
        {
            var bones = dataPackage.armature.sortedBones;

            for (int i = 0, l = bones.Count; i < l; ++i)
            {
                var boneData = bones[i];
                var bone     = BaseObject.BorrowObject <Bone>();
                bone.Init(boneData);

                if (boneData.parent != null)
                {
                    armature.AddBone(bone, boneData.parent.name);
                }
                else
                {
                    armature.AddBone(bone, string.Empty);
                }

                var constraints = boneData.constraints;

                for (int j = 0, lJ = constraints.Count; j < lJ; ++j)
                {
                    var constraintData = constraints[j];
                    var target         = armature.GetBone(constraintData.target.name);
                    if (target == null)
                    {
                        continue;
                    }

                    // TODO more constraint type.
                    var ikConstraintData = constraintData as IKConstraintData;
                    var constraint       = BaseObject.BorrowObject <IKConstraint>();
                    var root             = ikConstraintData.root != null?armature.GetBone(ikConstraintData.root.name) : null;

                    constraint.target       = target;
                    constraint.bone         = bone;
                    constraint.root         = root;
                    constraint.bendPositive = ikConstraintData.bendPositive;
                    constraint.scaleEnabled = ikConstraintData.scaleEnabled;
                    constraint.weight       = ikConstraintData.weight;

                    if (root != null)
                    {
                        root.AddConstraint(constraint);
                    }
                    else
                    {
                        bone.AddConstraint(constraint);
                    }
                }
            }
        }
Exemplo n.º 14
0
 /**
  * @private
  */
 void OnDestroy()
 {
     if (_armature != null)
     {
         var armature = _armature;
         _armature = null;
         armature.Dispose();
     }
     unityBones    = null;
     _sortedSlots  = null;
     _disposeProxy = true;
     _armature     = null;
 }
Exemplo n.º 15
0
 /** @private */
 override public void setArmature(Armature value)
 {
     base.setArmature(value);
     if (this._armature != null)
     {
         this._armature._slotsZOrderChanged = true;
         _displayBridge.AddDisplay(this._armature.Display, this.ZOrder);
     }
     else
     {
         _displayBridge.RemoveDisplay();
     }
 }
Exemplo n.º 16
0
 static int Dispose(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         obj.Dispose();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 17
0
 private void RestoreArmature(Armature armature)
 {
     if (armature == null)
     {
         return;
     }
     //
     foreach (UnitySlot slot in armature.GetSlots())
     {
         if (slot.childArmature == null)
         {
             slot.CancelCombineMesh();
         }
     }
 }
Exemplo n.º 18
0
 static int AdvanceTime(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
         obj.AdvanceTime(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int DBInit(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.UnityArmatureComponent obj = (DragonBones.UnityArmatureComponent)ToLua.CheckObject <DragonBones.UnityArmatureComponent>(L, 1);
         DragonBones.Armature arg0 = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 2);
         obj.DBInit(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 20
0
        /**
         * @private
         */
        public void _onClear()
        {
            if (_armature != null)
            {
                _armature = null;
                if (_disposeProxy)
                {
#if UNITY_EDITOR
                    Object.DestroyImmediate(gameObject);
#else
                    Object.Destroy(gameObject);
#endif
                }
            }
        }
Exemplo n.º 21
0
        /**
         * @private
         */
        override public void _onClear()
        {
            _armature = null;

            if (_disposeGameObject)
            {
#if UNITY_EDITOR
                Object.DestroyImmediate(this.gameObject);
#else
                Object.Destroy(this.gameObject);
#endif
            }

            _disposeGameObject = true;
        }
Exemplo n.º 22
0
 static int _sortZOrder(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         System.Collections.Generic.List <int> arg0 = (System.Collections.Generic.List <int>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <int>));
         obj._sortZOrder(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 23
0
 static int GetSlots(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         System.Collections.Generic.List <DragonBones.Slot> o = obj.GetSlots();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 24
0
 static int ReplaceTexture(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         object arg0 = ToLua.ToVarObject(L, 2);
         obj.ReplaceTexture(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 25
0
        /**
         * @private
         */
        internal override void _setArmature(Armature value)
        {
            if (_armature == value)
            {
                return;
            }

            _ik = null;

            List <Slot> oldSlots = null;
            List <Bone> oldBones = null;

            if (_armature != null)
            {
                oldSlots = GetSlots();
                oldBones = GetBones();
                _armature._removeBoneFromBoneList(this);
            }

            _armature = value;

            if (_armature != null)
            {
                _armature._addBoneToBoneList(this);
            }

            if (oldSlots != null)
            {
                foreach (var slot in oldSlots)
                {
                    if (slot.parent == this)
                    {
                        slot._setArmature(_armature);
                    }
                }
            }

            if (oldBones != null)
            {
                foreach (var bone in oldBones)
                {
                    if (bone.parent == this)
                    {
                        bone._setArmature(_armature);
                    }
                }
            }
        }
Exemplo n.º 26
0
 static int AddSlot(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         DragonBones.Armature obj  = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         DragonBones.Slot     arg0 = (DragonBones.Slot)ToLua.CheckObject(L, 2, typeof(DragonBones.Slot));
         string arg1 = ToLua.CheckString(L, 3);
         obj.AddSlot(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 27
0
 static int InvalidUpdate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         string arg0 = ToLua.CheckString(L, 2);
         bool   arg1 = LuaDLL.luaL_checkboolean(L, 3);
         obj.InvalidUpdate(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 28
0
 static int GetBone(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         string           arg0    = ToLua.CheckString(L, 2);
         DragonBones.Bone o       = obj.GetBone(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 29
0
 static int GetSlotByDisplay(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         object           arg0    = ToLua.ToVarObject(L, 2);
         DragonBones.Slot o       = obj.GetSlotByDisplay(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 30
0
        /// <internal/>
        /// <private/>
        internal virtual void Init(SlotData slotData, Armature armatureValue, object rawDisplay, object meshDisplay)
        {
            if (this._slotData != null)
            {
                return;
            }

            this._slotData = slotData;
            //
            this._visibleDirty   = true;
            this._blendModeDirty = true;
            this._colorDirty     = true;
            this._blendMode      = this._slotData.blendMode;
            this._zOrder         = this._slotData.zOrder;
            this._colorTransform.CopyFrom(this._slotData.color);
            this._rawDisplay  = rawDisplay;
            this._meshDisplay = meshDisplay;

            this._armature = armatureValue;

            var slotParent = this._armature.GetBone(this._slotData.parent.name);

            if (slotParent != null)
            {
                this._parent = slotParent;
            }
            else
            {
                // Never;
            }

            this._armature._AddSlot(this);

            //
            this._InitDisplay(this._rawDisplay, false);
            if (this._rawDisplay != this._meshDisplay)
            {
                this._InitDisplay(this._meshDisplay, false);
            }

            this._OnUpdateDisplay();
            this._AddDisplay();

            //
            // this.rawDisplayDatas = displayDatas; // TODO
        }