本文整理汇总了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);
}
示例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);
}
示例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++;
}
示例4: BuildChunk
void BuildChunk(WorldPos pos)
{
if (world.GetChunk(pos.x,pos.y,pos.z) == null)
{
world.CreateChunk(pos.x,pos.y,pos.z);
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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>();
}
示例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;
}
示例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);
}
}
示例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);
//}
}
示例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;
}