• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WorldPos类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WorldPos的典型用法代码示例。如果您正苦于以下问题:C# WorldPos类的具体用法?C# WorldPos怎么用?C# WorldPos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WorldPos类属于命名空间,在下文中一共展示了WorldPos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        WorldPos worldPos = new WorldPos(x, y, z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(
                        chunkPrefab, new Vector3(x, y, z),
                        Quaternion.Euler(Vector3.zero)
                    ) as GameObject;

        Chunk newChunk = newChunkObject.GetComponent<Chunk>(); //gets the script component

        newChunk.pos = worldPos; //rounds position to an int
        newChunk.world = this; //tells the chunk how to get back to mommy
        newChunk.tag = "breakable";

        //Add it to the chunks dictionary with the position as the key
        chunks.Add(worldPos, newChunk);

        TerrainGen terrainGen = new TerrainGen(); //this has some preset values for generating
        newChunk = terrainGen.ChunkGen(newChunk); //this runs the generation code

        newChunk.SetBlocksUnmodified(); //this tells Serialization not to save as there was no changes

        Serialization.Load(newChunk);
    }
开发者ID:TwoClunkers,项目名称:Clunk-Genesis,代码行数:26,代码来源:World.cs


示例2: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        WorldPos worldPos = new WorldPos(x, y, z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(
                        chunkPrefab, new Vector3(x, y, z),
                        Quaternion.Euler(Vector3.zero)
                    ) as GameObject;

        Chunk newChunk = newChunkObject.GetComponent<Chunk>();

        newChunk.pos = worldPos;
        newChunk.world = this;

        //Add it to the chunks dictionary with the position as the key
        chunks.Add(worldPos, newChunk);

        var terrainGen = new TerrainGen();
        newChunk = terrainGen.ChunkGen(newChunk);

        newChunk.SetBlocksUnmodified();

        Serialization.Load(newChunk);
    }
开发者ID:DWethmar,项目名称:rogue,代码行数:25,代码来源:World.cs


示例3: CreateChunk

    public void CreateChunk(int x, int y, int z) {
        WorldPos worldPos = new WorldPos(x, y, z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(
                        chunkPrefab, new Vector3(x, y, z),
                        Quaternion.Euler(Vector3.zero)
                    ) as GameObject;
        Chunk newChunk = newChunkObject.GetComponent<Chunk>();
		newChunkObject.name = "Chunk: " + x/16f + ":" + y/16f + ":" + z/16f;
        newChunk.pos = worldPos;
        newChunk.world = this;

        //Add it to the chunks dictionary with the position as the key
        chunks.Add(worldPos, newChunk);

		bool HasLoadedChunk = false;


		if ((Network.isServer || (!Network.isServer && !Network.isClient)) && IsLoadChunks) 
			HasLoadedChunk = Serialization.Load(newChunk);
		if (!HasLoadedChunk) {
			newChunk = MyTerrainGen.ChunkGen(newChunk);
		}
		newChunk.transform.parent = gameObject.transform;
		newChunk.SetBlocksUnmodified();
		GetManager.GetZoneManager ().LoadZones (new Vector3 (x, y, z));
		DebugChunksLoadedCount++;
    }
开发者ID:Deus0,项目名称:Zeltex,代码行数:29,代码来源:World.cs


示例4: BuildChunk

 void BuildChunk(WorldPos pos)
 {
     if (world.GetChunk(pos.x,pos.y,pos.z) == null)
     {
     world.CreateChunk(pos.x,pos.y,pos.z);
     }
 }
开发者ID:Rimevel,项目名称:VoxelWorld,代码行数:7,代码来源:ChunkManager.cs


示例5: GetChunk

    public Chunk GetChunk(int x, int y, int z)
    {
        WorldPos pos = new WorldPos();
        float multiple = Chunk.chunkSize;
        pos.x = Mathf.FloorToInt(x / multiple ) * Chunk.chunkSize;
        pos.y = Mathf.FloorToInt(y / multiple ) * Chunk.chunkSize;
        pos.z = Mathf.FloorToInt(z / multiple ) * Chunk.chunkSize;

        Chunk containerChunk = null;

        chunks.TryGetValue(pos, out containerChunk);
        for (int xi = 0; xi < 16; xi++)
        {
            for (int yi = 0; yi < 16; yi++)
            {
                for (int zi = 0; zi < 16; zi++)
                {
                    if (yi <= 7)
                    {
                        SetBlock(x+xi, y+yi, z+zi, new BlockGrass());
                    }
                    else
                    {
                        SetBlock(x + xi, y + yi, z + zi, new BlockAir());
                    }
                }
            }
        }
        return containerChunk;
    }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:30,代码来源:World.cs


示例6: Update

	// Update is called once per frame
	void Update() {	
		if (world != null) {
			world.ChunkLoader = this;
			TimeExisted += Time.deltaTime;
			if (TimeExisted - LastDeletedChunks > TimeCoolDown) {
				LastDeletedChunks = TimeExisted;
				// removes all excess chunks outside render range
				playerPos = new WorldPos(
					Mathf.FloorToInt(transform.position.x / Chunk.chunkSize) * Chunk.chunkSize,
					Mathf.FloorToInt(transform.position.y / Chunk.chunkSize) * Chunk.chunkSize,
					Mathf.FloorToInt(transform.position.z / Chunk.chunkSize) * Chunk.chunkSize
					);
				if (IsLoadOnce) {
					playerPos = new WorldPos(0,0,0);
				}
				//if (!IsLoadOnce)
				DeleteChunks ();
				// finds new chunks to load within the list
				//if (!IsLoadOnce)
				FindChunksToLoad ();
				// Loads new chunks and renders them
				LoadAndRenderChunks ();
			}
		
			DebugUpdateListSize = updateList.Count;
			DebugBuildListSize = buildList.Count;
		}
	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:29,代码来源:LoadChunks.cs


示例7: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        WorldPos worldPos = new WorldPos(x, y, z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(
                        chunkPrefab, new Vector3(x, y, z),
                        Quaternion.Euler(Vector3.zero)
                    ) as GameObject;

        Chunk newChunk = newChunkObject.GetComponent<Chunk>();

        newChunk.pos = worldPos;
        newChunk.world = this;

        //Add it to the chunks dictionary with the position as the key
        chunks.Add(worldPos, newChunk);

        // Initializes Chunk with top block layer only - creates ground

        for (int xi = 0; xi < 16; xi++)
        {
            for (int yi = 0; yi < 16; yi++)
            {
                for (int zi = 0; zi < 16; zi++)
                {
                    SetBlock(x + xi, y + yi, z + zi, new BlockAir());
                }
            }
        }

        newChunk.SetBlocksUnmodified();

        Serialization.Load(newChunk);
    }
开发者ID:nathanchau,项目名称:make,代码行数:35,代码来源:World.cs


示例8: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        WorldPos worldPos = new WorldPos(x,y,z);

        GameObject newChunkObject = Instantiate(
            chunkPrefab, new Vector3(worldPos.x,worldPos.y,worldPos.z),
            Quaternion.Euler(Vector3.zero)
            ) as GameObject;

        Chunk newChunk = newChunkObject.GetComponent<Chunk>();

        newChunk.pos = worldPos;
        newChunk.world = this;

        chunks.Add(worldPos, newChunk);

        //bool loaded = Serialization.Load(newChunk);
        //if(loaded)
            //return;
        var terrainGen = new TerrainGen();
        newChunk = terrainGen.ChunkGen(newChunk);

        newChunk.SetBlocksUnmodified();
        bool loaded = Serialization.Load(newChunk);
    }
开发者ID:Purplehain,项目名称:PHGMS01,代码行数:25,代码来源:World.cs


示例9: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        //the coordinates of this chunk in the world
        WorldPos worldPos = new WorldPos(x, y, z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(
                        chunkPrefab, new Vector3(worldPos.x, worldPos.y, worldPos.z),
                        Quaternion.Euler(Vector3.zero)
                    ) as GameObject;

        //Get the object's chunk component
        Chunk newChunk = newChunkObject.GetComponent<Chunk>();

        //Assign its values
        newChunk.pos = worldPos;
        newChunk.world = this;

        //Add it to the chunks dictionary with the position as the key
        chunks.Add(worldPos, newChunk);

        //now spawn me some test chunks!
        var terrainGen = new TerrainGen();
        newChunk = terrainGen.ChunkGen(newChunk);

           // newChunk.SetBlocksUnmodified();

        //bool loaded = Serialization.Load(newChunk);
    }
开发者ID:JuliusGJimenez0522,项目名称:MinecraftGame24Team3,代码行数:29,代码来源:World.cs


示例10: GetBlockPos

    public static WorldPos GetBlockPos(Vector3 pos)
    {
        WorldPos blockPos = new WorldPos(Mathf.RoundToInt(pos.x),
                                         Mathf.RoundToInt(pos.y),
                                         Mathf.RoundToInt(pos.z));

        return blockPos;
    }
开发者ID:dkim616,项目名称:VoxelEngine,代码行数:8,代码来源:EditTerrain.cs


示例11: shapesAtPos

 // Takes a WorldPos and answers with list of shapes at that position
 public List<Shape> shapesAtPos(WorldPos pos)
 {
     if (posDictionary.ContainsKey(pos))
     {
         return posDictionary[pos];
     }
     return new List<Shape>();
 }
开发者ID:nathanchau,项目名称:make,代码行数:9,代码来源:WorldState.cs


示例12: IsInChunkList

	public bool IsInChunkList(WorldPos NewChunkPos) {
		for (int i = 0; i < ChunkPositions.Count; i++) {
			if (NewChunkPos.x == ChunkPositions[i].x && 
			    NewChunkPos.y == ChunkPositions[i].y && 
			    NewChunkPos.z == ChunkPositions[i].z)
				return true;
		}
		return false;
	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:9,代码来源:LoadChunks.cs


示例13: AddChunkPositions

	public void AddChunkPositions(int Max) {
		for (int i = -Max; i <= Max; i++)
			for (int k = -Max; k <= Max; k++)
		{
			WorldPos NewPos = new WorldPos(i,0,k);
			if (!IsInChunkList(NewPos))
				ChunkPositions.Add (NewPos);
		}
	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:9,代码来源:LoadChunks.cs


示例14: CreateChunk

 public void CreateChunk(int x, int y, int z)
 {
     WorldPos worldPos = new WorldPos(x, y, z);
     //if(pending.Count > 0)
     //{
         Chunk c = Instantiate(chunk, worldPos.ToVector() - new Vector3(chunkSize / 2f, chunkSize / 2f, chunkSize / 2f), new Quaternion()) as Chunk;
         c.transform.parent = transform;
         chunks.Add(worldPos, c);
     //}
 }
开发者ID:Elwann,项目名称:VoxelTerrain,代码行数:10,代码来源:World.cs


示例15: ChunkColumnGen

    public Chunk ChunkColumnGen(Chunk chunk, int x, int z)
    {
        /*int stoneHeight = Mathf.FloorToInt (stoneBaseHeight);
        stoneHeight += GetNoise (x, 0, z, stoneMountainFrequency, Mathf.FloorToInt (stoneMountainHeight));

        if (stoneHeight < stoneMinHeight)
            stoneHeight = Mathf.FloorToInt (stoneMinHeight);

        stoneHeight += GetNoise (x, 0, z, stoneBaseNoise, Mathf.FloorToInt (stoneBaseNoiseHeight));

        int dirtHeight = stoneHeight + Mathf.FloorToInt (dirtBaseHeight);
        dirtHeight += GetNoise (x, 100, z, dirtNoise, Mathf.FloorToInt (dirtNoiseHeight));

        for (int y = 0; y < Chunk.chunkHeight; y++)
        {
            if (y <= stoneHeight)
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new Block ());
            } else if (y <= dirtHeight)
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new BlockGrass ());
            } else
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new BlockAir ());
            }
        }*/

        //*********************
        Random.seed = chunk.world.seed;
        Vector3 offSet0 = new Vector3 (Random.value * 10000, Random.value * 10000, Random.value * 10000);
        Vector3 offSet1 = new Vector3 (Random.value * 10000, Random.value * 10000, Random.value * 10000);
        Vector3 offSet2 = new Vector3 (Random.value * 10000, Random.value * 10000, Random.value * 10000);

        for (int y = 0; y < Chunk.chunkHeight; y++)
        {
            WorldPos pos = new WorldPos (x, y, z);

            float noiseValue = CalculateNoiseValue (pos, offSet0, 0.03f);
            noiseValue += CalculateNoiseValue (pos, offSet1, 0.02f);
            noiseValue += CalculateNoiseValue (pos, offSet2, 0.005f);
            noiseValue += (20 - y) / 10f;
            if (noiseValue < 0.08f)
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new BlockAir ());
            } else if (noiseValue < 0.3f)
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new BlockGrass ());
            } else
            {
                chunk.SetBlock (x - chunk.pos.x, y, z - chunk.pos.z, new BlockStone ());
            }
        }

        return chunk;
    }
开发者ID:neilsustc,项目名称:myMinecraft-unity3d,代码行数:55,代码来源:TerrainGen.cs


示例16: GetChunk

    public Chunk GetChunk(int x, int y, int z)
    {
        WorldPos pos = new WorldPos();
        float multiple = Chunk.chunkSize;
        pos.x = Mathf.FloorToInt(x / multiple) * Chunk.chunkSize;
        pos.y = Mathf.FloorToInt(y / multiple) * Chunk.chunkSize;
        pos.z = Mathf.FloorToInt(z / multiple) * Chunk.chunkSize;

        Chunk containerChunk = null;
        chunks.TryGetValue(pos, out containerChunk);

        return containerChunk;
    }
开发者ID:Purplehain,项目名称:PHGMS01,代码行数:13,代码来源:World.cs


示例17: FindChunksToLoad

	void FindChunksToLoad()
	{
		//Get the position of this gameobject to generate around
		WorldPos playerPos = new WorldPos(
			Mathf.FloorToInt(transform.position.x / Chunk.chunkSize) * Chunk.chunkSize,
			Mathf.FloorToInt(transform.position.y / Chunk.chunkSize) * Chunk.chunkSize,
			Mathf.FloorToInt(transform.position.z / Chunk.chunkSize) * Chunk.chunkSize
			);
		
		//If there aren't already chunks to generate
		if (updateList.Count == 0)
		{
			//Cycle through the array of positions
			for (int i = 0; i < chunkPositions.Length; i++)
			{
				//translate the player position and array position into chunk position
				WorldPos newChunkPos = new WorldPos(
					chunkPositions[i].x * Chunk.chunkSize + playerPos.x,
					0, 
					chunkPositions[i].z * Chunk.chunkSize + playerPos.z
					);
				
				//Get the chunk in the defined position
				Chunk newChunk = world.GetChunk(newChunkPos.x, newChunkPos.y, newChunkPos.z);
				
				//If the chunk already exists and it's already
				//rendered or in queue to be rendered continue
				if (newChunk != null
				    && (newChunk.rendered || updateList.Contains(newChunkPos)))
					continue;
				
				//load a column of chunks in this position
				//load a column of chunks in this position
				for (int y = -4; y < 4; y++)
				{
					
					for (int x = newChunkPos.x - Chunk.chunkSize; x <= newChunkPos.x + Chunk.chunkSize; x += Chunk.chunkSize)
					{
						for (int z = newChunkPos.z - Chunk.chunkSize; z <= newChunkPos.z + Chunk.chunkSize; z += Chunk.chunkSize)
						{
							buildList.Add(new WorldPos(x, y * Chunk.chunkSize, z));
						}
					}
					updateList.Add(new WorldPos(newChunkPos.x, y * Chunk.chunkSize, newChunkPos.z));
				}

				return;
			}
		}
	}
开发者ID:brandenTenbrink,项目名称:VoxelExperiment,代码行数:50,代码来源:LoadChunks.cs


示例18: CreateChunk

    public void CreateChunk(int x, int y, int z)
    {
        WorldPos worldPos = new WorldPos(x, y , z);

        //Instantiate the chunk at the coordinates using the chunk prefab
        GameObject newChunkObject = Instantiate(chunkPrefab, new Vector3(x, y, z),Quaternion.Euler(Vector3.zero)) as GameObject;

        Chunk newChunk = newChunkObject.GetComponent<Chunk>();

        newChunk.pos = worldPos;
        newChunk.world = this;

        //Adds to dictionary
        chunks.Add(worldPos, newChunk);
    }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:15,代码来源:World.cs


示例19: SetBlock

    public static void SetBlock(int x, int y, int z, Block block, Chunk chunk, bool replaceBlocks = false)
    {
        x -= chunk.pos.x;
        y -= chunk.pos.y;
        z -= chunk.pos.z;

        if (Chunk.InRange(x) && Chunk.InRange(y) && Chunk.InRange(z))
        {
            if (replaceBlocks || chunk.blocks[x, y, z] == null)
            {
                WorldPos pos = new WorldPos();
                pos.x = x; pos.y = y; pos.z =z;
                chunk.SetBlock(x, y, z, block);
            }
        }
    }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:16,代码来源:TerrainGen.cs


示例20: assignVoxel

        public void assignVoxel(World thisworld, WorldPos position, int number)
        {
            prime = thisworld.GetBlock(position.x,position.y,position.z);

            corner = (handledirection) number;

            pos.x = position.x;
            pos.y = position.y;
            pos.z = position.z;
            offx = prime.offx;
            offy = prime.offy;
            offz = prime.offz;
            transform.position = Camera.main.WorldToScreenPoint(new Vector3 (pos.x+offx, pos.y+offy, pos.z+offz));

            setupHandle (number);
        }
开发者ID:TwoClunkers,项目名称:Clunk-Genesis,代码行数:16,代码来源:CornerHandle.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WorldState类代码示例发布时间:2022-05-24
下一篇:
C# WorldObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap