当前位置: 首页>>代码示例>>C#>>正文


C# NSDictionary.GetEnumerator方法代码示例

本文整理汇总了C#中NSDictionary.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# NSDictionary.GetEnumerator方法的具体用法?C# NSDictionary.GetEnumerator怎么用?C# NSDictionary.GetEnumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSDictionary的用法示例。


在下文中一共展示了NSDictionary.GetEnumerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: parseVersion1

		void parseVersion1(NSDictionary animations)
		{
			CCSpriteFrameCache frameCache = CCSpriteFrameCache.sharedSpriteFrameCache;

			var enumerator = animations.GetEnumerator();
			while (enumerator.MoveNext()) {
				KeyValuePair<object, object> kv = enumerator.Current;
				string name = (string)kv.Key;
				NSDictionary animationDict = (NSDictionary)kv.Value;
				ArrayList frameNames = (ArrayList)animationDict["frames"];
				float delay = (float)animationDict["delay"];
				CCAnimation animation = null;
				
				if ( frameNames == null ) {
					CCDebug.Log("cocos2d: CCAnimationCache: Animation '{0}' found in dictionary without any frames - cannot add to animation cache.", name);
					continue;
				}
				
				List<CCAnimationFrame> frames = new List<CCAnimationFrame>(frameNames.Count);

				var framesEnumerator = frameNames.GetEnumerator();
				while (framesEnumerator.MoveNext()) {
					string frameName = (string)framesEnumerator.Current;
					CCSpriteFrame spriteFrame = frameCache.spriteFrameByName(frameName);
					
					if ( spriteFrame == null ) {
						CCDebug.Log("cocos2d: CCAnimationCache: Animation '{0}' refers to frame '{1}' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name, frameName);
						
						continue;
					}
					
					CCAnimationFrame animFrame = new CCAnimationFrame(spriteFrame, 1, null);
					frames.Add(animFrame);
				}
				
				if ( frames.Count == 0 ) {
					CCDebug.Log("cocos2d: CCAnimationCache: None of the frames for animation '{0}' were found in the CCSpriteFrameCache. Animation is not being added to the Animation Cache.", name);
					continue;
				} else if ( frames.Count != frameNames.Count ) {
					CCDebug.Log("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '{0}' may be missing.", name);
				}
				
				animation = new CCAnimation(frames, delay, 1);
				
				CCAnimationCache.sharedAnimationCache.addAnimation(animation, name);
			}	
		}
开发者ID:BigWoodGames,项目名称:cocos2d-unity,代码行数:47,代码来源:CCAnimationCache.cs

示例2: parseVersion2

		void parseVersion2(NSDictionary animations)
		{
			CCSpriteFrameCache frameCache = CCSpriteFrameCache.sharedSpriteFrameCache;

			var enumerator = animations.GetEnumerator();
			while (enumerator.MoveNext()) {
				KeyValuePair<object, object> kv = enumerator.Current;
				string name = (string)kv.Key;
				NSDictionary animationDict = (NSDictionary)kv.Value;
				
				int loops = 0;
				object loopsObj = loops;
				if(!animationDict.TryGetValue("loops", out loopsObj)){
					loops = 1;
				}else{
					loops = (int)loopsObj;
				}
				bool restoreOriginalFrame = (bool)animationDict["restoreOriginalFrame"];
				NSArray frameArray = (NSArray)animationDict["frames"];
				
				
				if ( frameArray == null ) {
					CCDebug.Log(@"cocos2d: CCAnimationCache: Animation '%@' found in dictionary without any frames - cannot add to animation cache.", name);
					continue;
				}
				
				// Array of AnimationFrames
				List<CCAnimationFrame> array = new List<CCAnimationFrame>(frameArray.Count);
				var frameArrayEnumerator = frameArray.GetEnumerator();
				while (frameArrayEnumerator.MoveNext()) {
					NSDictionary entry = (NSDictionary)frameArrayEnumerator.Current;
					string spriteFrameName = (string)entry["spriteframe"];
					CCSpriteFrame spriteFrame = frameCache.spriteFrameByName(spriteFrameName);
					
					if(  spriteFrame==null ) {
						CCDebug.Log("cocos2d: CCAnimationCache: Animation '{0}' refers to frame '{1}' which is not currently in the CCSpriteFrameCache. This frame will not be added to the animation.", name, spriteFrameName);
						
						continue;
					}
					
					float delayUnits = float.Parse(entry["delayUnits"].ToString());
					NSDictionary userInfo = entry.objectForKey<NSDictionary>("notification");
					
					CCAnimationFrame animFrame = new CCAnimationFrame(spriteFrame, delayUnits, userInfo);
					
					array.Add(animFrame);
				}
				
				float delayPerUnit = (float)animationDict["delayPerUnit"];
				CCAnimation animation = new CCAnimation (array, delayPerUnit, (uint)loops);
				
				animation.restoreOriginalFrame=restoreOriginalFrame;
				
				CCAnimationCache.sharedAnimationCache.addAnimation(animation, name);
			}
		}
开发者ID:BigWoodGames,项目名称:cocos2d-unity,代码行数:56,代码来源:CCAnimationCache.cs

示例3: WriteDictionaryValues

		static void WriteDictionaryValues(NSDictionary dictionary, XmlWriter writer)
		{
			writer.WriteStartElement("dict");

			var enumerator = dictionary.GetEnumerator();
			while (enumerator.MoveNext()) {
				KeyValuePair<object, object> kv = enumerator.Current;
				object value = kv.Value;
				if(value!=null){
					writer.WriteElementString("key", kv.Key.ToString());
					Compose(value, writer);
				}
			}

			writer.WriteEndElement();
		}
开发者ID:BigWoodGames,项目名称:cocos2d-unity,代码行数:16,代码来源:NSColletionUtils.cs


注:本文中的NSDictionary.GetEnumerator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。