예제 #1
0
        public int RenderToWorld(BlockManager bm)
        {
            int t = Width / 2;
            Vector2 tStart = new Vector2 (Start);
            Vector2 tEnd = new Vector2 (End);
            //Number of set tiles
            int ts = 0;

            Orientation o = GetOrientation ();
            bool roadDir = o == Orientation.NORTH || o == Orientation.SOUTH;

            if (!roadDir) {
                for (int y = -t; y <= t; ++y) {
                    tStart.Y = Start.Y + y;
                    tEnd.Y = End.Y + y;
                    ts += DrawRoadLine (tStart, tEnd, bm);
                }
            } else {
                for (int x = -t; x <= t; ++x) {
                    tStart.X = Start.X + x;
                    tEnd.X = End.X + x;
                    ts += DrawRoadLine (tStart, tEnd, bm);
                }
            }
            return ts;
        }
예제 #2
0
        public static int[,] MakePaths(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength,
                                       string strCitySize, bool booIncludeMineshaftOriginal)
        {
            // if the user doesn't want a mineshaft, we just tell Mace it's already been added
            _booIncludedMineshaft = !booIncludeMineshaftOriginal;
            _lstDistricts.Clear();
            _lstAllBuildings.Clear();
            _lstStreetsUsed.Clear();
            _intStreet = 0;
            _intBlockStart = intFarmLength + 13;
            _lstStreetsUsed.Clear();
            int intPlotBlocks = (1 + intMapLength) - (_intBlockStart * 2);
            int[,] intArea = new int[intPlotBlocks, intPlotBlocks];
            // make the main roads
            for (int a = 0; a <= intArea.GetUpperBound(0); a++)
            {
                for (int b = -1; b <= 1; b++)
                {
                    intArea[a, (intArea.GetUpperBound(0) / 2) + b] = 1;
                    intArea[(intArea.GetUpperBound(0) / 2) + b, a] = 1;
                }
            }
            // make the districts
            // top right
            SplitArea(bm, intArea, 0, 0,
                                   (intArea.GetLength(0) / 2) - 2, (intArea.GetLength(0) / 2) - 2);
            // bottom left
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, (intArea.GetLength(0) / 2) + 2,
                                   intArea.GetUpperBound(0), intArea.GetUpperBound(0));
            // bottom right
            SplitArea(bm, intArea, (intArea.GetLength(0) / 2) + 2, 0,
                                   intArea.GetUpperBound(0), (intArea.GetLength(0) / 2) - 2);
            // top left
            SplitArea(bm, intArea, 0, (intArea.GetLength(0) / 2) + 2,
                                   (intArea.GetLength(0) / 2) - 2, intArea.GetUpperBound(0));

            ShuffleDistricts(_lstDistricts);
            foreach (structDistrict stdCurrent in _lstDistricts)
            {
                int[,] intDistrict = FillArea(intArea, (stdCurrent.x2 - stdCurrent.x1),
                                              (stdCurrent.z2 - stdCurrent.z1), stdCurrent.x1, stdCurrent.z1,
                                              strCitySize != "Very small");
                for (int x = 0; x < intDistrict.GetUpperBound(0) - 1; x++)
                {
                    for (int y = 0; y < intDistrict.GetUpperBound(1) - 1; y++)
                    {
                        intArea[stdCurrent.x1 + x + 1, stdCurrent.z1 + y + 1] = intDistrict[x + 1, y + 1];
                    }
                }
            }

            MakePaths(world, bm, intArea, intMapLength);

            return intArea;
        }
예제 #3
0
 /// <summary>
 /// Create a column with a given depth of floor surface with empty blocks above
 /// </summary>
 /// <param name="bm">the BlockManger for the world</param>
 /// <param name="posX">The X coordinate of the column</param>
 /// <param name="posY">The Y coordinate where the floor surface ends and air begins</param>
 /// <param name="posZ">The Z coordinate of the column</param>
 private static void MakeOpenSurface(BlockManager bm, Int32 posX, Int32 posY, Int32 posZ)
 {
     for (Int32 yi = posY - 5; yi < posY; yi++)
     {
         bm.SetID(posX, yi, posZ, BlockType.OBSIDIAN);
     }
     for (Int32 yi = posY; yi < 256; yi++)
     {
         bm.SetID(posX, yi, posZ, BlockType.AIR);
     }
 }
예제 #4
0
 public static void ReplaceValuableBlocks(BetaWorld worldDest, BlockManager bm, int intCitySize,
                                          int intWallMaterial)
 {
     int intReplaced = 0;
     for (int x = 0; x < intCitySize; x++)
     {
         for (int z = 0; z < intCitySize; z++)
         {
             for (int y = 32; y < 128; y++)
             {
                 if ((int)bm.GetID(x, y, z) != intWallMaterial)
                 {
                     switch ((int)bm.GetID(x, y, z))
                     {
                         case BlockType.GOLD_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.YELLOW);
                             intReplaced++;
                             break;
                         case BlockType.IRON_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_GRAY);
                             intReplaced++;
                             break;
                         case BlockType.OBSIDIAN:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLACK);
                             intReplaced++;
                             break;
                         case BlockType.DIAMOND_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_BLUE);
                             intReplaced++;
                             break;
                         case BlockType.LAPIS_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLUE);
                             intReplaced++;
                             break;
                         // no need for a default, because we purposefully want to skip all the other blocks
                     }
                     if (intReplaced > 25)
                     {
                         worldDest.Save();
                         intReplaced = 0;
                     }
                 }
             }
         }
     }
 }
예제 #5
0
 public static structPoint MakeInsideCity(BlockManager bm, BetaWorld worldDest, int[,] intArea,
                                          int intFarmLength, int intMapLength, bool booIncludePaths)
 {
     int intBlockStart = intFarmLength + 13;
     structPoint spMineshaftEntrance = MakeBuildings(bm, intArea, intBlockStart, worldDest, intFarmLength);
     worldDest.Save();
     if (!booIncludePaths)
     {
         RemovePaths(bm, intArea, intBlockStart);
     }
     else
     {
         JoinPathsToRoad(bm, intMapLength, intFarmLength);
     }
     MakeStreetLights(bm, intMapLength, intFarmLength);
     MakeFlowers(bm, worldDest, intFarmLength, intMapLength);
     return spMineshaftEntrance;
 }
예제 #6
0
        /// <summary>
        /// Create an arena structure centered on the player
        /// </summary>
        /// <param name="bm">the BlockManager for the world</param>
        /// <param name="pos">the position of the player</param>
        /// <param name="podiumRad">the extent of the flat floor of the arena, measured in each direction from the players location</param>
        /// <param name="stepsRadius">the number of tiered levels surrounding the arena</param>
        private static void MakeArena(BlockManager bm, Vector3 pos, Int32 podiumRad, Int32 stepsRadius)
        {
            Int32 posX = (Int32)Math.Round(pos.X);
            Int32 posY = (Int32)Math.Floor(pos.Y);
            Int32 posZ = (Int32)Math.Round(pos.Z);

            for (int xi = posX - podiumRad; xi <= posX + podiumRad; xi++)
            {
                for (int zi = posZ - podiumRad; zi <= posZ + podiumRad; zi++)
                {
                    MakeOpenSurface(bm, xi, posY, zi);
                }
            }

            for (Int32 ri = 1; ri <= stepsRadius; ri++)
            {
                MakeRing(bm, posX, posY + ri, posZ, podiumRad + ri);
            }
        }
예제 #7
0
 private static void AddFlowersToBlock(BlockManager bmDest, int x, int z)
 {
     switch (RandomHelper.Next(4))
     {
         case 0:
             bmDest.SetID(x, 64, z, BlockType.RED_ROSE);
             break;
         case 1:
             bmDest.SetID(x, 64, z, BlockType.YELLOW_FLOWER);
             break;
         case 2:
         case 3:
             BlockShapes.MakeBlock(x, 64, z, BlockType.TALL_GRASS, RandomHelper.Next(1, 3));
             break;
         default:
             Debug.Fail("Invalid switch result");
             break;
     }
 }
예제 #8
0
 public static void MakeMineshaft(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength, Buildings.structPoint spMineshaftEntrance)
 {
     _intBlockStartBuildings = intFarmLength + 13;
     int intMineshaftSize = (1 + intMapLength) - (_intBlockStartBuildings * 2);
     if (intMineshaftSize % 5 > 0)
     {
         intMineshaftSize += 5 - (intMineshaftSize % 5);
     }
     _intBlockStartBuildings -= 2;
     for (int intLevel = 1; intLevel <= 7; intLevel++)
     {
         MakeLevel(world, bm, intLevel, intMineshaftSize, spMineshaftEntrance);
     }
     int intBlockToReplace = bm.GetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1);
     BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x,
                              3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockType.WOOD, 0);
     BlockHelper.MakeLadder(spMineshaftEntrance.x, 4, 63, spMineshaftEntrance.z, 0, BlockType.WOOD);
     BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1,
                              spMineshaftEntrance.z + 1, BlockType.STONE, 0);
     bm.SetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1, intBlockToReplace);
 }
예제 #9
0
 public static void PositionRails(BetaWorld worldDest, BlockManager bm, int intCitySize)
 {
     int intReplaced = 0;
     for (int x = 0; x < intCitySize; x++)
     {
         for (int z = 0; z < intCitySize; z++)
         {
             for (int y = 0; y < 128; y++)
             {
                 if (bm.GetID(x, y, z) == BlockType.RAILS)
                 {
                     BlockHelper.MakeRail(x, y, z);
                     if (++intReplaced > 100)
                     {
                         worldDest.Save();
                         intReplaced = 0;
                     }
                 }
             }
         }
     }
 }
예제 #10
0
        public static void MakeFarms(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength)
        {
            AddBuildings(bm, intFarmLength, intMapLength);
            int intFail = 0;
            int intFarms = 0;
            while (intFail <= 500)
            {
                int xlen = RandomHelper.Next(8, 26);
                int x1 = RandomHelper.Next(4, intMapLength - (4 + xlen));
                int zlen = RandomHelper.Next(8, 26);
                int z1 = RandomHelper.Next(4, intMapLength - (4 + zlen));
                if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
                      x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
                {
                    bool booValid = true;
                    for (int x = x1 - 2; x <= x1 + xlen + 2 && booValid; x++)
                    {
                        for (int z = z1 - 2; z <= z1 + zlen + 2 && booValid; z++)
                        {
                            // make sure it doesn't overlap with the spawn point or another farm
                            if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                                bm.GetID(x, 63, z) != BlockType.GRASS || bm.GetID(x, 64, z) != BlockType.AIR)
                            {
                                booValid = false;
                                intFail++;
                            }
                        }
                    }
                    if (booValid)
                    {
                        // first there is a 25% chance of a hill or pond
                        // if not, for large farms, there is a 50% chance it'll be an orchard
                        // if not, 33% are cactus, 33% are wheat and 33% are sugarcane

                        FarmTypes curFarm;
                        int intFarmType = RandomHelper.Next(100);
                        if (xlen >= 10 && zlen >= 10 && intFarmType > 75)
                        {
                            if (RandomHelper.NextDouble() > 0.5)
                            {
                                curFarm = FarmTypes.Pond;
                                MakePond(bm, x1, xlen, z1, zlen, false);
                            }
                            else
                            {
                                curFarm = FarmTypes.Hill;
                                MakeHill(bm, x1, xlen, z1, zlen, false);
                            }
                        }
                        else
                        {
                            intFarmType = RandomHelper.Next(100);
                            if (((xlen >= 11 && zlen >= 16) || (xlen >= 16 && zlen >= 11)) && intFarmType > 50)
                            {
                                curFarm = FarmTypes.Orchard;
                                xlen = ((int)((xlen - 1) / 5) * 5) + 1;
                                zlen = ((int)((zlen - 1) / 5) * 5) + 1;
                            }
                            else
                            {
                                intFarmType = RandomHelper.Next(3);
                                if (intFarmType == 2)
                                {
                                    curFarm = FarmTypes.Cactus;
                                }
                                else if (intFarmType == 1)
                                {
                                    curFarm = FarmTypes.Wheat;
                                    xlen += (xlen % 2) - 1;
                                    zlen += (zlen % 2) - 1;
                                }
                                else
                                {
                                    curFarm = FarmTypes.SugarCane;
                                    xlen += (xlen % 2) - 1;
                                    zlen += (zlen % 2) - 1;
                                }
                            }
                        }

                        int intWallMaterial = RandomHelper.NextDouble() > 0.5 ? BlockType.FENCE : BlockType.LEAVES;

                        switch (curFarm)
                        {
                            case FarmTypes.Hill:
                            case FarmTypes.Pond:
                                intWallMaterial = 0;
                                break;
                            case FarmTypes.SugarCane:
                            case FarmTypes.Mushroom:
                                if (RandomHelper.NextDouble() > 0.5)
                                {
                                    intWallMaterial = 0;
                                }
                                break;
                            case FarmTypes.Wheat:
                                intWallMaterial = BlockType.LEAVES;
                                break;
                                // no need for default - the other types don't need anything here
                        }
                        switch (intWallMaterial)
                        {
                            case BlockType.FENCE:
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 64, z1, z1 + zlen,
                                                             BlockType.FENCE, 0, -1);
                                break;
                            case BlockType.LEAVES:
                                // the saplings will all disappear if one of them is broken.
                                // so we put wood beneath them to stop that happening
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 63, 63, z1, z1 + zlen,
                                                             BlockType.WOOD, 0, -1);
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 65, z1, z1 + zlen, BlockType.LEAVES, 0,
                                  RandomHelper.RandomNumber((int)LeafType.OAK, (int)LeafType.SPRUCE,
                                                            (int)LeafType.BIRCH));
                                break;
                            case 0:
                                // no wall
                                break;
                            default:
                                Debug.Fail("Invalid switch result");
                                break;
                        }

                        switch (curFarm)
                        {
                            case FarmTypes.Orchard:
                                int intSaplingType = RandomHelper.RandomNumber(SaplingBirchDataID,
                                                                               SaplingOakDataID,
                                                                               SaplingSpruceDataID);
                                for (int x = x1 + 3; x <= x1 + xlen - 3; x += 5)
                                {
                                    for (int z = z1 + 3; z <= z1 + zlen - 3; z += 5)
                                    {
                                        bm.SetID(x, 63, z, BlockType.GRASS);
                                        BlockShapes.MakeBlock(x, 64, z, BlockType.SAPLING, intSaplingType);
                                    }
                                }
                                break;
                            case FarmTypes.Cactus:
                                int intAttempts = 0;
                                do
                                {
                                    int xCactus = RandomHelper.Next(x1 + 1, x1 + xlen);
                                    int zCactus = RandomHelper.Next(z1 + 1, z1 + zlen);
                                    bool booValidFarm = true;
                                    for (int xCheck = xCactus - 1; xCheck <= xCactus + 1 && booValidFarm; xCheck++)
                                    {
                                        for (int zCheck = zCactus - 1; zCheck <= zCactus + 1 && booValidFarm; zCheck++)
                                        {
                                            if (bm.GetID(xCheck, 64, zCheck) != BlockType.AIR)
                                            {
                                                booValidFarm = false;
                                            }
                                        }
                                    }
                                    if (booValidFarm)
                                    {
                                        bm.SetID(xCactus, 64, zCactus, BlockType.CACTUS);
                                        if (RandomHelper.NextDouble() > 0.5)
                                        {
                                            bm.SetID(xCactus, 65, zCactus, BlockType.CACTUS);
                                        }
                                    }
                                }
                                while (++intAttempts < 100);
                                break;
                            case FarmTypes.Wheat:
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 66, 66, z1, z1 + zlen,
                                                             BlockType.GLASS, 0, -1);
                                BlockShapes.MakeSolidBox(x1 + 1, x1 + xlen - 1, 67, 67, z1 + 1, z1 + zlen - 1,
                                                         BlockType.GLASS, 0);
                                break;
                            // no need for a default, because there's nothing to do for the other farms
                        }

                        for (int x = x1 + 1; x <= x1 + xlen - 1; x++)
                        {
                            for (int z = z1 + 1; z <= z1 + zlen - 1; z++)
                            {
                                switch (curFarm)
                                {
                                    case FarmTypes.Cactus:
                                        bm.SetID(x, 63, z, BlockType.SAND);
                                        break;
                                    case FarmTypes.Wheat:
                                        if (z == z1 + 1)
                                        {
                                            bm.SetID(x, 63, z, BlockType.DOUBLE_SLAB);
                                        }
                                        else if (x % 2 == 0)
                                        {
                                            BlockShapes.MakeBlock(x, 63, z, BlockType.FARMLAND, 1);
                                            bm.SetID(x, 64, z, BlockType.CROPS);
                                        }
                                        else
                                        {
                                            bm.SetID(x, 63, z, BlockType.STATIONARY_WATER);
                                        }
                                        break;
                                    case FarmTypes.SugarCane:
                                        if (z != z1 + 1)
                                        {
                                            if (x % 2 == 0)
                                            {
                                                bm.SetID(x, 64, z, BlockType.SUGAR_CANE);
                                                if (RandomHelper.Next(100) > 50)
                                                {
                                                    bm.SetID(x, 65, z, BlockType.SUGAR_CANE);
                                                }
                                            }
                                            else
                                            {
                                                bm.SetID(x, 63, z, BlockType.STATIONARY_WATER);
                                            }
                                        }
                                        break;
                                    // no need for a default, because there's nothing to do for the other farms
                                }
                            }
                        }
                        int intDoorPosition = x1 + RandomHelper.Next(1, xlen - 1);
                        if (curFarm == FarmTypes.Wheat)
                        {
                            bm.SetID(intDoorPosition, 63, z1, BlockType.DOUBLE_SLAB);
                        }
                        if (intWallMaterial != 0)
                        {
                            BlockShapes.MakeBlock(intDoorPosition, 64, z1, BlockType.WOOD_DOOR, 4);
                            BlockShapes.MakeBlock(intDoorPosition, 65, z1, BlockType.WOOD_DOOR,
                                                  4 + (int)DoorState.TOPHALF);
                        }
                        intFail = 0;
                        if (++intFarms > 10)
                        {
                            world.Save();
                            intFarms = 0;
                        }
                    }
                }
            }
            MakeMiniPondsAndHills(world, bm, intFarmLength, intMapLength);
            MakeFlowers(bm, intFarmLength, intMapLength);
        }
예제 #11
0
 private static void MakeMiniPondsAndHills(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength)
 {
     int intFail = 0;
     int intAdded = 0;
     do
     {
         int xlen = RandomHelper.Next(4, 12);
         int x1 = RandomHelper.Next(1, intMapLength - (1 + xlen));
         int zlen = RandomHelper.Next(4, 12);
         int z1 = RandomHelper.Next(1, intMapLength - (1 + zlen));
         if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
               x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
         {
             bool booValid = true;
             for (int x = x1 - 1; x <= x1 + xlen + 1 && booValid; x++)
             {
                 for (int z = z1 - 1; z <= z1 + zlen + 1 && booValid; z++)
                 {
                     // make sure it doesn't overlap with the spawn point or another farm
                     if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                         bm.GetID(x, 63, z) != BlockType.GRASS || bm.GetID(x, 64, z) != BlockType.AIR)
                     {
                         booValid = false;
                     }
                 }
             }
             if (booValid)
             {
                 if (RandomHelper.NextDouble() > 0.5)
                 {
                     MakePond(bm, x1, xlen, z1, zlen, true);
                 }
                 else
                 {
                     MakeHill(bm, x1, xlen, z1, zlen, true);
                 }
                 intFail = 0;
                 if (++intAdded % 25 == 0)
                 {
                     world.Save();
                 }
             }
             else
             {
                 intFail++;
             }
         }
     } while (intFail < 500);
 }
예제 #12
0
        private static void MakeHill(BlockManager bm, int x, int xlen, int z, int zlen, bool booMini)
        {
            int[,] intArea = new int[xlen, zlen];
            int a, b;

            int c = 0, d = 0, clen = -1, dlen = -1;
            if (!booMini)
            {
                c = RandomHelper.Next(1, intArea.GetUpperBound(0) - 7);
                d = RandomHelper.Next(1, intArea.GetUpperBound(1) - 7);
                clen = RandomHelper.Next(3, 7);
                dlen = RandomHelper.Next(3, 7);
            }

            for (a = 1; a <= intArea.GetUpperBound(0) - 1; a++)
            {
                for (b = 1; b <= intArea.GetUpperBound(1) - 1; b++)
                {
                    if (a < c || a > c + clen || b < d || b > d + dlen)
                    {
                        intArea[a, b] = 1;
                    }
                }
            }

            intArea = CheckAgainstNeighbours(intArea, 0, 0, 7, 0, RandomHelper.Next(7, 11), true);
            intArea = CheckAgainstNeighbours(intArea, 6, 0, 3, 2, 1, false);
            intArea = CheckAgainstNeighbours(intArea, 14, 0, 3, 3, 1, false);

            for (a = 1; a <= intArea.GetUpperBound(0) - 1; a++)
            {
                for (b = 1; b <= intArea.GetUpperBound(1) - 1; b++)
                {
                    for (int y = 1; y <= intArea[a, b]; y++)
                    {
                        if (y == intArea[a, b])
                        {
                            bm.SetID(x + a, y + 63, z + b, BlockType.GRASS);
                            switch (RandomHelper.Next(0, 10))
                            {
                                case 0:
                                    bm.SetID(x + a, y + 64, z + b, BlockType.RED_ROSE);
                                    break;
                                case 1:
                                    bm.SetID(x + a, y + 64, z + b, BlockType.YELLOW_FLOWER);
                                    break;
                                case 2:
                                case 3:
                                    bm.SetID(x + a, y + 64, z + b, BlockType.TALL_GRASS);
                                    bm.SetData(x + a, y + 64, z + b, RandomHelper.Next(1, 3));
                                    break;
                                // we want to skip the other numbers, so there's no need for a default
                            }
                        }
                        else
                        {
                            bm.SetID(x + a, y + 63, z + b, BlockType.DIRT);
                        }
                    }
                }
            }
        }
예제 #13
0
 private static void MakeFlowers(BlockManager bm, int intFarmLength, int intMapLength)
 {
     for (int x = 0; x <= intMapLength; x++)
     {
         for (int z = 0; z <= intMapLength; z++)
         {
             if (x <= intFarmLength || z <= intFarmLength ||
                 x >= intMapLength - intFarmLength || z >= intMapLength - intFarmLength)
             {
                 bool booFree = true;
                 for (int xCheck = x - 1; xCheck <= x + 1 && booFree; xCheck++)
                 {
                     for (int zCheck = z - 1; zCheck <= z + 1 && booFree; zCheck++)
                     {
                         booFree = bm.GetID(xCheck, 63, zCheck) == BlockType.GRASS &&
                                   bm.GetID(xCheck, 64, zCheck) == BlockType.AIR;
                     }
                 }
                 if (booFree && RandomHelper.NextDouble() > 0.90)
                 {
                     switch (RandomHelper.Next(4))
                     {
                         case 0:
                             bm.SetID(x, 64, z, BlockType.RED_ROSE);
                             break;
                         case 1:
                             bm.SetID(x, 64, z, BlockType.YELLOW_FLOWER);
                             break;
                         case 2:
                         case 3:
                             bm.SetID(x, 64, z, BlockType.TALL_GRASS);
                             bm.SetData(x, 64, z, RandomHelper.Next(1, 3));
                             break;
                         default:
                             Debug.Fail("Invalid switch result");
                             break;
                     }
                 }
             }
         }
     }
 }
예제 #14
0
        private static structPoint MakeBuildings(BlockManager bmDest, int[,] intArea, int intBlockStart, BetaWorld world, int intFarmLength)
        {
            structPoint structLocationOfMineshaftEntrance = new structPoint();
            structLocationOfMineshaftEntrance.x = -1;
            structLocationOfMineshaftEntrance.z = -1;
            int intBuildings = 0;
            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int z = 0; z < intArea.GetLength(1); z++)
                {
                    // hack: this 100 to 500 stuff is all a bit hackish really, need to find a proper solution
                    if (intArea[x, z] >= 100 && intArea[x, z] <= 500)
                    {
                        SourceWorld.Building CurrentBuilding = SourceWorld.GetBuilding(intArea[x, z] - 100);
                        SourceWorld.InsertBuilding(bmDest, intArea, intBlockStart, x, z,
                                                   CurrentBuilding, 0);

                        if (CurrentBuilding.btThis == SourceWorld.BuildingTypes.MineshaftEntrance)
                        {
                            structLocationOfMineshaftEntrance.x = intBlockStart + x + (int)(CurrentBuilding.intSizeX / 2);
                            structLocationOfMineshaftEntrance.z = intBlockStart + z + (int)(CurrentBuilding.intSizeZ / 2);
                            SourceWorld.Building BalloonBuilding = SourceWorld.GetBuilding("Sky Feature");
                            SourceWorld.InsertBuilding(bmDest, new int[0, 0], intBlockStart,
                                                       x + ((CurrentBuilding.intSizeX - BalloonBuilding.intSizeX) / 2),
                                                       z + ((CurrentBuilding.intSizeZ - BalloonBuilding.intSizeZ) / 2),
                                                       BalloonBuilding, 0);
                        }

                        intArea[x + CurrentBuilding.intSizeX - 2, z + CurrentBuilding.intSizeZ - 2] = 0;
                        if (++intBuildings == NumberOfBuildingsBetweenSaves)
                        {
                            world.Save();
                            intBuildings = 0;
                        }
                    }
                }
            }
            world.Save();
            return structLocationOfMineshaftEntrance;
        }
예제 #15
0
        public void BuildRoom (BlockManager bm, int x, int y, int z)
        {
            int ox = originx + (cellxlen + wallxwidth) * x;
            int oy = originy + (cellylen + wallywidth) * y;
            int oz = originz + (cellzlen + wallzwidth) * z;

            // Hollow out room
            for (int xi = 0; xi < cellxlen; xi++) {
                int xx = ox + wallxwidth + xi;
                for (int zi = 0; zi < cellzlen; zi++) {
                    int zz = oz + wallzwidth + zi;
                    for (int yi = 0; yi < cellylen; yi++) {
                        int yy = oy + wallywidth + yi;
                        bm.SetID(xx, yy, zz, (int)BlockType.AIR);
                    }
                }
            }

            // Build walls
            for (int xi = 0; xi < cellxlen + 2 * wallxwidth; xi++) {
                for (int zi = 0; zi < cellzlen + 2 * wallzwidth; zi++) {
                    for (int yi = 0; yi < wallywidth; yi++) {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi, oy + yi + cellylen + wallywidth, oz + zi, (int)BlockType.BEDROCK);
                    }
                }
            }

            for (int xi = 0; xi < cellxlen + 2 * wallxwidth; xi++) {
                for (int zi = 0; zi < wallzwidth; zi++) {
                    for (int yi = 0; yi < cellylen + 2 * wallywidth; yi++) {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi, oy + yi, oz + zi + cellzlen + wallzwidth, (int)BlockType.BEDROCK);
                    }
                }
            }

            for (int xi = 0; xi < wallxwidth; xi++) {
                for (int zi = 0; zi < cellzlen + 2 * wallzwidth; zi++) {
                    for (int yi = 0; yi < cellylen + 2 * wallywidth; yi++) {
                        bm.SetID(ox + xi, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                        bm.SetID(ox + xi + cellxlen + wallxwidth, oy + yi, oz + zi, (int)BlockType.BEDROCK);
                    }
                }
            }

            // Torchlight
            bm.SetID(ox + wallxwidth, oy + wallywidth + 2, oz + wallzwidth + 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 2, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 1, oy + wallywidth + 2, oz + wallzwidth + 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 1, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 2, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + 1, oy + wallywidth + 2, oz + wallzwidth, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 2, oy + wallywidth + 2, oz + wallzwidth, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + 1, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 1, (int)BlockType.TORCH);
            bm.SetID(ox + wallxwidth + cellxlen - 2, oy + wallywidth + 2, oz + wallzwidth + cellzlen - 1, (int)BlockType.TORCH);
        }
예제 #16
0
            if (nbtstr == null) {
                return false;
            }

            NbtTree tree = new NbtTree(nbtstr);

            _level = new Level(this);
            _level = _level.LoadTreeSafe(tree.Root);

            return _level != null;
        }


        internal static void OnResolveOpen (object sender, OpenWorldEventArgs e)
        {
            try {
                AlphaWorld world = new AlphaWorld().OpenWorld(e.Path);
예제 #17
0
        public void AddPrize (BlockManager bm, int x, int y, int z)
        {
            int ox = originx + (cellxlen + wallxwidth) * x + wallxwidth;
            int oy = originy + (cellylen + wallywidth) * y + wallywidth;
            int oz = originz + (cellzlen + wallzwidth) * z + wallzwidth;

            Random rand = new Random();
            for (int xi = 0; xi < cellxlen; xi++) {
                for (int zi = 0; zi < cellzlen; zi++) {
                    if (rand.NextDouble() < 0.1) {
                        bm.SetID(ox + xi, oy, oz + zi, (int)BlockType.DIAMOND_BLOCK);
                    }
                }
            }
        }
예제 #18
0
 private static void RemovePaths(BlockManager bmDest, int[,] intArea, int intBlockStart)
 {
     for (int x = 0; x < intArea.GetLength(0); x++)
     {
         for (int z = 0; z < intArea.GetLength(1); z++)
         {
             if (intArea[x, z] == 1)
             {
                 bmDest.SetID(intBlockStart + x, 63, intBlockStart + z, BlockType.GRASS);
             }
         }
     }
 }
예제 #19
0
        private static void MakeStreetLights(BlockManager bm, int intMapLength, int intFarmLength)
        {
            StreetLights slCurrent;
            if (RandomHelper.NextDouble() > 0.5)
            {
                slCurrent = StreetLights.Glowstone;
            }
            else
            {
                slCurrent = StreetLights.Torches;
            }
            for (int a = 2; a <= (intMapLength / 2) - (intFarmLength + 16); a += 8)
            {
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) - a, (intMapLength / 2) - 2,
                                               (intMapLength / 2) - a, (intMapLength / 2) - 1);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) - a, (intMapLength / 2) + 2,
                                               (intMapLength / 2) - a, (intMapLength / 2) + 1);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) + a, (intMapLength / 2) - 2,
                                               (intMapLength / 2) + a, (intMapLength / 2) - 1);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) + a, (intMapLength / 2) + 2,
                                               (intMapLength / 2) + a, (intMapLength / 2) + 1);

                MakeStreetLight(bm, slCurrent, (intMapLength / 2) - 2, (intMapLength / 2) - a,
                                               (intMapLength / 2) - 1, (intMapLength / 2) - a);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) + 2, (intMapLength / 2) - a,
                                               (intMapLength / 2) + 1, (intMapLength / 2) - a);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) - 2, (intMapLength / 2) + a,
                                               (intMapLength / 2) - 1, (intMapLength / 2) + a);
                MakeStreetLight(bm, slCurrent, (intMapLength / 2) + 2, (intMapLength / 2) + a,
                                               (intMapLength / 2) + 1, (intMapLength / 2) + a);
            }
        }
예제 #20
0
 private static void MakeStreetLight(BlockManager bm, StreetLights slCurrent, int x1, int z1, int x2, int z2)
 {
     if (bm.GetID(x1, 63, z1) == BlockType.GRASS && bm.GetID(x1, 64, z1) == BlockType.AIR
         && bm.GetID(x1, 65, z1) == BlockType.AIR)
     {
         switch (slCurrent)
         {
             case StreetLights.Glowstone:
                 bm.SetID(x1, 64, z1, BlockType.FENCE);
                 bm.SetID(x1, 65, z1, BlockType.FENCE);
                 bm.SetID(x1, 66, z1, BlockType.FENCE);
                 bm.SetID(x1, 67, z1, BlockType.FENCE);
                 bm.SetID(x1, 68, z1, BlockType.FENCE);
                 bm.SetID(x2, 68, z2, BlockType.FENCE);
                 bm.SetID(x2, 67, z2, BlockType.GLOWSTONE_BLOCK);
                 break;
             case StreetLights.Torches:
                 bm.SetID(x1, 64, z1, BlockType.FENCE);
                 bm.SetID(x1, 65, z1, BlockType.FENCE);
                 bm.SetID(x1, 66, z1, BlockType.FENCE);
                 bm.SetID(x1, 67, z1, BlockType.FENCE);
                 bm.SetID(x1, 68, z1, BlockType.FENCE);
                 bm.SetID(x2, 68, z2, BlockType.FENCE);
                 bm.SetID(x2, 67, z2, BlockType.WOOD_PLANK);
                 if (z1 == z2)
                 {
                     BlockHelper.MakeTorch(x2, 67, z2 - 1, BlockType.WOOD_PLANK, 0);
                     BlockHelper.MakeTorch(x2, 67, z2 + 1, BlockType.WOOD_PLANK, 0);
                 }
                 else
                 {
                     BlockHelper.MakeTorch(x2 - 1, 67, z2, BlockType.WOOD_PLANK, 0);
                     BlockHelper.MakeTorch(x2 + 1, 67, z2, BlockType.WOOD_PLANK, 0);
                 }
                 break;
         }
     }
 }
예제 #21
0
 private static void MakeFlowers(BlockManager bmDest, BetaWorld worldDest, int intFarmLength, int intMapLength)
 {
     int intFlowers = 0;
     for (int x = intFarmLength + 11; x <= intMapLength - (intFarmLength + 11); x++)
     {
         for (int z = intFarmLength + 11; z <= intMapLength - (intFarmLength + 11); z++)
         {
             if (bmDest.GetID(x, 63, z) == BlockType.GRASS &&
                 bmDest.GetID(x, 64, z) == BlockType.AIR)
             {
                 bool booFree = true;
                 int intFree = 0;
                 for (int xCheck = x - 1; xCheck <= x + 1 && booFree; xCheck++)
                 {
                     for (int zCheck = z - 1; zCheck <= z + 1 && booFree; zCheck++)
                     {
                         if (bmDest.GetID(xCheck, 63, zCheck) == BlockType.GRASS &&
                             bmDest.GetID(xCheck, 64, zCheck) == BlockType.AIR)
                         {
                             intFree++;
                         }
                     }
                 }
                 if (intFree >= MinimumFreeNeighboursNeededForFlowers &&
                     RandomHelper.NextDouble() <= FlowerChance)
                 {
                     AddFlowersToBlock(bmDest, x, z);
                     if (++intFlowers >= NumberOfFlowersBetweenSaves)
                     {
                         worldDest.Save();
                         intFlowers = 0;
                     }
                 }
             }
         }
     }
 }
예제 #22
0
        private static void MakePond(BlockManager bm, int x, int xlen, int z, int zlen, bool booSmallPond)
        {
            int[,] intArea = new int[xlen, zlen];
            int a, b;

            int c = 0, d = 0, clen = -1, dlen = -1;
            if (!booSmallPond)
            {
                c = RandomHelper.Next(1, intArea.GetUpperBound(0) - 7);
                d = RandomHelper.Next(1, intArea.GetUpperBound(1) - 7);
                clen = RandomHelper.Next(3, 7);
                dlen = RandomHelper.Next(3, 7);
            }

            for (a = 1; a <= intArea.GetUpperBound(0) - 1; a++)
            {
                for (b = 1; b <= intArea.GetUpperBound(1) - 1; b++)
                {
                    if (a < c || a > c + clen || b < d || b > d + dlen)
                    {
                        intArea[a, b] = 1;
                    }
                }
            }

            intArea = CheckAgainstNeighbours(intArea, 0, 0, 7, 0, RandomHelper.Next(3, 6), true);
            intArea = CheckAgainstNeighbours(intArea, 6, 0, 2, 2, 1, false);
            intArea = CheckAgainstNeighbours(intArea, 14, 0, 3, 3, 1, false);

            bool booLava = (!booSmallPond && RandomHelper.NextDouble() < 0.15);

            for (a = 1; a <= intArea.GetUpperBound(0) - 1; a++)
            {
                for (b = 1; b <= intArea.GetUpperBound(1) - 1; b++)
                {
                    if (intArea[a, b] == 1)
                    {
                        bm.SetID(x + a, 64, z + b, BlockType.TALL_GRASS);
                        bm.SetData(x + a, 64, z + b, RandomHelper.Next(1, 3));
                    }
                    else
                    {
                        for (int y = 2; y <= intArea[a, b]; y++)
                        {
                            if (booLava)
                            {
                                bm.SetID(x + a, 65 - y, z + b, BlockType.STATIONARY_LAVA);
                            }
                            else
                            {
                                bm.SetID(x + a, 65 - y, z + b, BlockType.STATIONARY_WATER);
                            }
                        }
                    }
                }
            }
        }
예제 #23
0
 private static void MakeHelperChest(BlockManager bm, int x, int y, int z)
 {
     TileEntityChest tec = new TileEntityChest();
     tec.Items[0] = BlockHelper.MakeItem(ItemInfo.DiamondSword.ID, 1);
     tec.Items[1] = BlockHelper.MakeItem(ItemInfo.DiamondPickaxe.ID, 1);
     tec.Items[2] = BlockHelper.MakeItem(ItemInfo.DiamondShovel.ID, 1);
     tec.Items[3] = BlockHelper.MakeItem(ItemInfo.DiamondAxe.ID, 1);
     tec.Items[4] = BlockHelper.MakeItem(BlockType.LADDER, 64);
     tec.Items[5] = BlockHelper.MakeItem(BlockType.DIRT, 64);
     tec.Items[6] = BlockHelper.MakeItem(BlockType.SAND, 64);
     tec.Items[7] = BlockHelper.MakeItem(BlockType.CRAFTING_TABLE, 64);
     tec.Items[8] = BlockHelper.MakeItem(BlockType.FURNACE, 64);
     tec.Items[9] = BlockHelper.MakeItem(ItemInfo.Bread.ID, 64);
     tec.Items[10] = BlockHelper.MakeItem(BlockType.TORCH, 64);
     tec.Items[11] = BlockHelper.MakeItem(BlockType.STONE, 64);
     tec.Items[12] = BlockHelper.MakeItem(BlockType.CHEST, 64);
     tec.Items[13] = BlockHelper.MakeItem(BlockType.GLASS, 64);
     tec.Items[14] = BlockHelper.MakeItem(BlockType.WOOD, 64);
     tec.Items[15] = BlockHelper.MakeItem(ItemInfo.Cookie.ID, 64);
     tec.Items[16] = BlockHelper.MakeItem(ItemInfo.RedstoneDust.ID, 64);
     tec.Items[17] = BlockHelper.MakeItem(BlockType.IRON_BLOCK, 64);
     tec.Items[18] = BlockHelper.MakeItem(BlockType.DIAMOND_BLOCK, 64);
     tec.Items[19] = BlockHelper.MakeItem(BlockType.GOLD_BLOCK, 64);
     bm.SetID(x, y, z, BlockType.CHEST);
     bm.SetTileEntity(x, y, z, tec);
 }
예제 #24
0
 private static void AddBuilding(BlockManager bm, int intFarmLength, int intMapLength, int intBuildingID)
 {
     bool booAddedBuilding = false;
     SourceWorld.Building bldInsert = SourceWorld.GetBuilding(intBuildingID);
     int intLen = bldInsert.intSizeX;
     bool booValid;
     do
     {
         booValid = false;
         int x1 = RandomHelper.Next(2, intMapLength - (2 + intLen));
         int z1 = RandomHelper.Next(2, intMapLength - (2 + intLen));
         if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
               x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
         {
             booValid = true;
             for (int x = x1 - 2; x <= x1 + intLen + 2 && booValid; x++)
             {
                 for (int z = z1 - 2; z <= z1 + intLen + 2 && booValid; z++)
                 {
                     // make sure it doesn't overlap with the spawn point or another farm
                     if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                         bm.GetID(x, 63, z) != BlockType.GRASS ||
                         bm.GetID(x, 64, z) != BlockType.AIR ||
                         bm.GetID(x, 53, z) == BlockType.AIR)
                     {
                         booValid = false;
                     }
                 }
             }
         }
         if (booValid)
         {
             SourceWorld.InsertBuilding(bm, new int[intMapLength, intMapLength], 0, x1, z1, bldInsert, 0);
             booAddedBuilding = true;
         }
     } while (!booAddedBuilding);
 }
예제 #25
0
        private void OpenDimension(int dim)
        {
            string path = Path;
            if (dim == Dimension.DEFAULT) {
                path = IO.Path.Combine(path, _REGION_DIR);
            }
            else {
                path = IO.Path.Combine(path, "DIM" + dim);
                path = IO.Path.Combine(path, _REGION_DIR);
            }

            if (!Directory.Exists(path)) {
                Directory.CreateDirectory(path);
            }

            ChunkCache cc = new ChunkCache();

            RegionManager rm = new RegionManager(path, cc);
            BetaChunkManager cm = new BetaChunkManager(rm, cc);
            BlockManager bm = new BlockManager(cm);

            _regionMgrs[dim] = rm;
            _chunkMgrs[dim] = cm;
            _blockMgrs[dim] = bm;
        }
예제 #26
0
 private static void AddBuildings(BlockManager bm, int intFarmLength, int intMapLength)
 {
     SourceWorld.Building CurrentBuilding;
     List<int> lstAllFarmingBuildings = new List<int>();
     int intBuildings = 0;
     do
     {
         do
         {
             CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.Farming, 0);
         } while (lstAllFarmingBuildings.Contains(CurrentBuilding.intID));
         AddBuilding(bm, intFarmLength, intMapLength, CurrentBuilding.intID);
         if (CurrentBuilding.booUnique)
         {
             lstAllFarmingBuildings.Add(CurrentBuilding.intID);
         }
     } while (++intBuildings < Math.Max(1, (intMapLength / 16) / 2));
 }
예제 #27
0
        public void LinkRooms (BlockManager bm, int x1, int y1, int z1, int x2, int y2, int z2)
        {
            int xx = originx + (cellxlen + wallxwidth) * x1;
            int yy = originy + (cellylen + wallywidth) * y1;
            int zz = originz + (cellzlen + wallzwidth) * z1;

            if (x1 != x2) {
                xx = originx + (cellxlen + wallxwidth) * Math.Max(x1, x2);
                for (int xi = 0; xi < wallxwidth; xi++) {
                    int zc = zz + wallzwidth + (cellzlen / 2);
                    int yb = yy + wallywidth;
                    bm.SetID(xx + xi, yb, zc - 1, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb, zc, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb, zc + 1, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb + 1, zc - 1, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb + 1, zc, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb + 1, zc + 1, (int)BlockType.AIR);
                    bm.SetID(xx + xi, yb + 2, zc, (int)BlockType.AIR);
                }
            }
            else if (z1 != z2) {
                zz = originz + (cellzlen + wallzwidth) * Math.Max(z1, z2);
                for (int zi = 0; zi < wallxwidth; zi++) {
                    int xc = xx + wallxwidth + (cellxlen / 2);
                    int yb = yy + wallywidth;
                    bm.SetID(xc - 1, yb, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc, yb, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc + 1, yb, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc - 1, yb + 1, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc, yb + 1, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc + 1, yb + 1, zz + zi, (int)BlockType.AIR);
                    bm.SetID(xc, yb + 2, zz + zi, (int)BlockType.AIR);
                }
            }
            else if (y1 != y2) {
                yy = originy + (cellylen + wallywidth) * Math.Max(y1, y2);
                for (int yi = 0 - cellylen + 1; yi < wallywidth + 1; yi++) {
                    int xc = xx + wallxwidth + (cellxlen / 2);
                    int zc = zz + wallzwidth + (cellzlen / 2);

                    bm.SetID(xc, yy + yi, zc, (int)BlockType.BEDROCK);
                    bm.SetID(xc - 1, yy + yi, zc, (int)BlockType.LADDER);
                    bm.SetData(xc - 1, yy + yi, zc, 4);
                    bm.SetID(xc + 1, yy + yi, zc, (int)BlockType.LADDER);
                    bm.SetData(xc + 1, yy + yi, zc, 5);
                    bm.SetID(xc, yy + yi, zc - 1, (int)BlockType.LADDER);
                    bm.SetData(xc, yy + yi, zc - 1, 2);
                    bm.SetID(xc, yy + yi, zc + 1, (int)BlockType.LADDER);
                    bm.SetData(xc, yy + yi, zc + 1, 3);
                }
            }
        }
예제 #28
0
 /// <summary>
 /// Make a square ring 
 /// </summary>
 /// <param name="bm">the BlockManger for the world</param>
 /// <param name="posX">the X coordinate of the ring's center</param>
 /// <param name="posY">the Y coordinate of the ring's center</param>
 /// <param name="posZ">the Z coordinate of the ring's center</param>
 /// <param name="rad">the radius of the ring, measured in blocks beyond the center point</param>
 private static void MakeRing(BlockManager bm, Int32 posX, Int32 posY, Int32 posZ, Int32 rad)
 {
     //left and right edges of box
     for (int xi = posX - rad; xi <= posX + rad; xi++)
     {
         MakeOpenSurface(bm, xi, posY, posZ - rad);
         MakeOpenSurface(bm, xi, posY, posZ + rad);
     }
     //top and left edges of box, shorter because corners are already set
     for (int zi = posZ - rad + 1; zi < posZ + rad; zi++)
     {
         MakeOpenSurface(bm, posX - rad, posY, zi);
         MakeOpenSurface(bm, posX + rad, posY, zi);
     }
 }
예제 #29
0
 public void BuildInit (BlockManager bm)
 {
     for (int xi = 0; xi < xlen; xi++) {
         for (int yi = 0; yi < ylen; yi++) {
             for (int zi = 0; zi < zlen; zi++) {
                 BuildRoom(bm, xi, yi, zi);
             }
         }
     }
 }
예제 #30
0
 private static void JoinPathsToRoad(BlockManager bmDest, int intMapLength, int intFarmLength)
 {
     int intBlockStart = intFarmLength + 13;
     int intPlotBlocksLength = (1 + intMapLength) - (intBlockStart * 2);
     for (int a = 0; a <= intPlotBlocksLength; a++)
     {
         for (int b = -2; b <= 2; b+=4)
         {
             if (bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + (int)(b * 1.5)) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + (int)(b / 2)) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + b) == BlockType.GRASS &&
                 bmDest.GetID(intBlockStart + a, 64, intBlockStart + (intPlotBlocksLength / 2) + b) == BlockType.AIR)
             {
                 bmDest.SetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + b, BlockType.DOUBLE_SLAB);
             }
             if (bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + (int)(b * 1.5), 63, intBlockStart + a) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + (int)(b / 2), 63, intBlockStart + a) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + b, 63, intBlockStart + a) == BlockType.GRASS &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + b, 64, intBlockStart + a) == BlockType.AIR)
             {
                 bmDest.SetID(intBlockStart + (intPlotBlocksLength / 2) + b, 63, intBlockStart + a, BlockType.DOUBLE_SLAB);
             }
         }
     }
 }