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


C# Map.GetHeight方法代码示例

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


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

示例1: Forest

 public Forest(List<ITree> startTrees, List<ITree> treesSpecies,Map map )
 {
     this.treesSpecies = treesSpecies;
     this.forestMap =map;
     allTrees.Clear();
     this.allTrees = new HashSet<ITree>();
     trees = new HashSet<ITree>[forestMap.GetWidth()/boxSize+2,forestMap.GetHeight()/boxSize+2];
     for (int i = 0; i < trees.GetLength(0); i++) {
         for (int j = 0; j < trees.GetLength(1); j++) {
             trees[i,j] = new HashSet<ITree>();
         }
     }
     foreach (ITree tree in  startTrees) {
         AddTree(tree);
     }
 }
开发者ID:BarHaran,项目名称:SlenderKobi,代码行数:16,代码来源:Forest.cs

示例2: LoadMap

        public void LoadMap(string filename)
        {
            int x = 0;
            int y = 0;
            Light light;

            map = MapFile.Load(resourcePath + "/Maps/" + filename);

            mapWidth = map.GetWidth();
            mapHeight = map.GetHeight();

            activeRobot = map.GetActiveRobot();
            robotCamera.Attach(activeRobot);
            map.AddRobotToRemoteControlUnitList(activeRobot);

            light = new Light(LightName.Light7);
            activeRobot.AddLight(light);

            someRobot = activeRobot;

            LightPost lightpost = new LightPost(4);
            map.SetTile(lightpost, x, y);

            light = new Light(LightName.Light0);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                         2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                         1.0f, 1.0f, 1.0f);

            lightpost.AddLight(light);

            l = light;

            lightCamera1 = new Camera(0.0f, 6.0f, 0.0f,
                         2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                         0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(3);
            map.SetTile(lightpost, x + mapWidth - 1, y);

            light = new Light(LightName.Light1);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                -2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 0.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera2 = new Camera(mapWidth - 1, 6.0f, 0.0f,
                (mapWidth - 1) - 2.0f * (float) Math.Sqrt(2.0f), 0.0f, -2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(2);
            map.SetTile(lightpost, x + mapWidth - 1, y + mapHeight -1);

            light = new Light(LightName.Light2);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                -2.0f * (float) Math.Sqrt(2.0f), 0.0f, 2.0f * (float) Math.Sqrt(2.0f),
                1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera3 = new Camera(mapWidth, 6.0f, -(mapHeight - 1),
                (mapWidth - 1) - 2.0f * (float) Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            lightpost = new LightPost(1);
            map.SetTile(lightpost, x, y + (mapHeight - 1));

            light = new Light(LightName.Light3);
            light.setCutOff(45.0f);
            light.lookAt(0.0f, 6.0f, 0.0f,
                2.0f * (float) Math.Sqrt(2.0f), 0.0f, 2.0f * (float) Math.Sqrt(2.0f),
                1.0f, 1.0f, 1.0f);
            lightpost.AddLight(light);

            lightCamera4 = new Camera(0.0f, 6.0f, -(mapHeight - 1),
                2.0f * (float) Math.Sqrt(2.0f), 0.0f, -(mapHeight - 1) + 2.0f * (float) Math.Sqrt(2.0f),
                0.0f, 1.0f, 0.0f);

            this.Title = this.baseTitle;

            PrintHelp();

            prevMousePosition = this.WindowCenter;
            prevMouseDelta = new Point(0, 0);
            nullDelta = new Point(0, 0);

            globalCamera.SetMap(map);
            robotCamera.SetMap(map);

            camera = globalCamera;

            System.Windows.Forms.Cursor.Hide();

            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.ColorMaterial);
            GL.Enable(EnableCap.Texture2D);

            /* To Avoid Having Z-Fighting for projecting surfaces onto another surface (Shadows) */
            GL.PolygonOffset(-10.0f, -25.0f);
//.........这里部分代码省略.........
开发者ID:angjminer,项目名称:rawbots,代码行数:101,代码来源:Program.cs

示例3: LoadScmapFile


//.........这里部分代码省略.........
		float HeightResize = 512 * 40;

		WaterMaterial.SetTexture("_UtilitySamplerC", map.UncompressedWatermapTex);
		WaterMaterial.SetFloat("_WaterScale", HalfxRes);

		                     

//*****************************************
// ***** Set Terrain proportives
//*****************************************
		if(Teren) DestroyImmediate(Teren.gameObject);

		// Load Stratum Textures Paths
		for (int i = 0; i < Textures.Length; i++) {
			Textures[i].AlbedoPath = map.Layers[i].PathTexture;
			Textures[i].NormalPath = map.Layers[i].PathNormalmap;
			if(Textures[i].AlbedoPath.StartsWith("/")){
				Textures[i].AlbedoPath = Textures[i].AlbedoPath.Remove(0, 1);
			}
			if(Textures[i].NormalPath.StartsWith("/")){
				Textures[i].NormalPath = Textures[i].NormalPath.Remove(0, 1);
			}
			Textures[i].AlbedoScale = map.Layers[i].ScaleTexture;
			Textures[i].NormalScale = map.Layers[i].ScaleNormalmap;

			Gamedata.LoadTextureFromGamedata("env.scd", Textures[i].AlbedoPath, i, false);
			yield return null;
			Gamedata.LoadTextureFromGamedata("env.scd", Textures[i].NormalPath, i, true);
			yield return null;
		}

		Teren = Terrain.CreateTerrainGameObject( Data ).GetComponent<Terrain>();
		Teren.gameObject.name = "TERRAIN";
		Teren.materialType = Terrain.MaterialType.Custom;
		Teren.materialTemplate = TerrainMaterial;
		Teren.heightmapPixelError = 1;
		Teren.basemapDistance = 10000;
		Teren.castShadows = false;
		Teren.drawTreesAndFoliage = false;
		Teren.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;


		Data.heightmapResolution = (int)(xRes + 1);
		Data.size = new Vector3(
			HalfxRes,
			yRes * MapHeightScale,
			HalfzRes
			);
		Data.SetDetailResolution((int)(xRes / 2), 8);
		Data.baseMapResolution = (int)(xRes / 2);
		Data.alphamapResolution = (int)(xRes / 2);

		Teren.transform.localPosition = new Vector3(0, 0, -HalfzRes);


		WaterLevel.transform.localScale = new Vector3(HalfxRes, 1, HalfzRes);
		WaterLevel.transform.position = Vector3.up * (map.Water.Elevation / 10.0f);
		TerrainMaterial.SetFloat("_WaterLevel", map.Water.Elevation / 10.0f);
		TerrainMaterial.SetFloat("_AbyssLevel", map.Water.ElevationAbyss / 10.0f);
		TerrainMaterial.SetInt("_Water", MapLuaParser.Water?1:0);
		TerrainMaterial.SetTexture("_UtilitySamplerC", map.UncompressedWatermapTex);
		TerrainMaterial.SetFloat("_GridScale", HalfxRes);


		heights = new float[map.Width + 1, map.Height + 1];
		// Modify heights array data
		for (int y = 0; y < map.Width + 1; y++) {
			for (int x = 0; x < map.Height + 1; x++) {
				heights[x,y] = map.GetHeight(y, map.Height - x) / HeightResize ;
			}
		}

		// Set terrain heights from heights array
		Data.SetHeights(0, 0, heights);

		//TerrainM.Heights = heights;
		//TerrainM.GenerateMesh ();

		// Save stratum mask to files
		if(SaveStratumToPng){
			byte[] bytes;
			string filename = "temfiles/tex1";
			bytes =  map.TexturemapTex.EncodeToPNG();
			filename += ".png";
			System.IO.File.WriteAllBytes(filename, bytes);

			bytes = null;
			filename = "temfiles/tex2";
			bytes =  map.TexturemapTex2.EncodeToPNG();
			filename += ".png";
			System.IO.File.WriteAllBytes(filename, bytes);
		}


		Teren.gameObject.layer = 8;
		Teren.heightmapPixelError = 0; // Force terrain pixel error to 0, to get more sharp terrain

		SetTextures ();
		yield return null;
	}
开发者ID:ozonexo3,项目名称:FAForeverMapEditor,代码行数:101,代码来源:ScmapEditor.cs

示例4: Generate

    public void Generate(Map map)
    {
        int w = map.Width;
        int h = map.Height;
        int faces = 0;          // face count needed
        int vCount = 0;         // total vertices
        int index = 0;
        int[, ,] indexMap = new int[w + 1, h + 1, 2];

        for (int x = 0; x < w + 1; ++x)
        {
            for (int y = 0; y < h + 1; ++y)
            {
                if (map.IsSquareOnLevel(x, y, 1))
                {
                    ++vCount;

                    if (map.IsSquareOnLevel(x, y, 0))
                    {
                        ++vCount;
                    }
                }
            }
        }
        vertices = new Vector3[vCount];

        index = 0;
        for (int x = 0; x < w + 1; ++x)
        {
            for (int y = 0; y < h + 1; ++y)
            {
                if (map.IsSquareOnLevel(x, y, 1))
                {
                    vertices[index] = new Vector3(x, 1, y);
                    indexMap[x, y, 1] = index;
                    ++index;

                    if (map.IsSquareOnLevel(x, y, 0))
                    {
                        vertices[index] = new Vector3(x, 0, y);
                        indexMap[x, y, 0] = index;
                        ++index;
                    }
                }
            }
        }

        for (int x = 0; x < w; ++x)
        {
            for (int y = 0; y < h; ++y)
            {
                int t = map.GetHeight(x, y);
                if (t > 0)
                {
                    if (map.GetHeight(x + 1, y) < 1)
                    {
                        ++faces;
                    }

                    if (map.GetHeight(x - 1, y) < 1)
                    {
                        ++faces;
                    }

                    if (map.GetHeight(x, y + 1) < 1)
                    {
                        ++faces;
                    }

                    if (map.GetHeight(x, y - 1) < 1)
                    {
                        ++faces;
                    }

                    ++faces;
                }
            }
        }
        triangles = new int[faces * 3 * 2];

        index = 0;
        for (int x = 0; x < w; ++x)
        {
            for (int y = 0; y < h; ++y)
            {
                if (map.IsLevel(x, y, 1))
                {
                    // top
                    triangles[index++] = indexMap[x, y, 1];
                    triangles[index++] = indexMap[x, y + 1, 1];
                    triangles[index++] = indexMap[x + 1, y + 1, 1];

                    triangles[index++] = indexMap[x, y, 1];
                    triangles[index++] = indexMap[x + 1, y + 1, 1];
                    triangles[index++] = indexMap[x + 1, y, 1];

                    if (map.GetHeight(x + 1, y) < 1)
                    {
                        // East
                        triangles[index++] = indexMap[x + 1, y + 1, 1];
//.........这里部分代码省略.........
开发者ID:snarf95,项目名称:DungeonRun,代码行数:101,代码来源:ProceduralMesh.cs

示例5: LoadScmapFile


//.........这里部分代码省略.........
			tex[i].smoothness = 0.5f;
		}

		Data.splatPrototypes = tex;

		Teren = Terrain.CreateTerrainGameObject( Data ).GetComponent<Terrain>();
		Teren.gameObject.name = "TERRAIN";
		Teren.materialType = Terrain.MaterialType.Custom;
		Teren.materialTemplate = TerrainMaterial;
		Teren.heightmapPixelError = 1;
		Teren.basemapDistance = 10000;
		Teren.castShadows = false;
		Teren.drawTreesAndFoliage = false;
		Teren.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;

		Data.heightmapResolution = (int)(xRes + 1);
		Data.size = new Vector3(
			xRes / 10.0f,
			yRes * MapHeightScale,
			zRes / 10.0f
			);
		Data.SetDetailResolution((int)(xRes / 2), 8);
		Data.baseMapResolution = (int)(xRes / 2);
		Data.alphamapResolution = (int)(xRes / 2);

		Teren.transform.localPosition = new Vector3(0, 0, -zRes / 10.0f);


		WaterLevel.transform.localScale = new Vector3(xRes / 10, 1, zRes / 10);
		WaterLevel.transform.position = Vector3.up * (map.Water.Elevation / 10.0f);
		TerrainMaterial.SetFloat("_WaterLevel", map.Water.Elevation / 10.0f);
		TerrainMaterial.SetFloat("_AbyssLevel", map.Water.ElevationAbyss / 10.0f);


		TerrainMaterial.SetInt("_Water", MapLuaParser.Water?1:0);
		TerrainMaterial.SetFloat("_LowerScale", Textures[0].AlbedoScale / Textures[1].AlbedoScale);
		TerrainMaterial.SetTexture("_SplatLower", Textures[0].Albedo);
		TerrainMaterial.SetTexture("_NormalLower", Textures[0].Normal);
		TerrainMaterial.SetTexture("_UtilitySamplerC", map.WatermapTex);
		TerrainMaterial.SetFloat("_GridScale", xRes / 10f);


		heights = new float[map.Width + 1, map.Height + 1];
		// Modify heights array data
		for (int y = 0; y < map.Width + 1; y++) {
			for (int x = 0; x < map.Height + 1; x++) {
				heights[x,y] = map.GetHeight(y, map.Height - x) / HeightResize ;
			}
		}

		// Set terrain heights from heights array
		Data.SetHeights(0, 0, heights);


		// Mask textures
		float[,,] maps = new float[Data.alphamapWidth, Data.alphamapHeight, 4];
		Debug.Log("Load maps: " + Data.alphamapWidth);

		for(int i = 0; i < Data.alphamapWidth; i++){
			for(int e = 0; e < Data.alphamapHeight; e++){

				float stratum1 = map.TexturemapTex.GetPixel(e, Data.alphamapWidth - i - 1).b;
				float stratum2 = map.TexturemapTex.GetPixel(e, Data.alphamapWidth - i - 1).g;
				float stratum3 = map.TexturemapTex.GetPixel(e, Data.alphamapWidth - i - 1).r;
				float stratum4 = map.TexturemapTex.GetPixel(e, Data.alphamapWidth - i - 1).a;

				maps[i, e, 0] = stratum1; // stratum 1
				maps[i, e, 1] = stratum2; // stratum 2
				maps[i, e, 2] = stratum3; // stratum 3
				maps[i, e, 3] = stratum4; // stratum 4

			}
		}
		yield return null;
		byte[] bytes;
		string filename = "temfiles/tex1";
		bytes =  map.TexturemapTex.EncodeToPNG();
		filename += ".png";
		System.IO.File.WriteAllBytes(filename, bytes);


		bytes = null;
		filename = "temfiles/tex2";
		bytes =  map.TexturemapTex2.EncodeToPNG();
		filename += ".png";
		System.IO.File.WriteAllBytes(filename, bytes);

		Data.SetAlphamaps(0, 0, maps);
		Teren.gameObject.layer = 8;

		string AllProps = "";

		for(int i = 0; i < map.Props.Count; i++){
			if( !map.Props[i].BlueprintPath.Contains("pine")){
				AllProps += map.Props[i].BlueprintPath + "\n";
			}
		}
		Debug.Log("All Props\n" + AllProps);
		yield return null;
	}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:101,代码来源:ScmapEditor.cs


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