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


C# Grid.UpdatePoints方法代码示例

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


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

示例1: Generate

						public static List<GPoint> Generate (Grid g, GPoint.PType walkType, int steps)
						{
								//make the last direction random, to randomise the opposite of the first direction
								//start at 1
								//pick a new direction
								//if the direction is okay
								//move the test vector
								//if the new position is in bounds
								//add the point
								//iterate the loop
								//set the last direction to the new direction
								List<GPoint> points = new List<GPoint> ();
								//set the scanpoint in the middle of the grid
								ScanPoint scan = new ScanPoint (g.GetSize () / 2);
								//set the last direction as a new direction
								Direction lastDir = PickNewDirection ();
								//set the stepcount at 1
								int stepcount = 1;
								//if the stepcount is less than or equal to the max number of steps
								while (stepcount<=steps) {
										//pick a new direction and set it as the new direction
										Direction newDir = PickNewDirection ();
										//if the new direction is not the opposite of the last direction
										if (IsValidDirection (newDir, lastDir)) {
												//move the testposition in the new direction
												Vector2 testPos = scan.VirtualMove (newDir);
												//check if the new position is within the constraints
												if (g.PositionInBounds (testPos)) {
														//if it is, move the scanpoint in the direction
														scan.Move (newDir);
														//iterate the stepcount
														stepcount++;
														//add a new gpoint to the list of the designated type
														points.Add (new GPoint (scan.Position (), walkType));
														//Debug.Log ("point added to grid at " + scan.Position ());
												}
												//set the last dir to the new dir to ensure accurate direction checking
												//when the loop repeats
												lastDir = newDir;
										}
										//otherwise, do absolutely nothing
								}
								Debug.Log ("generated a " + points.Count + " point line of " + walkType);
								Grid tg = new Grid (g);
								tg.Clear ();
								tg.UpdatePoints (points);
								List<GPoint> processed = new List<GPoint> ();
								processed = PostProcess (tg, walkType, walkType);
								return processed;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:50,代码来源:CityMaker.cs

示例2: MergeGrids

				static Grid MergeGrids (Grid a, Grid b)
				{
						a.UpdatePoints (b);
						return a;
				}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:5,代码来源:CityMaker.cs

示例3: FixRoads

						public static List<GPoint> FixRoads (Grid g, List<GPoint> rVHplusO, Vector2 blockSize)
						{
								//we will need to create a temporary grid that contains all of the new points
								//then iterate through it by the blocksize as done earlier
								//for each intersection check if there is a road to the left or down
								//if there is one left, then create a vertical road as done earlier
								//if there is one down, then create a horizontal road as done earlier
								//also create an intersection at the point
								List<GPoint> fixedRoads = new List<GPoint> ();
								Grid tG = new Grid (g);
								tG.Fill (GPoint.PType.TILE_GRASS);
								tG.UpdatePoints (rVHplusO);
								for (float ix=1.0f; ix<tG.GetXYMax().x; ix+=blockSize.x) {
										//iterate up by blocksize
										for (float iy=1.0f; iy<tG.GetXYMax().y; iy+=blockSize.y) {
												//iterate right by blocksize
												//set the scan point to the current position on the grid
												ScanPoint sp1 = new ScanPoint (new Vector2 (ix, iy));
												//move the scanpoint to the left and check if is anything but background
												if (!tG.GetPoint (sp1.VirtualMove (Direction.w)).IsBackgroundTile ()) {
														//create a vertical road blocksize.y units long
														//probably going to do this with a for loop
														fixedRoads.Add (new GPoint (sp1.Position (), GPoint.PType.TILE_ROADI));
														fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x, sp1.Position ().y + blockSize.y), GPoint.PType.TILE_ROADI));
														for (float iy2 = 1.0f; iy2<blockSize.y; iy2+=1.0f) {
																fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x, sp1.Position ().y + iy2), GPoint.PType.TILE_ROADV));
														}
												}
												if (!tG.GetPoint (sp1.VirtualMove (Direction.s)).IsBackgroundTile ()) {
														//create a horizontal road blocksize.x units long
														//probably going to do this with a for loop
														fixedRoads.Add (new GPoint (sp1.Position (), GPoint.PType.TILE_ROADI));
														fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x + blockSize.x, sp1.Position ().y), GPoint.PType.TILE_ROADI));
														for (float ix2 = 1.0f; ix2<blockSize.x; ix2+=1.0f) {
																fixedRoads.Add (new GPoint (new Vector2 (sp1.Position ().x + ix2, sp1.Position ().y), GPoint.PType.TILE_ROADH));
														}
												}
										}
								}
								return fixedRoads;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:41,代码来源:CityMaker.cs

示例4: MergeBufferDown

				public static Grid MergeBufferDown (List<Grid> buffer, Grid g)
				{
						//Debug.Log ("merging the buffer to the game grid...");
						//Grid outputGrid = new Grid (g);
						foreach (Grid bg in buffer) {
								//Debug.Log ("merging a grid");
								g.UpdatePoints (MergeGrids (g, bg));
						}
						return g;
				}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:10,代码来源:CityMaker.cs


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