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


C# Grid.GetXYMax方法代码示例

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


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

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

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


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