Esempio n. 1
0
        /**
         * @private
         */
        protected bool _fillBuildArmaturePackage(BuildArmaturePackage dataPackage, string dragonBonesName, string armatureName, string skinName, string textureAtlasName)
        {
            DragonBonesData dragonBonesData = null;
            ArmatureData    armatureData    = null;

            var isAvailableName = !string.IsNullOrEmpty(dragonBonesName);

            if (isAvailableName)
            {
                if (_dragonBonesDataMap.ContainsKey(dragonBonesName))
                {
                    dragonBonesData = _dragonBonesDataMap[dragonBonesName];
                    armatureData    = dragonBonesData.GetArmature(armatureName);
                }
            }

            if (armatureData == null && (!isAvailableName || autoSearch)) // Will be search all data, if do not give a data name or the autoSearch is true.
            {
                foreach (var pair in _dragonBonesDataMap)
                {
                    dragonBonesData = pair.Value;
                    if (!isAvailableName || dragonBonesData.autoSearch)
                    {
                        armatureData = dragonBonesData.GetArmature(armatureName);
                        if (armatureData != null)
                        {
                            dragonBonesName = dragonBonesData.name;
                            break;
                        }
                    }
                }
            }

            if (armatureData != null)
            {
                dataPackage.dataName         = dragonBonesName;
                dataPackage.textureAtlasName = textureAtlasName;
                dataPackage.data             = dragonBonesData;
                dataPackage.armature         = armatureData;
                dataPackage.skin             = armatureData.GetSkin(skinName);
                if (dataPackage.skin == null)
                {
                    dataPackage.skin = armatureData.defaultSkin;
                }

                return(true);
            }

            return(false);
        }
 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));
     }
 }
        /// <private/>
        protected bool _FillBuildArmaturePackage(BuildArmaturePackage dataPackage,
                                                 string dragonBonesName,
                                                 string armatureName,
                                                 string skinName,
                                                 string textureAtlasName)
        {
            DragonBonesData dragonBonesData = null;
            ArmatureData    armatureData    = null;

            var isAvailableName = !string.IsNullOrEmpty(dragonBonesName);

            if (isAvailableName)
            {
                if (this._dragonBonesDataMap.ContainsKey(dragonBonesName))
                {
                    dragonBonesData = this._dragonBonesDataMap[dragonBonesName];
                    armatureData    = dragonBonesData.GetArmature(armatureName);
                }
            }

            if (armatureData == null && (!isAvailableName || this.autoSearch))
            {
                // Will be search all data, if do not give a data name or the autoSearch is true.
                foreach (var key in this._dragonBonesDataMap.Keys)
                {
                    dragonBonesData = this._dragonBonesDataMap[key];
                    if (!isAvailableName || dragonBonesData.autoSearch)
                    {
                        armatureData = dragonBonesData.GetArmature(armatureName);
                        if (armatureData != null)
                        {
                            dragonBonesName = key;
                            break;
                        }
                    }
                }
            }

            if (armatureData != null)
            {
                dataPackage.dataName         = dragonBonesName;
                dataPackage.textureAtlasName = textureAtlasName;
                dataPackage.data             = dragonBonesData;
                dataPackage.armature         = armatureData;
                dataPackage.skin             = null;

                if (!string.IsNullOrEmpty(skinName))
                {
                    dataPackage.skin = armatureData.GetSkin(skinName);
                    if (dataPackage.skin == null && this.autoSearch)
                    {
                        foreach (var k in this._dragonBonesDataMap.Keys)
                        {
                            var skinDragonBonesData = this._dragonBonesDataMap[k];
                            var skinArmatureData    = skinDragonBonesData.GetArmature(skinName);
                            if (skinArmatureData != null)
                            {
                                dataPackage.skin = skinArmatureData.defaultSkin;
                                break;
                            }
                        }
                    }
                }

                if (dataPackage.skin == null)
                {
                    dataPackage.skin = armatureData.defaultSkin;
                }

                return(true);
            }

            return(false);
        }