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


C# Grid.GetPoint方法代码示例

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


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

示例1: ProcessPoint

						private static bool ProcessPoint (Grid g, ScanPoint sc, GPoint.PType st, List<Direction[]> scanMethod)
						{
				
								foreach (Direction[] dpat in scanMethod) {
										bool match = true;
										/*if (g.GetPoint (sc.VirtualMove (dpat [0])).GetPType () == st &&
												g.GetPoint (sc.VirtualMove (dpat [1])).GetPType () == st &&
												g.GetPoint (sc.VirtualMove (dpat [2])).GetPType () == st) {
												return true;
										}*/
										for (int i =0; i <dpat.Length; i++) {
												if (g.GetPoint (sc.VirtualMove (dpat [i])).GetPType () != st) {
														match = false;
												}
										}
										if (match) {
												return match;
										}
								}
								return false;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:21,代码来源:CityMaker.cs

示例2: Generate

						public static List<GPoint> Generate (Grid g, int numOfTrees)
						{
								List<GPoint> trees = new List<GPoint> ();
								int i = 0;
								while (i < numOfTrees) {
										int rX = (int)Random.Range (g.GetXYMin ().x, g.GetXYMax ().x);
										int rY = (int)Random.Range (g.GetXYMin ().y, g.GetXYMax ().y);
										if (g.GetPoint (rX, rY).GetPType () == GPoint.PType.TILE_GRASS) {
												trees.Add (new GPoint (new Vector2 ((float)rX, (float)rY), GPoint.PType.TILE_TREE));
												i++;
										}
								}
								return trees;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:14,代码来源:CityMaker.cs

示例3: FindRoadOrigins

						public static List<GPoint> FindRoadOrigins (Grid g, Vector2 blockSize)
						{
								List<GPoint> roadOrigins = new List<GPoint> ();
								//iterate right by blocksize
								for (float ix=1.0f; ix<g.GetXYMax().x; ix+=blockSize.x) {
										//iterate up by blocksize
										for (float iy=1.0f; iy<g.GetXYMax().y; iy+=blockSize.y) {
												//start at the next block right and up
												//so the previous iteration set is the 1
												//and where this iteration set starts is the 2
												//this is because we start at ix2 = 1.0f and iy2 = 1.0f
												//10000100001
												//00000000000
												//02000020000
												//10000100001
												//iterate right
												for (float ix2=1.0f; ix2<blockSize.x; ix2+=1.0f) {
														//iterate up
														for (float iy2=1.0f; iy2<blockSize.y; iy2+=1.0f) {
																//check if the tile at the given point is anything other
																//than a background tile
																if (!g.GetPoint (new Vector2 (ix + ix2, iy + iy2)).IsBackgroundTile ()) {
																		//if it is, then add a road intersection at start point
																		roadOrigins.Add (new GPoint (new Vector2 (ix, iy), GPoint.PType.TILE_ROADI));
																}
														}
												}
												
										}
								}
								return roadOrigins;
						}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:32,代码来源:CityMaker.cs

示例4: 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

示例5: CalculateDirection

				public static GPoint.Direction CalculateDirection (Grid g, GPoint gp)
				{
						ScanPoint scp = new ScanPoint (gp.GetPosition ());
						List<string> dirs = new List<string> ();
						string direction = "";
						switch (g.GetPoint (scp.VirtualMove (Direction.n)).GetPType ()) {
						case GPoint.PType.TILE_ROADH:
								dirs.Add ("N");
								break;
						case GPoint.PType.TILE_ROADV:
								dirs.Add ("N");
								break;
						default:
				//nothing
								break;
						}
						
						switch (g.GetPoint (scp.VirtualMove (Direction.s)).GetPType ()) {
						case GPoint.PType.TILE_ROADH:
								dirs.Add ("S");
								break;
						case GPoint.PType.TILE_ROADV:
								dirs.Add ("S");
								break;
						default:
				//nothing
								break;
						}
						
						switch (g.GetPoint (scp.VirtualMove (Direction.e)).GetPType ()) {
						case GPoint.PType.TILE_ROADH:
								dirs.Add ("E");
								break;
						case GPoint.PType.TILE_ROADV:
								dirs.Add ("E");
								break;
						default:
				//nothing
								break;
								
						}
						
						switch (g.GetPoint (scp.VirtualMove (Direction.w)).GetPType ()) {
						case GPoint.PType.TILE_ROADH:
								dirs.Add ("W");
								break;
						case GPoint.PType.TILE_ROADV:
								dirs.Add ("W");
								break;
						default:
				//nothing
								break;
						}
/*						foreach (string s in dirs) {
								Debug.Log (s);
						}*/
						int val = (int)Random.Range (0, dirs.Count ());
						//Debug.Log ("integer " + val);
						//Debug.Log ("directions " + dirs.Count ());
						direction = dirs.ElementAt (val);
						//Debug.Log ("direction chosen" + direction);
						switch (direction) {
						case "N":
								//Debug.Log ("turn north");
								return GPoint.Direction.NORTH;
						//break;
						case "S":
								//Debug.Log ("turn south");
								return GPoint.Direction.SOUTH;
						//break;
						case "E":
								//Debug.Log ("turn east");
								return GPoint.Direction.EAST;
						//break;
						case "W":
								//Debug.Log ("turn west");
								return GPoint.Direction.WEST;
						//break;
						default:
								return GPoint.Direction.NORTH;
						//break;
						}
						;
						//return GPoint.Direction.NORTH;
				}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:85,代码来源:CityMaker.cs


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