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


C# Layout.CheckIfOnEdge方法代码示例

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


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

示例1: GetMineSpriteNameForTile

	public static List<string> GetMineSpriteNameForTile(int x, int y, string[,] nsewMap, Layout layout, Grid grid, PseudoRandom prnd)
	{
		List<string> nameList = new List<string> ();
		string nsewData = nsewMap [y, x];

		if (!layout.IsOpen(x,y)) 
		{	
			nameList.Add("Mine_Empty"); 
			string spriteName = "Mine_Edge" + nsewData;

			if (CheckSpriteExists (spriteName)) {
				nameList.Add("Mine_Edge" + nsewData);
			} else {
				char[] data = nsewData.ToCharArray ();
				for(int i = 1; i < data.Length; i++){
					string newSpriteName = "Mine_Edge" + "_" + data[i].ToString(); 
					Debug.Log (nsewData);
					if (CheckSpriteExists (newSpriteName)) {
						nameList.Add ("Mine_Edge" + "_" + data[i].ToString());
					}
				}
			}

			if (layout.CheckIfOnEdge (x, y)) 
			{
				if (x + 1 < grid.width && y + 1 < grid.height && !layout.IsOpen(x+1,y) && !layout.IsOpen(x,y+1) && layout.IsOpen(x+1,y+1)) 
				{
					nameList.Add ("Mine_Edge_Corner" + "_NE");
				}

				if (x - 1 >= 0 && y + 1 < grid.height && !layout.IsOpen(x-1,y) && !layout.IsOpen(x,y+1) && layout.IsOpen(x-1,y+1)) 
				{
					nameList.Add ("Mine_Edge_Corner" + "_NW");
				}

				if (x + 1 < grid.width && y - 1 >= 0 && !layout.IsOpen(x+1,y) && !layout.IsOpen(x,y-1) && layout.IsOpen(x+1,y-1)) 
				{
					nameList.Add ("Mine_Edge_Corner" + "_SE");
				}

				if (x - 1 >= 0 && y - 1 >= 0 && !layout.IsOpen(x-1,y) && !layout.IsOpen(x,y-1) && layout.IsOpen(x-1,y-1)) 
				{
					nameList.Add ("Mine_Edge_Corner" + "_SW");
				}
			}
		} 
		else 
		{
			string num = prnd.Next (1, 4).ToString ();
			nameList.Add("Mine_Floor_" + num);

			if (prnd.Next () < 0.1) {
				string decalNum = prnd.Next (1, 10).ToString ();
				nameList.Add("Mine_Floor_Decal_" + decalNum);
			}

			string insideNsewData = NSEWMap.GetNSEWString(layout.layout, x, y, 0);
			if (insideNsewData.Contains ("N")) {
				string shadowTile = "Mine_Floor_Shadow_";
				if (insideNsewData.Contains ("E") && nsewData.Contains ("W")) {
					nameList.Add (shadowTile + "NE");
					nameList.Add (shadowTile + "NW");
				} else if (insideNsewData.Contains ("E")) {
					nameList.Add (shadowTile + "NE");
				} else if (insideNsewData.Contains ("W")) {
					nameList.Add (shadowTile + "NW");
				} else {
					nameList.Add (shadowTile + "N");
				}
			}
		}

		return nameList; 
	}
开发者ID:JackUnthank,项目名称:Portfolio,代码行数:74,代码来源:DungeonSetup.cs

示例2: CreateForestMeshFromMap

	public static void CreateForestMeshFromMap(Layout layout, Grid grid, int seedX, int seedY, int seedZ)
	{
		Texture2D tex = CreateForestTextureFromMap (layout.layout, grid, seedX, seedY, seedZ);
		Rect rec = new Rect (0, 0, grid.width*16, grid.height*16);
		//Hardcoded Paths
		GameObject blankObj = Resources.Load ("Prefabs/BlankSprite") as GameObject;
		GameObject blockObj = Resources.Load ("Prefabs/BlankInter") as GameObject;

		Vector3 vec = new Vector3 ( ((float)(grid.width))/2, ((float)(grid.height))/2, 1);

		GameObject obj = (GameObject) Instantiate (blankObj, vec, Quaternion.identity);

		Sprite sprite = Sprite.Create(tex, rec, new Vector2(0.5f, 0.5f), 16);

		PseudoRandom prnd = new PseudoRandom (seedX, seedY, seedZ);

		obj.GetComponent<SpriteRenderer> ().sprite = sprite;
		SceneObjects.AddObjectToScene (obj);

		for (int y = 0; y < grid.height; y++) {
			for (int x = 0; x < grid.width; x++) {
				// Create Invisible wall rigidbodys
				if (layout.CheckIfOnEdge(x,y)){
					//GameObject objr = (GameObject)Instantiate (blockObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
					//SceneObjects.AddObjectToScene (objr);
				}
				else if (layout.CheckIfNextToEdge(x,y))// Create wall leaves. 
				{
					int num = prnd.Next (1, 3);
					string nsewData = NSEWMap.GetNSEWString(layout.layout, x, y, 0);
					if (nsewData.Length > 3) {
						num = 1; 
					}
					string spriteName = "Forest_Leaf" + nsewData + "_" + num.ToString (); 

					if (CheckSpriteExists (spriteName)) {
						GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
						objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
						objr.GetComponent<SpriteRenderer> ().sortingOrder = 100;
						SceneObjects.AddObjectToScene (objr);
					} 
				}

				if (layout.IsOpen (x, y)) 
				{
					double chance = prnd.Next (); 
					if (chance < 0.01) {
						int num = prnd.Next (1, 4);
						string spriteName = "Forest_Mush_" + num.ToString();
						GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
						objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
						SceneObjects.AddObjectToScene (objr);
					}
					else if(chance >= 0.01 && chance < 0.02) 
					{
						int num = prnd.Next (1, 5);
						string spriteName = "Forest_Rock_" + num.ToString();
						GameObject objr = (GameObject)Instantiate (blankObj, new Vector3 (grid.GetCoords (x, y).x, grid.GetCoords (x, y).y, 0), Quaternion.identity);
						objr.GetComponent<SpriteRenderer> ().sprite = GetSprite (spriteName);
						SceneObjects.AddObjectToScene (objr);
					}
				}
			}
		}
	}
开发者ID:JackUnthank,项目名称:Portfolio,代码行数:65,代码来源:ForestSetup.cs


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