Exemplo n.º 1
0
    static int ReplaceDisplay(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                DragonBones.UnityFactory obj  = (DragonBones.UnityFactory)ToLua.CheckObject <DragonBones.UnityFactory>(L, 1);
                DragonBones.Slot         arg0 = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 2);
                DragonBones.DisplayData  arg1 = (DragonBones.DisplayData)ToLua.CheckObject <DragonBones.DisplayData>(L, 3);
                obj.ReplaceDisplay(arg0, arg1);
                return(0);
            }
            else if (count == 4)
            {
                DragonBones.UnityFactory obj  = (DragonBones.UnityFactory)ToLua.CheckObject <DragonBones.UnityFactory>(L, 1);
                DragonBones.Slot         arg0 = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 2);
                DragonBones.DisplayData  arg1 = (DragonBones.DisplayData)ToLua.CheckObject <DragonBones.DisplayData>(L, 3);
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                obj.ReplaceDisplay(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.UnityFactory.ReplaceDisplay"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 2
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.º 3
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));
     }
 }
 static int GetSlot(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 1);
         string           arg0    = ToLua.CheckString(L, 2);
         DragonBones.Slot o       = obj.GetSlot(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_slot(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj = (DragonBones.EventObject)o;
            DragonBones.Slot        ret = obj.slot;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index slot on a nil value"));
        }
    }
    static int set_slot(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.EventObject obj  = (DragonBones.EventObject)o;
            DragonBones.Slot        arg0 = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 2);
            obj.slot = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index slot on a nil value"));
        }
    }
Exemplo n.º 7
0
 static int ContainsPoint(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         float            arg0    = (float)LuaDLL.luaL_checknumber(L, 2);
         float            arg1    = (float)LuaDLL.luaL_checknumber(L, 3);
         DragonBones.Slot o       = obj.ContainsPoint(arg0, arg1);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 8
0
    static int get_parent(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DragonBones.Armature obj = (DragonBones.Armature)o;
            DragonBones.Slot     ret = obj.parent;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index parent on a nil value" : e.Message));
        }
    }
Exemplo n.º 9
0
 static int ReplaceSlotDisplayList(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         DragonBones.BaseFactory obj = (DragonBones.BaseFactory)ToLua.CheckObject(L, 1, typeof(DragonBones.BaseFactory));
         string           arg0       = ToLua.CheckString(L, 2);
         string           arg1       = ToLua.CheckString(L, 3);
         string           arg2       = ToLua.CheckString(L, 4);
         DragonBones.Slot arg3       = (DragonBones.Slot)ToLua.CheckObject(L, 5, typeof(DragonBones.Slot));
         obj.ReplaceSlotDisplayList(arg0, arg1, arg2, arg3);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 10
0
 static int ReplaceSlotDisplayList(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 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);
         DragonBones.Slot arg3       = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 5);
         bool             o          = obj.ReplaceSlotDisplayList(arg0, arg1, arg2, arg3);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int ReplaceSlotDisplay(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(DragonBones.UnityFactory), typeof(string), typeof(string), typeof(string), typeof(string), typeof(DragonBones.Slot), typeof(int)))
            {
                DragonBones.UnityFactory obj = (DragonBones.UnityFactory)ToLua.ToObject(L, 1);
                string           arg0        = ToLua.ToString(L, 2);
                string           arg1        = ToLua.ToString(L, 3);
                string           arg2        = ToLua.ToString(L, 4);
                string           arg3        = ToLua.ToString(L, 5);
                DragonBones.Slot arg4        = (DragonBones.Slot)ToLua.ToObject(L, 6);
                int arg5 = (int)LuaDLL.lua_tonumber(L, 7);
                obj.ReplaceSlotDisplay(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else if (count == 10 && TypeChecker.CheckTypes(L, 1, typeof(DragonBones.UnityFactory), typeof(string), typeof(string), typeof(string), typeof(string), typeof(DragonBones.Slot), typeof(UnityEngine.Texture2D), typeof(UnityEngine.Material), typeof(bool), typeof(int)))
            {
                DragonBones.UnityFactory obj = (DragonBones.UnityFactory)ToLua.ToObject(L, 1);
                string                arg0   = ToLua.ToString(L, 2);
                string                arg1   = ToLua.ToString(L, 3);
                string                arg2   = ToLua.ToString(L, 4);
                string                arg3   = ToLua.ToString(L, 5);
                DragonBones.Slot      arg4   = (DragonBones.Slot)ToLua.ToObject(L, 6);
                UnityEngine.Texture2D arg5   = (UnityEngine.Texture2D)ToLua.ToObject(L, 7);
                UnityEngine.Material  arg6   = (UnityEngine.Material)ToLua.ToObject(L, 8);
                bool arg7 = LuaDLL.lua_toboolean(L, 9);
                int  arg8 = (int)LuaDLL.lua_tonumber(L, 10);
                obj.ReplaceSlotDisplay(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.UnityFactory.ReplaceSlotDisplay"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 12
0
    static int ReplaceSlotDisplay(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 6)
            {
                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.Slot arg4       = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 6);
                bool             o          = obj.ReplaceSlotDisplay(arg0, arg1, arg2, arg3, arg4);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 7)
            {
                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.Slot arg4       = (DragonBones.Slot)ToLua.CheckObject <DragonBones.Slot>(L, 6);
                int  arg5 = (int)LuaDLL.luaL_checknumber(L, 7);
                bool o    = obj.ReplaceSlotDisplay(arg0, arg1, arg2, arg3, arg4, arg5);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.BaseFactory.ReplaceSlotDisplay"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 13
0
 static int intersectsSegment(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 8);
         DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject(L, 1, typeof(DragonBones.Armature));
         float             arg0   = (float)LuaDLL.luaL_checknumber(L, 2);
         float             arg1   = (float)LuaDLL.luaL_checknumber(L, 3);
         float             arg2   = (float)LuaDLL.luaL_checknumber(L, 4);
         float             arg3   = (float)LuaDLL.luaL_checknumber(L, 5);
         DragonBones.Point arg4   = (DragonBones.Point)ToLua.CheckObject(L, 6, typeof(DragonBones.Point));
         DragonBones.Point arg5   = (DragonBones.Point)ToLua.CheckObject(L, 7, typeof(DragonBones.Point));
         DragonBones.Point arg6   = (DragonBones.Point)ToLua.CheckObject(L, 8, typeof(DragonBones.Point));
         DragonBones.Slot  o      = obj.intersectsSegment(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 14
0
 private static int _onSortSlots(Slot a, Slot b)
 {
     return(a._zOrder > b._zOrder ? 1 : -1);
 }
Exemplo n.º 15
0
		public void RemoveChild(DBObject child)
		{
			if(child==null)
			{
				throw new ArgumentException();
			}
			
			int index = _children.IndexOf(child);
			if (index >= 0)
			{
				//_children.fixed = false;
				_children.RemoveAt(index);
				//_children.fixed = true;
				child.setParent(null);
				child.setArmature(null);
				
				if(child == _slot)
				{
					_slot = null;
				}
			}
			else
			{
				throw new ArgumentException();
			}
		}
Exemplo n.º 16
0
		public void AddChild(DBObject child)
		{
			if(child == null)
			{
				throw new ArgumentException();
			}
			
			if(child == this || (child is Bone && (child as Bone).Contains(this)))
			{
				throw new ArgumentException("An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)");
			}
			
			if(child.Parent!=null)
			{
				child.Parent.RemoveChild(child);
			}
			//_children.fixed = false;
			_children.Add(child);
			//_children.fixed = true;
			child.setParent(this);
			child.setArmature(this._armature);
			
			if(_slot==null && child is Slot)
			{
				_slot = child as Slot;
			}
		}
Exemplo n.º 17
0
		/**
		 * @inheritDoc
		 */
		override public void Dispose()
		{
			if(_children == null)
			{
				return;
			}
			base.Dispose();
			
			int i = _children.Count;
			while(i -- >0)
			{
				_children[i].Dispose();
			}
			//_children.fixed = false;
			_children.Clear();
			
			_children = null;
			_slot = null;
			_tweenPivot = null;
		}
Exemplo n.º 18
0
        override protected Armature _BuildChildArmatrue(BuildArmaturePackage dataPackage, Slot slot, DisplayData displayData)
        {
            var      childDisplayName = slot.slotData.name + " (" + displayData.path + ")"; //
            var      proxy            = slot.armature.proxy as UnityArmatureComponent;
            var      childTransform   = proxy.transform.Find(childDisplayName);
            Armature childArmature    = null;

            if (childTransform == null)
            {
                childArmature = BuildArmature(displayData.path, dataPackage.dataName);
            }
            else
            {
                childArmature = BuildArmatureComponent(displayData.path, dataPackage.dataName, null, dataPackage.textureAtlasName, childTransform.gameObject).armature;
            }

            //
            var childArmatureDisplay = childArmature.display as GameObject;

            childArmatureDisplay.GetComponent <UnityArmatureComponent>().isUGUI = proxy.GetComponent <UnityArmatureComponent>().isUGUI;
            childArmatureDisplay.name = childDisplayName;
            childArmatureDisplay.transform.SetParent(proxy.transform, false);
            childArmatureDisplay.gameObject.hideFlags = HideFlags.HideInHierarchy;
            childArmatureDisplay.SetActive(false);
            return(childArmature);
        }
Exemplo n.º 19
0
        /// <private/>
        public bool ReplaceSlotDisplayList(string dragonBonesName, string armatureName, string slotName, Slot slot)
        {
            var armatureData = this.GetArmatureData(armatureName, dragonBonesName);

            if (armatureData == null || armatureData.defaultSkin == null)
            {
                return(false);
            }

            var displays = armatureData.defaultSkin.GetDisplays(slotName);

            if (displays == null)
            {
                return(false);
            }

            var displayIndex = 0;

            // for (const displayData of displays)
            for (int i = 0, l = displays.Count; i < l; ++i)
            {
                var displayData = displays[i];
                this.ReplaceDisplay(slot, displayData, displayIndex++);
            }

            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">The DragonBonesData instance cache name</param>
        /// <param name="armatureName">The armature data name</param>
        /// <param name="slotName">The slot data name</param>
        /// <param name="displayName">The display data name</param>
        /// <param name="slot">The slot</param>
        /// <param name="texture">The new texture</param>
        /// <param name="material">The new material</param>
        /// <param name="isUGUI">is ugui。</param>
        /// <param name="displayIndex">The index of the display data that is replaced. (If it is not set, replaces the current display data)</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>

        /// <summary>
        /// 用特定的显示对象数据替换特定插槽当前的显示对象数据。
        /// </summary>
        /// <param name="dragonBonesName">指定的龙骨数据名称。</param>
        /// <param name="armatureName">指定的骨架名称。</param>
        /// <param name="slotName">指定的插槽名称。</param>
        /// <param name="displayName">指定的显示对象名称。</param>
        /// <param name="slot">指定的插槽实例。</param>
        /// <param name="texture">新的贴图。</param>
        /// <param name="material">新的材质。</param>
        /// <param name="isUGUI">是否为ugui。</param>
        /// <param name="displayIndex">被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据)。</param>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>
        public void ReplaceSlotDisplay(
            string dragonBonesName, string armatureName, string slotName, string displayName,
            Slot slot, Texture2D texture, Material material = null,
            bool isUGUI = false, int displayIndex = -1)
        {
            var armatureData = this.GetArmatureData(armatureName, dragonBonesName);

            if (armatureData == null || armatureData.defaultSkin == null)
            {
                return;
            }

            var displays = armatureData.defaultSkin.GetDisplays(slotName);

            if (displays == null)
            {
                return;
            }

            DisplayData prevDispalyData = null;

            foreach (var displayData in displays)
            {
                if (displayData.name == displayName)
                {
                    prevDispalyData = displayData;
                    break;
                }
            }

            if (prevDispalyData == null || !((prevDispalyData is ImageDisplayData) || (prevDispalyData is MeshDisplayData)))
            {
                return;
            }

            TextureData prevTextureData = null;

            if (prevDispalyData is ImageDisplayData)
            {
                prevTextureData = (prevDispalyData as ImageDisplayData).texture;
            }
            else
            {
                prevTextureData = (prevDispalyData as MeshDisplayData).texture;
            }

            UnityTextureData newTextureData = new UnityTextureData();

            newTextureData.CopyFrom(prevTextureData);
            newTextureData.rotated       = false;
            newTextureData.region.x      = 0.0f;
            newTextureData.region.y      = 0.0f;
            newTextureData.region.width  = texture.width;
            newTextureData.region.height = texture.height;
            newTextureData.frame         = newTextureData.region;
            newTextureData.name          = prevTextureData.name;
            newTextureData.parent        = new UnityTextureAtlasData();
            newTextureData.parent.width  = (uint)texture.width;
            newTextureData.parent.height = (uint)texture.height;
            newTextureData.parent.scale  = prevTextureData.parent.scale;

            //
            if (material == null)
            {
                if (isUGUI)
                {
                    material = UnityFactoryHelper.GenerateMaterial(defaultUIShaderName, texture.name + "_UI_Mat", texture);
                }
                else
                {
                    material = UnityFactoryHelper.GenerateMaterial(defaultShaderName, texture.name + "_Mat", texture);
                }
            }

            if (isUGUI)
            {
                (newTextureData.parent as UnityTextureAtlasData).uiTexture = material;
            }
            else
            {
                (newTextureData.parent as UnityTextureAtlasData).texture = material;
            }

            material.mainTexture = texture;

            DisplayData newDisplayData = null;

            if (prevDispalyData is ImageDisplayData)
            {
                newDisplayData      = new ImageDisplayData();
                newDisplayData.type = prevDispalyData.type;
                newDisplayData.name = prevDispalyData.name;
                newDisplayData.path = prevDispalyData.path;
                newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                newDisplayData.parent = prevDispalyData.parent;
                (newDisplayData as ImageDisplayData).pivot.CopyFrom((prevDispalyData as ImageDisplayData).pivot);
                (newDisplayData as ImageDisplayData).texture = newTextureData;
            }
            else if (prevDispalyData is MeshDisplayData)
            {
                newDisplayData      = new MeshDisplayData();
                newDisplayData.type = prevDispalyData.type;
                newDisplayData.name = prevDispalyData.name;
                newDisplayData.path = prevDispalyData.path;
                newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                newDisplayData.parent = prevDispalyData.parent;
                (newDisplayData as MeshDisplayData).texture = newTextureData;

                (newDisplayData as MeshDisplayData).vertices.inheritDeform = (prevDispalyData as MeshDisplayData).vertices.inheritDeform;
                (newDisplayData as MeshDisplayData).vertices.offset        = (prevDispalyData as MeshDisplayData).vertices.offset;
                (newDisplayData as MeshDisplayData).vertices.data          = (prevDispalyData as MeshDisplayData).vertices.data;
                (newDisplayData as MeshDisplayData).vertices.weight        = (prevDispalyData as MeshDisplayData).vertices.weight;
            }

            ReplaceDisplay(slot, newDisplayData, displayIndex);
        }
    static int IntersectsSegment(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 5)
            {
                DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 1);
                float            arg0    = (float)LuaDLL.luaL_checknumber(L, 2);
                float            arg1    = (float)LuaDLL.luaL_checknumber(L, 3);
                float            arg2    = (float)LuaDLL.luaL_checknumber(L, 4);
                float            arg3    = (float)LuaDLL.luaL_checknumber(L, 5);
                DragonBones.Slot o       = obj.IntersectsSegment(arg0, arg1, arg2, arg3);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 6)
            {
                DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 1);
                float             arg0   = (float)LuaDLL.luaL_checknumber(L, 2);
                float             arg1   = (float)LuaDLL.luaL_checknumber(L, 3);
                float             arg2   = (float)LuaDLL.luaL_checknumber(L, 4);
                float             arg3   = (float)LuaDLL.luaL_checknumber(L, 5);
                DragonBones.Point arg4   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 6);
                DragonBones.Slot  o      = obj.IntersectsSegment(arg0, arg1, arg2, arg3, arg4);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 7)
            {
                DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 1);
                float             arg0   = (float)LuaDLL.luaL_checknumber(L, 2);
                float             arg1   = (float)LuaDLL.luaL_checknumber(L, 3);
                float             arg2   = (float)LuaDLL.luaL_checknumber(L, 4);
                float             arg3   = (float)LuaDLL.luaL_checknumber(L, 5);
                DragonBones.Point arg4   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 6);
                DragonBones.Point arg5   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 7);
                DragonBones.Slot  o      = obj.IntersectsSegment(arg0, arg1, arg2, arg3, arg4, arg5);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 8)
            {
                DragonBones.Armature obj = (DragonBones.Armature)ToLua.CheckObject <DragonBones.Armature>(L, 1);
                float             arg0   = (float)LuaDLL.luaL_checknumber(L, 2);
                float             arg1   = (float)LuaDLL.luaL_checknumber(L, 3);
                float             arg2   = (float)LuaDLL.luaL_checknumber(L, 4);
                float             arg3   = (float)LuaDLL.luaL_checknumber(L, 5);
                DragonBones.Point arg4   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 6);
                DragonBones.Point arg5   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 7);
                DragonBones.Point arg6   = (DragonBones.Point)ToLua.CheckObject <DragonBones.Point>(L, 8);
                DragonBones.Slot  o      = obj.IntersectsSegment(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.Armature.IntersectsSegment"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 22
0
        /// <private/>
        protected object _GetSlotDisplay(BuildArmaturePackage dataPackage, DisplayData displayData, DisplayData rawDisplayData, Slot slot)
        {
            var    dataName = dataPackage != null ? dataPackage.dataName : displayData.parent.parent.parent.name;
            object display  = null;

            switch (displayData.type)
            {
            case DisplayType.Image:
            {
                var imageDisplayData = displayData as ImageDisplayData;
                if (imageDisplayData.texture == null)
                {
                    imageDisplayData.texture = this._GetTextureData(dataName, displayData.path);
                }
                else if (dataPackage != null && !string.IsNullOrEmpty(dataPackage.textureAtlasName))
                {
                    imageDisplayData.texture = this._GetTextureData(dataPackage.textureAtlasName, displayData.path);
                }

                if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh && this._IsSupportMesh())
                {
                    display = slot.meshDisplay;
                }
                else
                {
                    display = slot.rawDisplay;
                }
            }
            break;

            case DisplayType.Mesh:
            {
                var meshDisplayData = displayData as MeshDisplayData;
                if (meshDisplayData.texture == null)
                {
                    meshDisplayData.texture = this._GetTextureData(dataName, meshDisplayData.path);
                }
                else if (dataPackage != null && !string.IsNullOrEmpty(dataPackage.textureAtlasName))
                {
                    meshDisplayData.texture = this._GetTextureData(dataPackage.textureAtlasName, meshDisplayData.path);
                }

                if (this._IsSupportMesh())
                {
                    display = slot.meshDisplay;
                }
                else
                {
                    display = slot.rawDisplay;
                }
            }
            break;

            case DisplayType.Armature:
            {
                var armatureDisplayData = displayData as ArmatureDisplayData;
                var childArmature       = this._BuildChildArmature(dataPackage, slot, displayData);
                if (childArmature != null)
                {
                    childArmature.inheritAnimation = armatureDisplayData.inheritAnimation;
                    if (!childArmature.inheritAnimation)
                    {
                        var actions = armatureDisplayData.actions.Count > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions;
                        if (actions.Count > 0)
                        {
                            foreach (var action in actions)
                            {
                                childArmature._BufferAction(action, true);
                            }
                        }
                        else
                        {
                            childArmature.animation.Play();
                        }
                    }

                    armatureDisplayData.armature = childArmature.armatureData;         //
                }

                display = childArmature;
            }
            break;

            case DisplayType.BoundingBox:
                break;
            }

            return(display);
        }
Exemplo n.º 23
0
        /**
         * @language zh_CN
         * 用外部贴图替换display贴图。
         * @param dragonBonesName 指定的龙骨数据名称。
         * @param armatureName 指定的骨架名称。
         * @param slotName 指定的插槽名称。
         * @param displayName 指定的显示对象名称。
         * @param slot 指定的插槽实例。
         * @param texture 新的贴图。
         * @param material 新的材质。
         * @param isUGUI 是否为ugui。
         * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。
         * @version DragonBones 4.5
         */
        public void ReplaceSlotDisplay(string dragonBonesName, string armatureName, string slotName, string displayName, Slot slot, Texture2D texture, Material material, bool isUGUI = false, int displayIndex = -1)
        {
            var dataPackage = new BuildArmaturePackage();

            if (_FillBuildArmaturePackage(dataPackage, dragonBonesName, armatureName, null, null))
            {
                var displays = dataPackage.skin.GetDisplays(slotName);

                DisplayData prevDispalyData = null;
                foreach (var displayData in displays)
                {
                    if (displayData.name == displayName)
                    {
                        prevDispalyData = displayData;
                        break;
                    }
                }

                //QQQ
                if (prevDispalyData == null || !(prevDispalyData is ImageDisplayData))
                {
                    return;
                }

                TextureData      prevTextureData = (prevDispalyData as ImageDisplayData).texture;
                UnityTextureData newTextureData  = new UnityTextureData();
                newTextureData.CopyFrom(prevTextureData);
                newTextureData.rotated       = false;
                newTextureData.region.x      = 0.0f;
                newTextureData.region.y      = 0.0f;
                newTextureData.region.width  = texture.width;
                newTextureData.region.height = texture.height;
                newTextureData.frame         = newTextureData.region;
                newTextureData.name          = prevTextureData.name;
                newTextureData.parent        = new UnityTextureAtlasData();
                newTextureData.parent.width  = (uint)texture.width;
                newTextureData.parent.height = (uint)texture.height;
                if (isUGUI)
                {
                    (newTextureData.parent as UnityTextureAtlasData).uiTexture = material;
                }
                else
                {
                    (newTextureData.parent as UnityTextureAtlasData).texture = material;
                }

                material.mainTexture = texture;

                ImageDisplayData newDisplayData = prevDispalyData is MeshDisplayData ? new MeshDisplayData() : new ImageDisplayData();
                newDisplayData.type = prevDispalyData.type;
                newDisplayData.name = prevDispalyData.name;
                newDisplayData.path = prevDispalyData.path;
                newDisplayData.transform.CopyFrom(prevDispalyData.transform);
                newDisplayData.parent = prevDispalyData.parent;
                newDisplayData.pivot.CopyFrom((prevDispalyData as ImageDisplayData).pivot);
                newDisplayData.texture = newTextureData;

                if (newDisplayData is MeshDisplayData)
                {
                    (newDisplayData as MeshDisplayData).inheritAnimation = (prevDispalyData as MeshDisplayData).inheritAnimation;
                    (newDisplayData as MeshDisplayData).offset           = (prevDispalyData as MeshDisplayData).offset;
                    (newDisplayData as MeshDisplayData).weight           = (prevDispalyData as MeshDisplayData).weight;
                }

                _ReplaceSlotDisplay(dataPackage, newDisplayData, slot, displayIndex);
            }
        }
Exemplo n.º 24
0
        /**
         * @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;
            _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();
        }
Exemplo n.º 25
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;
        }
Exemplo n.º 26
0
        /**
         * @language zh_CN
         * 判断线段是否与骨架的所有插槽的自定义包围盒相交。
         * @param xA 线段起点的水平坐标。(骨架内坐标系)
         * @param yA 线段起点的垂直坐标。(骨架内坐标系)
         * @param xB 线段终点的水平坐标。(骨架内坐标系)
         * @param yB 线段终点的垂直坐标。(骨架内坐标系)
         * @param intersectionPointA 线段从起点到终点与包围盒相交的第一个交点。(骨架内坐标系)
         * @param intersectionPointB 线段从终点到起点与包围盒相交的第一个交点。(骨架内坐标系)
         * @param normalRadians 碰撞点处包围盒切线的法线弧度。 [x: 第一个碰撞点处切线的法线弧度, y: 第二个碰撞点处切线的法线弧度]
         * @returns 线段从起点到终点相交的第一个自定义包围盒的插槽。
         * @version DragonBones 5.0
         */
        public Slot intersectsSegment(
            float xA, float yA, float xB, float yB,
            Point intersectionPointA = null,
            Point intersectionPointB = null,
            Point normalRadians      = null
            )
        {
            var  isV      = xA == xB;
            var  dMin     = 0.0f;
            var  dMax     = 0.0f;
            var  intXA    = 0.0f;
            var  intYA    = 0.0f;
            var  intXB    = 0.0f;
            var  intYB    = 0.0f;
            var  intAN    = 0.0f;
            var  intBN    = 0.0f;
            Slot intSlotA = null;
            Slot intSlotB = null;

            for (int i = 0, l = _slots.Count; i < l; ++i)
            {
                var slot = _slots[i];
                var intersectionCount = slot.IntersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians);
                if (intersectionCount > 0)
                {
                    if (intersectionPointA != null || intersectionPointB != null)
                    {
                        if (intersectionPointA != null)
                        {
                            var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA;
                            if (d < 0.0f)
                            {
                                d = -d;
                            }

                            if (intSlotA == null || d < dMin)
                            {
                                dMin     = d;
                                intXA    = intersectionPointA.x;
                                intYA    = intersectionPointA.y;
                                intSlotA = slot;

                                if (normalRadians != null)
                                {
                                    intAN = normalRadians.x;
                                }
                            }
                        }

                        if (intersectionPointB != null)
                        {
                            var d = intersectionPointB.x - xA;
                            if (d < 0.0f)
                            {
                                d = -d;
                            }

                            if (intSlotB == null || d > dMax)
                            {
                                dMax     = d;
                                intXB    = intersectionPointB.x;
                                intYB    = intersectionPointB.y;
                                intSlotB = slot;

                                if (normalRadians != null)
                                {
                                    intBN = normalRadians.y;
                                }
                            }
                        }
                    }
                    else
                    {
                        intSlotA = slot;
                        break;
                    }
                }
            }

            if (intSlotA != null && intersectionPointA != null)
            {
                intersectionPointA.x = intXA;
                intersectionPointA.y = intYA;

                if (normalRadians != null)
                {
                    normalRadians.x = intAN;
                }
            }

            if (intSlotB != null && intersectionPointB != null)
            {
                intersectionPointB.x = intXB;
                intersectionPointB.y = intYB;

                if (normalRadians != null)
                {
                    normalRadians.y = intBN;
                }
            }

            return(intSlotA);
        }
Exemplo n.º 27
0
 /// <private/>
 protected virtual Armature _BuildChildArmature(BuildArmaturePackage dataPackage, Slot slot, DisplayData displayData)
 {
     return(this.BuildArmature(displayData.path, dataPackage != null ? dataPackage.dataName : "", "", dataPackage != null ? dataPackage.textureAtlasName : ""));
 }
Exemplo n.º 28
0
        protected override void _OnClear()
        {
            base._OnClear();

            this.slot = null; //
        }