private void BlockAddBtn_Click(object sender, RoutedEventArgs e) { Block block = new WoodBlock(100, 100, new Classes.Point()); switch (blockComboBox.SelectedItem) { case "Wood": block = new WoodBlock(100, 10, new Classes.Point()); break; case "Metal": block = new MetalBlock(100, 10, new Classes.Point()); break; case "Rust": block = new RustBlock(100, 10, new Classes.Point()); break; case "Sand": block = new SandBlock(100, 10, new Classes.Point()); break; default: break; } block.Image.PointerPressed += SelectedImage_onMuseClick; _selectedImage = block.Image; Map.CreateAndAddBlockToMap(block); // DataUpdater(block); }
public Chunk Create() { var chunk = new Chunk(dimension, address); var heightMap = new HeightMap(dimension.Seed.Dimension.Value, address, MaxHeight); var biomeMap = new BiomeMap(dimension.Seed.Temperature.Value, dimension.Seed.Humidity.Value, address); heightMap.Generate(); biomeMap.Generate(); for (int x = 0; x < Chunk.Size; x++) { for (int z = 0; z < Chunk.Size; z++) { var yMax = heightMap[x, z]; var yMaxValue = Mathf.RoundToInt(yMax); if (yMaxValue > MaxHeight) { yMaxValue = MaxHeight; } for (int y = 0; y <= yMaxValue; y++) { BaseBlock block; if (y > WaterHeight + 10) { block = new StoneBlock(); } else if (y > WaterHeight + 0) { block = new GrassBlock(); } else { block = new SandBlock(); } if (y >= WaterHeight) { var biome = biomeMap[x, z]; if (biome == "desert") { block = new SandBlock(); } else if (biome == "stone") { block = new StoneBlock(); } else if (biome == "grass") { block = new GrassBlock(); } else { block = new GrassBlock(); } } else { block = new SandBlock(); } chunk[x, y, z] = block; } for (int y = yMaxValue + 1; y < Chunk.Depth; y++) { BaseBlock block; if (y < WaterHeight) { block = new WaterBlock(); } else { block = new AirBlock(); } chunk[x, y, z] = block; } } } return(chunk); }