Advertisement
Guest User

Untitled

a guest
Oct 18th, 2011
1,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System.Collections;
  2.  
  3. public class WorldData  {
  4.    
  5.     private int chunkWidth = 32, chunkHeight = 128, chunkDepth = 32;        // The dimensions of each chunk in blocks, so each chunk is 32 blocks in width and depth but 128 blocks in height
  6.     private int chunksX = 8, chunksY = 1, chunksZ = 8;                      // How many chunks we want to generate in the world along each axis
  7.    
  8.     public ChunkData[,,] chunks;                                            // And array of our chunks so we can keep track of them
  9.    
  10.     public const int BottomChunkBorderRow = 0, LeftChunkBorderColumn = 0;
  11.    
  12.     public void InitChunkGrid()
  13.     {
  14.         // Lets initialize our array where our chunk data will be stored
  15.         chunks = new ChunkData[chunksX,chunksY,chunksZ];
  16.        
  17.         // Our for loops so we can iterate through and set our chunk
  18.         // Position in the array
  19.         for (int x = LeftChunkBorderColumn; x <= RightChunkBorderColumn; x++)
  20.         {
  21.             for (int y = BottomChunkBorderRow; y <= TopChunkBorderRow; y++)
  22.             {
  23.                 for (int z = 0; z < chunksZ; z++)
  24.                 {
  25.                     // Create a new set of ChunkData at x,y,z
  26.                     chunks[x, y, z] = new ChunkData(x, y, z);
  27.                 }
  28.             }
  29.         }
  30.     }
  31.    
  32.     // Chunk width,height,depth Functions just allow us
  33.     // To get and set the value of our vars because they're private
  34.     public int ChunkWidth
  35.     {
  36.         get { return chunkWidth; }
  37.         set { chunkWidth = value; }
  38.     }
  39.    
  40.     public int ChunkHeight
  41.     {
  42.         get { return chunkHeight; }
  43.         set { chunkHeight = value; }
  44.     }
  45.    
  46.     public int ChunkDepth
  47.     {
  48.         get { return chunkDepth; }
  49.         set { chunkDepth = value; }
  50.     }
  51.    
  52.     // Chunks X,Y,Z Functions just allow us
  53.     // To get and set the value of our vars because they're private
  54.     public int ChunksX
  55.     {
  56.         get { return chunksX; }
  57.         set { chunksX = value; }
  58.     }
  59.    
  60.     public int ChunksY
  61.     {
  62.         get { return chunksY; }
  63.         set { chunksY = value; }
  64.     }
  65.    
  66.     public int ChunksZ
  67.     {
  68.         get { return chunksZ; }
  69.         set { chunksZ = value; }
  70.     }
  71.    
  72.     public int TopChunkBorderRow
  73.     {
  74.         get { return chunksY - 1; }
  75.     }
  76.  
  77.     public int RightChunkBorderColumn
  78.     {
  79.         get { return chunksX - 1; }
  80.     }
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement