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


C# Chunk.Generate方法代码示例

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


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

示例1: ActivateChunks

    // Accesses the chunks from allChunks and assigns them into activeChunks
    //  OR if not in allChunks already, generates them, puts them in allChunks and activeChunks
    IEnumerator ActivateChunks(List<int[]> indices)
    {
        int worldHeight = 1 * Settings.CHUNK_SIZE;
        activeChunks = new List<Chunk>();

        foreach (int[] index in indices)
        {
          string accessor = Util.CoordsToString(index);
          Chunk c;

          // Chunk is currently loaded into allChunks
          if (allChunks.TryGetValue(accessor, out c))
          {
        activeChunks.Add(c);

        if (c.myObj == null)
          InstantiateChunk(c);
        if (!c.rendering)
        {
          c.rendering = true;
          c.chunkRenderer.Render();
        }
          }
          // Chunk is not found, so we create it
          else
          {
        c = new Chunk(octaves, multiplier, amplitude, lacunarity, index);
        Vector3 location = new Vector3(index[0],index[1],index[2])*Settings.CHUNK_SIZE;
        // Note that the location parameter unit is blocks, not chunks, nor meters
        c.Generate(location, worldHeight);

        InstantiateChunk(c);
        c.rendering = true;
        c.chunkRenderer.Render();

        allChunks[accessor] = c;
        activeChunks.Add(c);
          }

          yield return null;
        }
    }
开发者ID:cjcurrie,项目名称:Pillars,代码行数:44,代码来源:ChunkController.cs

示例2: FixedUpdate

	void FixedUpdate () {


        if (!PlayerShip.instance)
        {
            
            return;
        }

		player = PlayerShip.instance.gameObject;
		
		for (int y = Mathf.FloorToInt(player.transform.position.y/chunkSize)-6;y <= Mathf.FloorToInt(player.transform.position.y/chunkSize)+6;y++) {
			for (int x = Mathf.FloorToInt(player.transform.position.x/chunkSize)-6;x <= Mathf.FloorToInt(player.transform.position.x/chunkSize)+6;x++) {
				int _x = Mathf.Clamp (x+levelSize/2,0, levelSize-1);
				int _y = Mathf.Clamp (y+levelSize/2,0, levelSize-1);

				if (!initializedChunks[_y,_x]) {
					initializedChunks[_y,_x] = Instantiate (chunk, new Vector2(x*chunkSize, y*chunkSize),chunk.transform.rotation) as Chunk;
					initializedChunks[_y,_x].transform.parent = transform;
				}
			}
		}


		foreach(Collider2D c in Physics2D.OverlapCircleAll(player.transform.position, chunkSize*4, 1<<15)) {
			chunk = c.GetComponent<Chunk>();
			if (chunk) {
				chunk.Generate();
			}
		}

		foreach(Collider2D c in Physics2D.OverlapCircleAll (player.transform.position, chunkSize*4, 1<<9)) {
			EnemyShip e = c.GetComponent <EnemyShip>();
			if(e!=null)
				e.DespawnIn(15);
		}
	}
开发者ID:LatexBotox,项目名称:SPACE,代码行数:37,代码来源:LevelGenerator.cs


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