public IList <Item> GetItems(Field field) { IList <Item> list = new List <Item>(); new DatFileReader(this.GetType().Assembly.GetManifestResourceStream(path)) .ReadStream_ByHexa(DatFileReader.ByPosition(Field.WIDTH, (x, y, dat) => { Item item = null; switch (dat) { case 0: break; case 1: item = new Me(field); break; case 2: item = new Snake(field); break; case 3: item = new Rmb(field); break; case 4: item = new Mush(field); break; case 5: item = new NormalStone(field); break; case 6: item = new Block(field); break; case 7: item = new BlueStone(field); break; case 8: item = new BlueBlock(field); break; case 9: item = new RedStone(field); break; case 10: item = new RedBlock(field); break; case 11: item = new GreenStone(field); break; case 12: item = new GreenBlock(field); break; case 13: item = new YellowStone(field); break; case 14: item = new YellowBlock(field); break; default: throw new Exception("データファイルが!!"); } if (item != null) { item.X = x; item.Y = y; list.Add(item); } })); return(list); }
void BuildChunk() { bool dataFromFile = false; dataFromFile = Load(); chunkData = new Block[World.chunkSize,World.chunkSize,World.chunkSize]; for(int z = 0; z < World.chunkSize; z++) for(int y = 0; y < World.chunkSize; y++) for(int x = 0; x < World.chunkSize; x++) { Vector3 pos = new Vector3(x,y,z); int worldX = (int)(x + chunk.transform.position.x); int worldY = (int)(y + chunk.transform.position.y); int worldZ = (int)(z + chunk.transform.position.z); if(dataFromFile) { chunkData[x,y,z] = new Block(bd.matrix[x, y, z], pos, chunk.gameObject, this); continue; } int surfaceHeight = Utils.GenerateHeight(worldX,worldZ); if (worldY == 0) chunkData [x, y, z] = new Bedrock (pos, this); //new Block(Block.BlockType.BEDROCK, pos, //chunk.gameObject, this); else if (Utils.fBM3D (worldX, worldY, worldZ, 0.1f, 3) < 0.42f) chunkData [x, y, z] = new Air (pos, this); //new Block(Block.BlockType.AIR, pos, //chunk.gameObject, this); else if(worldY <= Utils.GenerateStoneHeight(worldX,worldZ)) { if (Utils.fBM3D (worldX, worldY, worldZ, 0.01f, 2) < 0.4f && worldY < 40) chunkData [x, y, z] = new Diamond (pos, this); //new Block (Block.BlockType.DIAMOND, pos, //chunk.gameObject, this); else if (Utils.fBM3D (worldX, worldY, worldZ, 0.03f, 3) < 0.41f && worldY < 20) chunkData [x, y, z] = new RedStone (pos, this); //new Block (Block.BlockType.REDSTONE, pos, //chunk.gameObject, this); else chunkData [x, y, z] = new Stone (pos, this); //new Block(Block.BlockType.STONE, pos, //chunk.gameObject, this); } else if(worldY == surfaceHeight) { surfaceChunk = true; if (Utils.fBM3D (worldX, worldY, worldZ, 0.4f, 2) < 0.4f && worldY > 70) chunkData [x, y, z] = new WoodBase (pos, this); //new Block (Block.BlockType.WOODBASE, pos, //chunk.gameObject, this); else { chunkData [x, y, z] = new Grass (pos, this); //new Block (Block.BlockType.GRASS, pos, //chunk.gameObject, this); } } else if(worldY < surfaceHeight) chunkData[x,y,z] = new Dirt (pos, this);// new Block(Block.BlockType.DIRT, pos, //chunk.gameObject, this); else { chunkData [x, y, z] = new Air (pos, this); //new Block(Block.BlockType.AIR, pos, //chunk.gameObject, this); } if (worldY < 70 && worldY > 40 && chunkData [x, y, z].bType == Block.BlockType.AIR) { //fluid.gameObject.transform.parent = World.Instance.transform; chunkData [x, y, z] = new Water (pos, this); //new Block (Block.BlockType.WATER, pos, //fluid.gameObject, this); waterChunk = true; } status = ChunkStatus.DRAW; } }