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


C# MapData.SetNode方法代码示例

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


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

示例1: LoadOldXml

	public static MapData LoadOldXml(string fullPath)
	{

		if (!System.IO.File.Exists(fullPath))
		{
			Debug.LogError(string.Format("File not exists. {0}", fullPath));
			return null;
		}

		MapHeightInfos heightInfos = ChpLibXML.Load<MapHeightInfos>(fullPath);


		
		int xCount = heightInfos.xCount-1;
		int zCount = heightInfos.zCount-1;
		MapData data = new MapData(xCount, zCount);

		for ( int x = 0; x < xCount; x++){
			for ( int z = 0; z < zCount ; z++){
				
				
				float[] neighbourHeights = new float[4];
				neighbourHeights[0] = heightInfos.heights[x][z];
				neighbourHeights[1] = heightInfos.heights[x][z+1];
				neighbourHeights[2] = heightInfos.heights[x+1][z+1];
				neighbourHeights[3] = heightInfos.heights[x+1][z];
				

				float height = (neighbourHeights[0] + neighbourHeights[1] + neighbourHeights[2] + neighbourHeights[3]) / 4f; 
				MapData.MapNode _node = new MapData.MapNode(x,z,1,height, heightInfos.reachables[x][z]
					, heightInfos.isWayPoints[x][z], x == 0 || x == xCount-1 || z == 0 || z == zCount-1);

				
				_node.neighborHeights = neighbourHeights;

				data.SetNode(x, z, _node);
			}
		}


		return data;
	}
开发者ID:fengqk,项目名称:Art,代码行数:42,代码来源:MapData.cs

示例2: Load

	public static MapData Load(string fullPath)
	{
		Debug.Log("load  <-- " + fullPath);
		XmlDocument doc = new XmlDocument();
		doc.Load(fullPath);
		XmlNode root = doc.DocumentElement;
		Debug.Log(root.Name);
		MapData mapData = null;
		foreach (XmlNode map in root.ChildNodes)
		{
			XmlElement mapEle = map as XmlElement;
			if (mapEle == null)
				continue;
			string sceneName = mapEle.GetAttribute("sceneName");
			int xCount = System.Convert.ToInt32(mapEle.GetAttribute("xCount"));
			int zCount = System.Convert.ToInt32(mapEle.GetAttribute("zCount"));
			Debug.Log(string.Format("{0}  {1} {2}", sceneName, xCount, zCount));
			mapData = new MapData(xCount, zCount);
			foreach (XmlNode _nd in mapEle.ChildNodes)
			{
				XmlElement nodeEle = _nd as XmlElement;
				if (nodeEle == null)
					continue;
				if (nodeEle.Name == "node")
				{
					int x = System.Convert.ToInt32(nodeEle.GetAttribute("x"));
					int z = System.Convert.ToInt32(nodeEle.GetAttribute("z"));
					float height = System.Convert.ToSingle(nodeEle.GetAttribute("height"));
					bool isReachable = System.Convert.ToBoolean(nodeEle.GetAttribute("isReachable"));
					bool isWayPoint = System.Convert.ToBoolean(nodeEle.GetAttribute("isWayPoint"));
					bool isBoundary = System.Convert.ToBoolean(nodeEle.GetAttribute("isBoundary"));
					MapData.MapNode _mapNode = new MapData.MapNode(x, z, 1, height, isReachable, isWayPoint, isBoundary);
					float[] neighbourHeight  = new float[4];
					neighbourHeight[0] = System.Convert.ToSingle( nodeEle.GetAttribute("neighbour_0_0"));
					neighbourHeight[1] = System.Convert.ToSingle( nodeEle.GetAttribute("neighbour_0_1"));
					neighbourHeight[2] = System.Convert.ToSingle( nodeEle.GetAttribute("neighbour_1_1"));
					neighbourHeight[3] = System.Convert.ToSingle( nodeEle.GetAttribute("neighbour_1_0"));

					_mapNode.neighborHeights = neighbourHeight;
					mapData.SetNode(x, z, _mapNode);
				}

			}
		}
		return mapData;
	}
开发者ID:fengqk,项目名称:Art,代码行数:46,代码来源:MapData.cs

示例3: LoadBinary

	public static MapData LoadBinary( string fullPath){
		FileStream fileStream = new FileStream( fullPath, FileMode.Open, FileAccess.Read);
		BinaryReader binaryReader = new BinaryReader(fileStream);
		int xCount = binaryReader.ReadInt32();
		int zCount = binaryReader.ReadInt32();
		MapData data = new MapData(xCount, zCount);

		for ( int i = 0; i <xCount * zCount; i ++){
			int x = binaryReader.ReadInt32();
			int z = binaryReader.ReadInt32();
			float height =binaryReader.ReadSingle();
			bool isReachable = binaryReader.ReadBoolean();
			bool isWayPoint = binaryReader.ReadBoolean();
			bool isBoundary = binaryReader.ReadBoolean();
			float[] neighbourHeights = new float[4];
			neighbourHeights[0] = binaryReader.ReadSingle();
			neighbourHeights[1] = binaryReader.ReadSingle();
			neighbourHeights[2] = binaryReader.ReadSingle();
			neighbourHeights[3] = binaryReader.ReadSingle();

			MapData.MapNode _node = new MapData.MapNode(x, z, 1, height,isReachable, isWayPoint, isBoundary);
			_node.neighborHeights = neighbourHeights;
			data.SetNode(x,z,_node);
			
		}
		return data;
	}
开发者ID:fengqk,项目名称:Art,代码行数:27,代码来源:MapData.cs


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