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


C# MapData.GetNode方法代码示例

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


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

示例1: CreateSubMesh

	Mesh CreateSubMesh(MapData data, int xOffset, int zOffset, int patchXCount, int patchZCount, float size, Vector3 offset)
	{
		Mesh mesh = new Mesh();

		int vCount = patchXCount * patchZCount * 4;
		Vector3[] pts = new Vector3[vCount];
		Color[] colors = new Color[vCount];
		int[] indices = new int[vCount * 2];


		size *= 0.5f;
		Vector3[] squareBias = new Vector3[4]{ new Vector3(-size, 0, -size)
											,new Vector3(-size, 0, size)
											,new Vector3(size, 0, size)
											 ,new Vector3(size, 0, -size)	};

		//Vector3 offset = GetOffset() + bia;

		int i = 0;
		for (int z = zOffset; z < zOffset + patchZCount; z++)
		{
			for (int x = xOffset; x < xOffset + patchXCount; x++)
			{
				MapData.MapNode node = data.GetNode(x, z);
				Vector3[] neighbours = data.GetNeighbourOffset(x, z);
				Vector3 center = node.Position;
				Color vertexColor = node.IsWayPoint ? wayPointColor : node.IsReachable ? reachableColor : notReachableColor;

				pts[i * 4] = center + squareBias[0] + offset + neighbours[0];
				pts[i * 4 + 1] = center + squareBias[1] + offset + neighbours[1];
				pts[i * 4 + 2] = center + squareBias[2] + offset + neighbours[2];
				pts[i * 4 + 3] = center + squareBias[3] + offset + neighbours[3];

				int start = i * 4;
				for (int j = 0; j < 4; j++)
				{
					colors[start + j] = vertexColor;
				}

				indices[i * 8] = start; indices[i * 8 + 1] = start + 1;
				indices[i * 8 + 2] = start + 1; indices[i * 8 + 3] = start + 2;
				indices[i * 8 + 4] = start + 2; indices[i * 8 + 5] = start + 3;
				indices[i * 8 + 6] = start + 3; indices[i * 8 + 7] = start;
				i++;
			}
		}

		mesh.vertices = pts;
		mesh.colors = colors;
		//mesh.SetIndices(indices, MeshTopology.Lines, 0);
		mesh.SetIndices(indices, MeshTopology.Quads, 0);

		return mesh;
	}
开发者ID:fengqk,项目名称:Art,代码行数:54,代码来源:MapDrawer.cs

示例2: SaveAutoMove

	void SaveAutoMove(MapData mapData)
	{
		int xC = mapData.xCount;
		int zC = mapData.zCount;
		var pImg = AutoMove.exp_CreateBitImage(xC, zC);

		int r = 0;
		int notR = 0;
		for (int z = zC - 1; z >= 0; z--)
		{
			for (int x = 0; x < xC; x++)
			{
				AutoMove.exp_SetBitImagePixel(pImg, x, z, mapData.GetNode(x, z).IsReachable);
				if (mapData.GetNode(x, z).IsReachable)
					r++;
				else
				{
					notR++;
				}
			}
		}
		string path = SampleHeightAndReachableV3.GetSavePath(EditorApplication.currentScene);
		string fullName = System.IO.Path.Combine(path, thisTarget.GetRFileName(EditorApplication.currentScene));
		Debug.Log(string.Format("path: {0}  r {1}  notR {2}", fullName, r, notR));
		AutoMove.exp_SaveBitImage(pImg, fullName);
		AutoMove.exp_ReleaseBitImage(pImg);

	}
开发者ID:fengqk,项目名称:Art,代码行数:28,代码来源:SampleHeightAndReachableV3_Inspector.cs

示例3: SetCenter

	public void SetCenter(int x, int z, MapData data, bool forceUpdate = false)
	{
		if (!forceUpdate && lastCenterX == x && lastCenterZ == z)
		{
			return;
		}

		for (int i = 0; i < enabledCount; i++)
		{
			int _x = x + offsetX[i];
			int _z = z + offsetZ[i];

			if (_x >= 0 && _x < data.xCount)
			{
				if (_z >= 0 && _z < data.zCount)
				{
					subObjs[i].SetActive(true);

					subObjs[i].transform.position = data.GetNode(_x, _z).Position + GetOffset();
				}
			}
		}
		if (subObjs.Count > enabledCount)
		{
			for (int i = enabledCount; i < subObjs.Count; i++)
			{
				subObjs[i].SetActive(false);
			}
		}
		lastCenterX = x;
		lastCenterZ = z;

	}
开发者ID:fengqk,项目名称:Art,代码行数:33,代码来源:MapDrawer.cs

示例4: HeightInEngineOrder

	float[] HeightInEngineOrder(MapData data)
	{
		//int xMax = heights.Length;
		int xMax = data.xCount;
		int zMax = data.zCount;

		if (xMax <= 0)
		{
			Debug.LogError("Empty heights");
			return null;
		}
		//int zMax = heights[0].Length;

		int size = (xMax + 1) * (zMax + 1);
		float[] result = new float[size];

		MapData.MapNode node = data.GetNode(0, 0);



		{	// get data (n+1) * (n+1)
			int i = 0;
			for (int x = 0; x < xMax; x++)
			{
				result[i++] = data.GetNode(x, zMax - 1).GetNeighborHeight(0, 1);
				if (x == xMax - 1)
				{
					result[i++] = data.GetNode(x, zMax - 1).GetNeighborHeight(1, 1);

				}

			}

			for (int z = zMax - 1; z >= 0; z--)
			{
				for (int x = 0; x < xMax; x++)
				{
					//result[i++] = heights[x][z];
					//result[i++] = data.GetNode(x, z).Height;
					result[i++] = data.GetNode(x, z).GetNeighborHeight(0, 0);
					if (x == xMax - 1)
					{
						result[i++] = data.GetNode(x, z).GetNeighborHeight(1, 0);
					}
				}
			}


			if (i != size)
			{
				Debug.LogError("NotSameSize");
			}
		}

		return result;
	}
开发者ID:fengqk,项目名称:Art,代码行数:56,代码来源:SampleHeightAndReachableV3_Inspector.cs


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