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


C# Region.ToTerrainRegion方法代码示例

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


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

示例1: OnSelectionChanged

	public void OnSelectionChanged(ResourceTileSelection selection)
	{
		List<int> ids = new List<int>(selection.resource_tile_ids);
		if (tileIds.Count == ids.Count) {
			return;
		}
		if (ids.Count <= 0) {
			FloodFill();
		} else {
			if (tileIds.Count < ids.Count) {
				tileIds = ids;
			}
			TerrainManager.Status status;
			ResourceTileLite[] tiles = TerrainManager.GetResourceTileCacheGroup(out status,tileIds.ToArray());
			if (status == TerrainManager.Status.Succeeded) {
				Region region = new Region(tiles);
				region.ToTerrainRegion(out region);
				PaintRegion(region);
			}
		}
		tileIds = ids;
	}
开发者ID:wids-eria,项目名称:tf_client,代码行数:22,代码来源:DataMaps.cs

示例2: SetTerrainFromResourceTiles

	/// <summary>
	/// Sets the terrain from resourceTiles.
	/// </summary>
	/// <param name='resourceTiles'>
	/// Microtiles.
	/// </param>
	/// <param name='mode'>
	/// Mode.
	/// </param>
	public void SetTerrainFromResourceTiles(ResourceTile[] resourceTiles, SetTerrainMode mode)
	{
		if (resourceTiles.Length <= 0) {
//			return;
			// if this case actually gets hit I want to know what is causing it.
			throw new System.ArgumentException("Please find out why the resourceTile array was empty and tell Adam.");
		}
		
		// if the view is not entirely terrain, clear it and move it to the center of the view
		if (!m_isTerrainFixedInPlace &&
			!CameraRig.use.isViewFrustumEntirelyTerrain
		) {
			ClearTerrain(SetTerrainMode.NoFlush);
			MoveTerrainToCenterOfView();
		}
		// determine region of update to minimize calls to Terrain APIs
		Region region = new Region(resourceTiles);
		// clear structures in the region
		ClearBuildingsInRegion(region);
		// convert to terrain-space region
		region.ToTerrainRegion( out region );
		// get current properties for the region
		float[,] heights = terrainData.GetHeights(region.left, region.bottom, region.width, region.height);
		float[,,] splats = terrainData.GetAlphamaps(region.left, region.bottom, region.width, region.height);
		int[][,] details = new int[terrainData.detailPrototypes.Length][,];
		for (int i=0; i<details.Length; i++) {
			details[i] = terrainData.GetDetailLayer(region.left, region.bottom, region.width, region.height, i);
		}
		// update values as needed
		int xOffset = (int)terrain.transform.position.x + region.left;
		int zOffset = (int)terrain.transform.position.z + region.bottom;
		Building b = null;
		foreach (ResourceTile tile in resourceTiles) {
			// get coordinates in the space of the chunk
			int x = tile.x - xOffset;
			int z = tile.z - zOffset;
			// skip any resourceTiles that are out of bounds, as when e.g., server returns a bigger cached chunk than we need
			if (x<0 || x>heights.GetUpperBound(1) ||
			    z<0 || z>heights.GetUpperBound(0)
			) {
				continue;
			}
//			// cache stuff that is not collapsed into other representations
//			resourceTileCache[region.bottom+z,region.left+x] = new ResourceTileLite(tile);
			// set heights
			GroundTextureType ground = tile.groundTextureType;
			heights[z,x] = (ground==GroundTextureType.Water)?0f:terrainData.size.y;
			// set ground texture
			for (int i=0; i<=splats.GetUpperBound(2); ++i) {
				splats[z,x,i] = 0f;
			}
			splats[z,x,(int)ground] = 1f;
			// get the raw number of trees of each type
			int[] treeCounts = tile.GetTreeCountsByGraphicType();
			// remap tree counts to the range for detail values
			for (int i=0; i<treeCounts.Length; ++i) {
				treeCounts[i] = (int)(detailResolutionPerPatch*Mathf.Min(treeCounts[i]*ResourceTile.oneOverMaxNumberOfTreesPerAcre, 1f));
			}
			// set details
			for (int i=0; i<treeCounts.Length; ++i) {
				details[i][z,x] = treeCounts[i];
			}
			// add structures
			if (tile.hasOutpost && !m_outpostInstances.ContainsKey(tile.id)) {
				m_outpostInstances.Add(
					tile.id,
					Instantiate(m_outpostPrefab, tile.GetCenterPoint(), Quaternion.identity) as ResearchOutpost
				);
			}
			else if (!tile.hasOutpost && m_outpostInstances.ContainsKey(tile.id)) {
				Destroy(m_outpostInstances[tile.id].gameObject);
				m_outpostInstances.Remove(tile.id);
			}
			b = buildHousingAction.GetBuildingWithCapacity(tile.housingCapacity);
			if (b==null) {
				continue;
			}
			Building building = Instantiate(b, tile.GetCenterPoint(), Quaternion.identity) as Building;
			building.gameObject.transform.parent = m_objectGrouper.transform;
			m_buildingInstances.Add(building.gameObject);
		}
		
		// cache stuff that is not collapsed into other representations
		// NOTE: must do afterward for now, since it relies on e.g. research outpost locations; can go back once server sets permissions
		foreach (ResourceTile tile in resourceTiles) {
			// get coordinates in the space of the chunk
			int x = tile.x - xOffset;
			int z = tile.z - zOffset;
			// skip any resourceTiles that are out of bounds, as when e.g., server returns a bigger cached chunk than we need
			if (x<0 || x>heights.GetUpperBound(1) ||
			    z<0 || z>heights.GetUpperBound(0)
//.........这里部分代码省略.........
开发者ID:wids-eria,项目名称:tf_client,代码行数:101,代码来源:TerrainManager.cs

示例3: ClearTreesInRegion

	/// <summary>
	/// Clears the trees in region.
	/// </summary>
	/// <param name='region'>
	/// Region in world space specifying resource tiles to clear.
	/// </param>
	/// <param name='mode'>
	/// Mode.
	/// </param>
	private void ClearTreesInRegion(Region region, SetTerrainMode mode)
	{
		// set all details to 0 in the region
		region.ToTerrainRegion( out region );
		int[,] details = new int[region.right-region.left+1,
		                         region.top-region.bottom+1];
		for (int i=0; i<terrainData.detailPrototypes.Length; i++)
			terrainData.SetDetailLayer(region.left, region.bottom, i, details);
		
		// flush if requested
		if (mode == SetTerrainMode.Flush) {
			terrain.Flush();
		}
	}
开发者ID:wids-eria,项目名称:tf_client,代码行数:23,代码来源:TerrainManager.cs


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