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


C# IEnumerator.Take方法代码示例

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


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

示例1: CreateGuards

		public IEnumerable<SpriteInfoExtended> CreateGuards(IEnumerator<Point> FreeSpaceForStuff, int Count, bool DoAttachGuardLogic)
		{
			for (int i = 0; i < Count; i++)
			{
				var g = CreateGuard();

				GuardSprites.Add(g);

				EgoView.BlockingSprites.Add(g);

				g.ConstructorIndexForSync = i + ConstructorIndexForSync_Guards;
				g.Position = FreeSpaceForStuff.Take();
				g.Direction = 0;

				g.TakeDamage +=
					(damage, DamageOwner) =>
					{
						if (Sync_GuardAddDamage != null)
							Sync_GuardAddDamage(g.ConstructorIndexForSync, damage, DamageOwner);
					};

				// state machine for AI guard

				if (DoAttachGuardLogic)
					AttachGuardLogic(g);


			}

			return GuardSprites;
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:31,代码来源:FlashTreasureHunt.CreateGuards.cs

示例2: CreateGuards

		private void CreateGuards(IEnumerator<TextureBase.Entry> FreeSpaceForStuff)
		{
			for (int i = 0; i < 3; i++)
			{
				var g = CreateGuard();
				g.Position = FreeSpaceForStuff.Take().Do(kk => new Point(kk.XIndex + 0.5, kk.YIndex + 0.5));
				g.Direction = 0;

				// state machine for AI guard

				// each 3 secs turn 90 while not walking
				3000.AtInterval(
					delegate
					{
						if (g.WalkingAnimationRunning)
							return;
						
						var PossibleDestination = g.Position.MoveToArc(g.Direction, 1);

						var AsMapLocation = new PointInt32
						{
							X = PossibleDestination.x.Floor(),
							Y = PossibleDestination.y.Floor()
						};

						if (EgoView.Map.WallMap[AsMapLocation.X, AsMapLocation.Y] == 0)
						{
							// whee we can walk at this direction
							g.StartWalkingAnimation();

							const int StepsToBeTaken  = 100;

							(1000 / 15).AtInterval(
								t =>
								{
									g.Position = g.Position.MoveToArc(g.Direction, 1.0 / (double)StepsToBeTaken);

									if (t.currentCount == StepsToBeTaken)
									{
										t.stop();
										g.StopWalkingAnimation();
									}
								}
							);
							return;
						}

						// can we walk at that direction?
						g.Direction += 90.DegreesToRadians();

					}
				);
			}
		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:54,代码来源:FlashTreasureHunt.CreateGuards.cs

示例3: UpdatePortalPositions

		void UpdatePortalPositions(IEnumerator<TextureBase.Entry> PortalPositions)
		{
			//WriteLine("portals: ");
			foreach (var v in DualPortals)
			{
				var PortalAPos = PortalPositions.Take().Do(u => new Point { x = u.XIndex + 0.5, y = u.YIndex + 0.5 });
				var PortalBPos = PortalPositions.Take().Do(u => new Point { x = u.XIndex + 0.5, y = u.YIndex + 0.5 });

				//WriteLine("A: " + new { PortalAPos.x, PortalAPos.y });
				//WriteLine("B: " + new { PortalBPos.x, PortalBPos.y });

				var PortalADir = GetGoodDirection(PortalAPos);
				var PortalBDir = GetGoodDirection(PortalBPos);


				v.Orange.ViewVector = new Vector { Direction = 0, Position = new Point() };
				v.Orange.ViewVector = new Vector { Direction = PortalADir, Position = PortalAPos };
				v.Orange.SpriteVector = new Vector { Direction = PortalBDir, Position = PortalBPos };

				v.Blue.ViewVector = new Vector { Direction = 0, Position = new Point() };
				v.Blue.ViewVector = v.Orange.SpriteVector;
				v.Blue.SpriteVector = v.Orange.ViewVector;
			}

		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:25,代码来源:FlashTreasureHunt.AddPortals.cs

示例4: UpdatePortalPositions

		public void UpdatePortalPositions(IEnumerator<Point> PortalPositions)
		{
			//WriteLine("portals: ");
			foreach (var v in DualPortals)
			{
				var PortalAPos = PortalPositions.Take();
				var PortalBPos = PortalPositions.Take();

				//WriteLine("A: " + new { PortalAPos.x, PortalAPos.y });
				//WriteLine("B: " + new { PortalBPos.x, PortalBPos.y });

				var PortalADir = GetGoodDirection(PortalAPos);
				var PortalBDir = GetGoodDirection(PortalBPos);


				v.Orange.ViewVector = new RVector { Direction = 0, Position = new Point() };
				v.Orange.ViewVector = new RVector { Direction = PortalADir, Position = PortalAPos };
				v.Orange.SpriteVector = new RVector { Direction = PortalBDir, Position = PortalBPos };

				v.Blue.ViewVector = new RVector { Direction = 0, Position = new Point() };
				v.Blue.ViewVector = v.Orange.SpriteVector;
				v.Blue.SpriteVector = v.Orange.ViewVector;
			}

		}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:25,代码来源:FlashTreasureHunt.AddPortals.cs


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