private static ArmatureData parseArmatureData(Dictionary<String, Object> armatureObject, SkeletonData data, uint frameRate)
		{
			ArmatureData armatureData = new ArmatureData();
			armatureData.Name = armatureObject[ConstValues.A_NAME] as String;

			//Logger.Log("ObjectDataParser::: " + armatureObject[ConstValues.BONE].ToString());
			foreach(Dictionary<String, Object> boneObject in armatureObject[ConstValues.BONE] as List<object>)
			{

				armatureData.AddBoneData(parseBoneData(boneObject as Dictionary<string, object>));
			}
			
			foreach(Dictionary<String, Object> skinObject in armatureObject[ConstValues.SKIN] as List<object>)
			{
				armatureData.AddSkinData(parseSkinData(skinObject as Dictionary<string, object>, data));
			}
			
			DBDataUtil.TransformArmatureData(armatureData);
			armatureData.SortBoneDataList();
			
			foreach(Dictionary<String, Object> animationObject in armatureObject[ConstValues.ANIMATION] as List<object>)
			{
				armatureData.AddAnimationData(parseAnimationData(animationObject as Dictionary<string, object>, armatureData, frameRate));
			}
			
			return armatureData;
		}
		public static SkeletonData ParseSkeletonData(Dictionary<string, Object> rawData)
		{
			if(rawData == null)
			{
				throw new ArgumentException();
			}
			
			string version = rawData[ConstValues.A_VERSION].ToString();

			switch (version)
			{
			case DragonBones.Core.DragonBones.DATA_VERSION:
				break;
			default:
				throw new Exception("Nonsupport version!");
			}
			
			uint frameRate =  uint.Parse(rawData[ConstValues.A_FRAME_RATE].ToString());

			SkeletonData data = new SkeletonData();
			data.Name = rawData[ConstValues.A_NAME] as String;

			foreach(Dictionary<String, Object> armatureObject in rawData[ConstValues.ARMATURE] as List<Object>)
			{

				data.AddArmatureData(parseArmatureData(armatureObject as Dictionary<string, object>, data, frameRate));
			}

			return data;
		}
		private static DisplayData parseDisplayData(Dictionary<String, Object> displayObject, SkeletonData data)
		{
			DisplayData displayData = new DisplayData();
			displayData.Name = displayObject[ConstValues.A_NAME] as String;
			displayData.Type = displayObject[ConstValues.A_TYPE] as String;
			
			displayData.Pivot = data.AddSubTexturePivot(
				0, 
				0, 
				displayData.Name
				);
			
			parseTransform(displayObject[ConstValues.TRANSFORM] as Dictionary<String, object>, displayData.Transform, displayData.Pivot);
			
			return displayData;
		}
		private static SlotData parseSlotData(Dictionary<String, Object> slotObject, SkeletonData data)
		{
			SlotData slotData = new SlotData();
			slotData.Name = slotObject[ConstValues.A_NAME] as String;
			slotData.Parent = slotObject[ConstValues.A_PARENT] as String;
			slotData.ZOrder = (float)slotObject[ConstValues.A_Z_ORDER];

			if (slotObject.ContainsKey (ConstValues.A_BLENDMODE)) {
			  
			  if (slotObject [ConstValues.A_BLENDMODE] == null) 
			  {
				slotData.BlendMode = "normal";
			  }
			  else
			  {
				slotData.BlendMode = slotObject [ConstValues.A_BLENDMODE].ToString();
			  }
			}
			foreach(Dictionary<String, Object> displayObject in slotObject[ConstValues.DISPLAY] as List<object>)
			{
				slotData.AddDisplayData(parseDisplayData(displayObject as Dictionary<string, object>, data));
			}
			
			return slotData;
		}
		private static SkinData parseSkinData(Dictionary<String, Object> skinObject, SkeletonData data)
		{
			SkinData skinData = new SkinData();
			skinData.Name = skinObject[ConstValues.A_NAME] as String;
			
			foreach(Dictionary<String, Object> slotObject in skinObject[ConstValues.SLOT] as List<object>)
			{
				skinData.AddSlotData(parseSlotData(slotObject as Dictionary<string, object>, data));
			}
			
			return skinData;
		}
Ejemplo n.º 6
0
		/**
		 * Add a SkeletonData instance to this BaseFactory instance.
		 * @example 
		 * <listing>
		 * factory.addSkeletonData(data, 'dragon');
		 * </listing>
		 * @param	A SkeletonData instance.
		 * @param	(optional) A name for this SkeletonData instance.
		 */
		public void AddSkeletonData(SkeletonData data, string name = null)
		{
			if(data == null)
			{
				throw new ArgumentException();
			}

			if (name == null) 
			{
				name = data.Name;
			}
			if(name == null)
			{
				throw new ArgumentException("Unnamed data!");
			}
			if(_dataDic.ContainsKey(name))
			 if(_dataDic[name]!=null)
			 {
				
			 }
			_dataDic[name] = data;


		}