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


C# WorldPos类代码示例

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


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


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