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


C# MapData.GetNeighbourOffset方法代码示例

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


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


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