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


C# GPoint.GetPosition方法代码示例

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


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

示例1: CoDestroyTiles

    GameTile[,] tiles; // = new GameTile[,];

    #endregion Fields

    #region Methods

    IEnumerator CoDestroyTiles()
    {
        NotificationCenter.DefaultCenter.PostNotification (this, "Destroy");
                yield return new WaitForSeconds (0.01f);
                for (int ix =0; ix<tiles.GetLength(0); ix++) {
                        for (int iy =0; iy <tiles.GetLength(1); iy++) {
                                //GameTile tile = ;
                                if (!tiles [ix, iy]) {
                                        GPoint gP = new GPoint (new Vector2 (ix + 1, iy + 1), GPoint.PType.TILE_DESTROYED);
                                        GameObject newTile = (GameObject)Instantiate (destroyedTile, gP.GetWorldPosition (), Quaternion.identity);
                                        newTile.name = "/x:" + gP.GetPosition ().x + "$/y:" + gP.GetPosition ().y + "$/t:" + gP.GetPType () + "$";
                                        newTile.transform.parent = transform;
                                        tiles [ix, iy] = newTile.GetComponent<GameTile> ();
                                        tiles [ix, iy].SetData ();
                                }
                        }
                }
                AStarGrid.Scan ();
                StopCoroutine ("CoDestroyTiles");
    }
开发者ID:informem,项目名称:MyUnityScripts,代码行数:26,代码来源:GameGridManager.cs

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

示例3: InstantiateTile

				public void InstantiateTile (GPoint gp)
				{
						int index = 0;
						switch (gp.GetPType ()) {
						case GPoint.PType.DEBUG:
								index = 0;
								break;
						case GPoint.PType.TILE_TEST:
								index = 1;
								break;
						case GPoint.PType.TILE_GRASS:
								index = 2;
								break;
						case GPoint.PType.TILE_SAND:
								index = 3;
								break;
						case GPoint.PType.TILE_ROADI:
								index = 4;
								break;
						case GPoint.PType.TILE_ROADH:
								index = 5;
								break;
						case GPoint.PType.TILE_ROADV:
								index = 6;
								break;
						case GPoint.PType.TILE_TREE:
								index = 7;
								break;
						case GPoint.PType.TILE_BUILDING:
								index = 8;
								break;
						case GPoint.PType.TILE_HOUSE:
								index = 9;
								break;
						default:
								index = -1;
								break;
						}
						if (index >= 0) {
								float scale = 1;
								GameObject newTile = null;
								//Destroy (newTile);
								if (index < 8) {
										newTile = (GameObject)Instantiate (tilePrefabs [index], gp.GetWorldPosition (), Quaternion.identity);
										if (index == 7) {
												scale = Random.Range (0.75f, 1.25f);
										}
								} else if (index == 8) {
										int addup = Random.Range (0, buildingPrefabs.Count ());
										scale = Random.Range (0.75f, 1.25f);
										newTile = (GameObject)Instantiate (buildingPrefabs [addup], gp.GetWorldPosition (), Quaternion.identity);
								} else if (index == 9) {
										int addup = Random.Range (0, housePrefabs.Count ());
										newTile = (GameObject)Instantiate (housePrefabs [addup], gp.GetWorldPosition (), Quaternion.identity);
								}
								newTile.name = "/x:" + gp.GetPosition ().x + "$/y:" + gp.GetPosition ().y + "$/t:" + gp.GetPType () + "$";
								newTile.transform.parent = tilePool.transform;
								newTile.transform.localScale = new Vector3 (1, scale, 1);
								if (gp.GetPType () == GPoint.PType.TILE_BUILDING || gp.GetPType () == GPoint.PType.TILE_HOUSE) {
										switch (gp.GetDirection ()) {
										case GPoint.Direction.NORTH:
												//Debug.Log ("tile turned north");
												newTile.transform.LookAt (newTile.transform.position + Vector3.back);
												//newTile.transform.Translate (Vector3.up * 1);
												break;
										case GPoint.Direction.SOUTH:
												//Debug.Log ("tile turned south");
												newTile.transform.LookAt (newTile.transform.position + Vector3.forward);
												//newTile.transform.Translate (Vector3.up * 2);
					
												break;
										case GPoint.Direction.EAST:
												//Debug.Log ("tile turned east");
												newTile.transform.LookAt (newTile.transform.position + Vector3.left);
												//newTile.transform.Translate (Vector3.up * 3);
												break;
										case GPoint.Direction.WEST:
												//Debug.Log ("tile turned west");
												newTile.transform.LookAt (newTile.transform.position + Vector3.right);
												//newTile.transform.Translate (Vector3.up * 4);
												break;
										default:
												break;
										}
										;
								}
						}
				}
开发者ID:informem,项目名称:MyUnityScripts,代码行数:88,代码来源:CityMaker.cs


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