Ejemplo n.º 1
0
        private directions getRoadEdge(internalData[,] map, int x, int y)
        {
            Structures.Type nw = map[x - 1, y + 1].structureType;
            Structures.Type no = map[x - 0, y + 1].structureType;
            Structures.Type ne = map[x + 1, y + 1].structureType;
            Structures.Type ea = map[x - 1, y - 0].structureType;
            Structures.Type we = map[x + 1, y - 0].structureType;
            Structures.Type sw = map[x - 1, y - 1].structureType;
            Structures.Type so = map[x - 0, y - 1].structureType;
            Structures.Type se = map[x + 1, y - 1].structureType;

            if (nw == Structures.Type.Road && 
                no == Structures.Type.Road &&
                ne == Structures.Type.Road) return directions.north;
            if (sw == Structures.Type.Road &&
                so == Structures.Type.Road &&
                se == Structures.Type.Road) return directions.south;
            if (nw == Structures.Type.Road &&
                we == Structures.Type.Road &&
                sw == Structures.Type.Road) return directions.west;
            if (ne == Structures.Type.Road &&
                ea == Structures.Type.Road &&
                se == Structures.Type.Road) return directions.east;

            return directions.none;

        }
Ejemplo n.º 2
0
 public internalData(int height, int biome, int riverType, int riverLevel, int waterLevel, Structures.Type structureType)
 {
     this.riverLevel    = riverLevel;
     this.structureType = structureType;
     this.waterLevel    = waterLevel;
     this.height        = height;
     this.biomeIndex    = biome;
     this.riverType     = riverType;
 }
Ejemplo n.º 3
0
 public static Structures.Type getStructureType(Color color)
 {
     Structures.Type structure = Structures.Type.Unknown;
     foreach (KeyValuePair <Structures.Type, Color> def in structureDefinitions)
     {
         if (match(def.Value, color))
         {
             structure = def.Key;
             break;
         }
     }
     return(structure);
 }
Ejemplo n.º 4
0
        void HeightMapChunk(ChunkRef chunk, bounds bound)
        {
            double mapXMin = bound.xMin;
            double mapXMax = bound.xMax;
            double mapYMin = bound.yMin;
            double mapYMax = bound.yMax;

            int size = 16;
            internalData[,] mapData = new internalData[3*size+2,  3*size+2];
            for (int x = -size-1; x <= 2*size; x++)
            {
                for (int z = -size-1; z <= 2 * size; z++)
                {
                    bound.updateBound(x, z);
                    // build 48x48 chunk of source maps for use below
                    mapData[x+size+1, z+size+1] = generateInternalMapChunk(bound);
                }
            }
            
            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    bound.updateBound(x, z);


                   

                    internalData id = mapData[x+1, z+1]; // .getInternalData(xt, zt);
                    int height      = id.height;
                    int waterLevel  = id.waterLevel;
                    int riverLevel  = id.riverLevel;
                    int depth       = id.riverType;
                    Structures.Type structure   = id.structureType;
                    int biomeIndex  = id.biomeIndex < 0 ? 0 : id.biomeIndex;



                    if (height > maxHeight) maxHeight = height;
                    if (height < minHeight) minHeight = height;

                    
                    chunk.Biomes.SetBiome(x, z, BiomeList.biomes[biomeIndex].mineCraftBiome);
                    //create bedrock
                    for (int y = 0; y < 2; y++)
                    {
                        chunk.Blocks.SetID(x, y, z, BlockType.BEDROCK);
                    }
                    ////deal with rivers
                    // BezierRivers.MakeRivers mr = new BezierRivers.MakeRivers();
                    // mr.makeRivers();

                    if (riverLevel >= 0)
                    {
                        chunk.Biomes.SetBiome(x, z, BiomeType.River);

                        height = riverLevel;

                        // All DF rivers are 1 px wide.  
                        // That scales into embarkWidth regardless of type of river
                        // This metric allows us to fine-tune river width beyond that of embarkWidth
                        double oX = (mapXMax - mapXMin) * x % 16 - 8;
                        double oY = (mapYMax - mapYMin) * z % 16 - 8;
                        // Console.WriteLine("[{3},{4},({2}): {0},{1}  (({5},{6})) [{7},{8}]", oX, oY, depth,x,z, mux, muy, mux-Math.Floor(mux + 0.5), muy-Math.Floor(muy+0.5));
                        int scale = Settings.Default.blocksPerEmbarkTile;

                        // can account for depth of river here 
                        for (int y = 0; y < height - depth - 2; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.STONE);
                        }
                        for (int y = height - depth - 2; y < height - depth - 1; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.GRAVEL);
                        }
                        for (int y = height - depth - 1; y < height; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.WATER);
                        }
                        for (int y = height; y < height + 1; y++)//Just to blockupdate for flowing water(falls).
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.AIR);
                        }
                    }
                    else if (BiomeList.biomes[biomeIndex].mineCraftBiome == BiomeID.DeepOcean && waterLevel <= height)
                    {
                        //make beaches
                        chunk.Biomes.SetBiome(x, z, BiomeType.Beach);
                        height = 98 + shift;
                        for (int y = 0; y < height - 4; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.STONE);
                        }
                        for (int y = height - 4; y < height - 3; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.SANDSTONE);
                        }
                        for (int y = height - 3; y < height; y++)
                        {
                            chunk.Blocks.SetID(x, y, z, BlockType.SAND);
                        }

                    }
                    else
                    {
                        // Create the rest, according to biome
                        for (int y = 2; y < height; y++)
                        {
                            if (y >= chunk.Blocks.YDim) break;
                            chunk.Blocks.SetID(x, y, z, BiomeList.biomes[biomeIndex].getBlockID(height - y, x + (chunk.X * 16), z + (chunk.Z * 16)));
                        }
                    }
                    //// Create Oceans and lakes
                    for (int y = height; y < waterLevel; y++)
                    {
                        if (y < 2) continue;
                        if (y >= chunk.Blocks.YDim) break;
                        chunk.Blocks.SetID(x, y, z, BlockType.STATIONARY_WATER);
                    }

                    // Fill caves
                    for (int y = 2; y < height; y++)
                    {
                        if (y >= chunk.Blocks.YDim) break;
                        int caveID = currentCaveMap.getCaveBlock(bound.mux, y - shift, bound.muy);
                        if (caveID == -2)
                            break;
                        if (caveID >= 0)
                            chunk.Blocks.SetID(x, y, z, caveID);
                    }

                    // Populate Structures
                    int tunnelHeight = 5;
                    int tunnelDepth = 10;
                    // structureNeighbor:
                    // 1 2 3
                    // 4 X 5
                    // 6 7 8

                    // 

                   switch (structure)
                    {
                        case Structures.Type.Underground_Road:
                            chunk.Blocks.SetID(x, height - tunnelDepth - tunnelHeight, z, BlockType.COBBLESTONE);
                            for (int y = height - tunnelHeight - tunnelDepth; y < height - tunnelDepth; y++)
                            {
                                chunk.Blocks.SetID(x, y, z, BlockType.AIR);
                            }
                            chunk.Blocks.SetID(x, height - tunnelHeight, z, BlockType.COBBLESTONE);
                            break;
                        case Structures.Type.Road: // road
                            for (int y = height - 2; y < height; y++)
                            {
                                chunk.Blocks.SetID(x, y, z, BlockType.STONE_BRICK);
                                if (mapData[x + 1 - 1, z +1 ].structureType == Structures.Type.Bridge)
                                {
                                    chunk.Blocks.SetID(x, height + 1, z, BlockType.COBBLESTONE_STAIRS);
                                    chunk.Blocks.GetBlock(x, height + 1, z).Data = (int)StairOrientation.ASCEND_WEST;
                                }
                                if (mapData[x + 1 + 1, z + 1 ].structureType == Structures.Type.Bridge)
                                {
                                    chunk.Blocks.SetID(x, height + 1, z, BlockType.COBBLESTONE_STAIRS);
                                    chunk.Blocks.GetBlock(x, height + 1, z).Data = (int)StairOrientation.ASCEND_EAST;
                                }

                            }
                            break;
                        case Structures.Type.Bridge: // bridge
                            chunk.Blocks.SetID(x, height + 1, z, BlockType.HARDENED_CLAY);
                            break;
                        case Structures.Type.HumanCity1: // wheat?
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.GOLD_BLOCK);
                            break;
                        case Structures.Type.HumanCity2: // potato
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.HAY_BLOCK);
                            break;
                        case Structures.Type.HumanCity3: // carrot
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.OBSIDIAN);
                            break;
                        case Structures.Type.HumanCity4: // carrot
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.BIRCH_WOOD_STAIRS);
                            break;
                        case Structures.Type.Fortress: // Fort?
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.IRON_BLOCK);
                            break;
                        case Structures.Type.ElvenCity1: // Farm?
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.FARMLAND);
                            break;
                        case Structures.Type.ElvenCity2: // Farm?
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.MELON);
                            break;
                        case Structures.Type.ElvenCity3: // Farm?
                            chunk.Blocks.SetID(x, height - 1, z, BlockType.PUMPKIN);
                            break;
                        default:
                            directions neighbor = getRoadEdge(mapData, x + 1, z + 1);  // +1 for edge shift

                            switch (neighbor)
                            {
                                case directions.north:
                                case directions.south:
                                    if (x % 4 < 3)
                                    {
                                        if (x % 8 == 1)
                                        {
                                            chunk.Blocks.SetID(x, height + 1, z, BlockType.TORCH);
                                            currentWorld.
                                            chunk.Blocks.GetBlock(x, height + 1, z).SetTileEntity(                                        }
                                        chunk.Blocks.SetID(x, height, z, BlockType.FENCE);
                                    }
                                    break;
                                case directions.west:
                                case directions.east:
                                    if (z % 4 < 3)
                                    {
                                        chunk.Blocks.SetID(x, height, z, BlockType.FENCE);
                                        if (z % 8 == 1)
                                        {
                                            chunk.Blocks.SetID(x, height + 1, z, BlockType.TORCH);
                                        }
                                    }
                                    break;
                            }

                            break;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void setStructure(Structures.Type v, int x, int y)
 {
     this.data[x - offsetX, y - offsetY].structureType = v;
 }