Ejemplo n.º 1
0
        private static int[,] FillArea(int[,] intArea, int intSizeX, int intSizeZ, int intStartX, int intStartZ, bool booUniqueBonus)
        {
            int[,] intDistrict = new int[intSizeX, intSizeZ];
            int[,] intFinal    = new int[intSizeX, intSizeZ];
            int        intWasted = intSizeX * intSizeZ, intAttempts = 15, intFail = 0;
            int        intBonus              = 0;
            List <int> lstBuildings          = new List <int>();
            List <int> lstAcceptedBuildings  = new List <int>();
            bool       booAreaNeedsMineshaft = false;

            do
            {
                lstBuildings.Clear();
                intBonus = 0;
                if (!_booIncludedMineshaft)
                {
                    booAreaNeedsMineshaft = true;
                }
                do
                {
                    SourceWorld.Building CurrentBuilding;
                    if (booAreaNeedsMineshaft)
                    {
                        CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.MineshaftEntrance, 0);
                        // mineshaft is always the first building, so therefore it will always be possible to place it
                        booAreaNeedsMineshaft = false;
                    }
                    else
                    {
                        do
                        {
                            CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.City, 0);
                        } while (!IsValidBuilding(CurrentBuilding, lstBuildings, intArea,
                                                  intStartX, intStartZ, intSizeX, intSizeZ));
                    }
                    bool booFound = false;
                    if (RNG.NextDouble() > 0.5)
                    {
                        intDistrict = intDistrict.RotateArray(RNG.Next(4));
                    }
                    int x, z = 0;
                    for (x = 0; x < intDistrict.GetLength(0) - CurrentBuilding.intSizeX && !booFound; x++)
                    {
                        for (z = 0; z < intDistrict.GetLength(1) - CurrentBuilding.intSizeZ && !booFound; z++)
                        {
                            booFound = intDistrict.IsArraySectionAllZeros2D(x, z, x + CurrentBuilding.intSizeX, z + CurrentBuilding.intSizeZ);
                        }
                    }
                    x--;
                    z--;
                    if (booFound)
                    {
                        for (int a = x + 1; a <= x + CurrentBuilding.intSizeX - 1; a++)
                        {
                            for (int b = z + 1; b <= z + CurrentBuilding.intSizeZ - 1; b++)
                            {
                                intDistrict[a, b] = 2;
                            }
                        }
                        if (CurrentBuilding.booUnique && booUniqueBonus)
                        {
                            // we want to include the unique buildings,
                            //   so we give a slight preference to those

                            intBonus += 15;
                        }
                        lstBuildings.Add(CurrentBuilding.intID);
                        intDistrict[x + 1, z + 1] = 100 + CurrentBuilding.intID;
                        intDistrict[x + CurrentBuilding.intSizeX - 1,
                                    z + CurrentBuilding.intSizeZ - 1] = 100 + CurrentBuilding.intID;
                        intFail = 0;
                    }
                    else
                    {
                        intFail++;
                    }
                } while (intFail < 10);

                int intCurWasted = Utils.ZerosInArray2D(intDistrict) - intBonus;
                if (intCurWasted < intWasted)
                {
                    intFinal = new int[intDistrict.GetLength(0), intDistrict.GetLength(1)];
                    Array.Copy(intDistrict, intFinal, intDistrict.Length);
                    intWasted   = intCurWasted;
                    intAttempts = 10;
                    lstAcceptedBuildings.Clear();
                    lstAcceptedBuildings.AddRange(lstBuildings);
                }
                Array.Clear(intDistrict, 0, intDistrict.Length);
                intAttempts--;
            } while (intAttempts > 0);
            if (intSizeX == intFinal.GetLength(1))
            {
                intFinal = intFinal.RotateArray(1);
            }
            _lstAllBuildings.AddRange(lstAcceptedBuildings);
            _booIncludedMineshaft = true;
            return(intFinal);
        }
Ejemplo n.º 2
0
        private static bool IsValidBuilding(SourceWorld.Building bldCheck, List <int> lstBuildings, int[,] intArea,
                                            int intStartX, int intStartZ, int intSizeX, int intSizeZ)
        {
            if (bldCheck.booUnique)
            {
                if (_lstAllBuildings.Contains(bldCheck.intID) || lstBuildings.Contains(bldCheck.intID))
                {
                    return(false);
                }
                else
                {
                    foreach (int intID in lstBuildings)
                    {
                        if (SourceWorld.GetBuilding(intID).booUnique)
                        {
                            return(false);
                        }
                    }
                    for (int x = intStartX - 8; x < intStartX + intSizeX + 8; x++)
                    {
                        for (int z = intStartZ - 8; z < intStartZ + intSizeZ + 8; z++)
                        {
                            if (x >= 0 && z >= 0 && x <= intArea.GetUpperBound(0) && z <= intArea.GetUpperBound(1))
                            {
                                if (intArea[x, z] >= 100)
                                {
                                    if (SourceWorld.GetBuilding(intArea[x, z] - 100).booUnique)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
            else
            {
                switch (bldCheck.strFrequency)
                {
                case "very common":
                case "common":
                    return(true);

                case "average":
                case "rare":
                case "very rare":
                    // this exists to avoid infite loops
                    if (RNG.NextDouble() > 0.975)
                    {
                        return(true);
                    }
                    if (lstBuildings.Contains(bldCheck.intID))
                    {
                        return(false);
                    }
                    else
                    {
                        int intDistance = 0;
                        switch (bldCheck.strFrequency)
                        {
                        case "average":
                            intDistance = 12;
                            break;

                        case "rare":
                            intDistance = 25;
                            break;

                        case "very rare":
                            intDistance = 50;
                            break;
                        }
                        for (int x = intStartX - intDistance; x < intStartX + intSizeX + intDistance; x++)
                        {
                            for (int z = intStartZ - intDistance; z < intStartZ + intSizeZ + intDistance; z++)
                            {
                                if (x >= 0 && z >= 0 && x <= intArea.GetUpperBound(0) && z <= intArea.GetUpperBound(1))
                                {
                                    if (intArea[x, z] - 100 == bldCheck.intID)
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                        return(true);
                    }

                // should never get here to either of these, but just in case
                case "exclude":
                    Debug.WriteLine("Excluded buildings are not allowed here");
                    return(false);

                default:
                    Debug.WriteLine("Unknown frequency type encountered");
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
        // this is a simplified version of the FillArea method from Paths.cs
        private static int[,] FillArea(int intSizeX, int intSizeZ)
        {
            int[,] intDistrict = new int[intSizeX, intSizeZ];
            int[,] intFinal    = new int[intSizeX, intSizeZ];
            int        intWasted = intSizeX * intSizeZ, intAttempts = 15, intFail = 0;
            int        intBonus     = 0;
            List <int> lstBuildings = new List <int>();

            do
            {
                lstBuildings.Clear();
                intBonus = 0;
                do
                {
                    SourceWorld.Building CurrentBuilding;
                    do
                    {
                        CurrentBuilding = SourceWorld.SelectRandomBuilding(SourceWorld.BuildingTypes.Farming, 0);
                    } while (!IsValidBuilding(CurrentBuilding, lstBuildings));
                    bool booFound = false;
                    if (RNG.NextDouble() > 0.5)
                    {
                        intDistrict = intDistrict.RotateArray(RNG.Next(4));
                    }
                    int x, z = 0;
                    for (x = 0; x < intDistrict.GetLength(0) - CurrentBuilding.intSizeX && !booFound; x++)
                    {
                        for (z = 0; z < intDistrict.GetLength(1) - CurrentBuilding.intSizeZ && !booFound; z++)
                        {
                            booFound = intDistrict.IsArraySectionAllZeros2D(x, z, x + CurrentBuilding.intSizeX, z + CurrentBuilding.intSizeZ);
                        }
                    }
                    x--;
                    z--;
                    if (booFound)
                    {
                        for (int a = x + 1; a <= x + CurrentBuilding.intSizeX - 1; a++)
                        {
                            for (int b = z + 1; b <= z + CurrentBuilding.intSizeZ - 1; b++)
                            {
                                intDistrict[a, b] = 2;
                            }
                        }
                        if (CurrentBuilding.booUnique)
                        {
                            intBonus += 15;
                        }
                        lstBuildings.Add(CurrentBuilding.intID);
                        intDistrict[x + 1, z + 1] = 100 + CurrentBuilding.intID;
                        intDistrict[x + CurrentBuilding.intSizeX - 1, z + CurrentBuilding.intSizeZ - 1] = 100 + CurrentBuilding.intID;
                        intFail = 0;
                    }
                    else
                    {
                        intFail++;
                    }
                } while (intFail < 10);

                int intCurWasted = Utils.ZerosInArray2D(intDistrict) - intBonus;
                if (intCurWasted < intWasted)
                {
                    intFinal = new int[intDistrict.GetLength(0), intDistrict.GetLength(1)];
                    Array.Copy(intDistrict, intFinal, intDistrict.Length);
                    intWasted   = intCurWasted;
                    intAttempts = 10;
                }
                Array.Clear(intDistrict, 0, intDistrict.Length);
                intAttempts--;
            } while (intAttempts > 0);
            if (intSizeX == intFinal.GetLength(1))
            {
                intFinal = intFinal.RotateArray(1);
            }
            return(intFinal);
        }
Ejemplo n.º 4
0
        public static void MakeGuardTowers(BlockManager bm, frmMace frmLogForm)
        {
            // remove wall
            BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 11, 64, 79,
                                     City.EdgeLength + 5, City.EdgeLength + 11, BlockInfo.Air.ID, 1);
            // add tower
            BlockShapes.MakeHollowBox(City.EdgeLength + 4, City.EdgeLength + 12, 63, 80,
                                      City.EdgeLength + 4, City.EdgeLength + 12, City.WallMaterialID, 1, City.WallMaterialData);
            // divide into two rooms
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 4, City.EdgeLength + 12, 2, 72,
                                             City.EdgeLength + 4, City.EdgeLength + 12,
                                             City.WallMaterialID, 1, City.WallMaterialData);
            BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 11, 64, 67,
                                     City.EdgeLength + 5, City.EdgeLength + 11, BlockInfo.Air.ID, 1);

            switch (City.OutsideLightType)
            {
            case "Fire":
                BlockShapes.MakeBlock(City.EdgeLength + 5, 76, City.EdgeLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1);
                BlockShapes.MakeBlock(City.EdgeLength + 5, 77, City.EdgeLength + 3, BlockInfo.Fire.ID, 2, 100, -1);
                BlockShapes.MakeBlock(City.EdgeLength + 11, 76, City.EdgeLength + 3, BlockInfo.Netherrack.ID, 2, 100, -1);
                BlockShapes.MakeBlock(City.EdgeLength + 11, 77, City.EdgeLength + 3, BlockInfo.Fire.ID, 2, 100, -1);
                break;

            case "Torches":
                for (int y = 73; y <= 80; y += 7)
                {
                    BlockHelper.MakeTorch(City.EdgeLength + 6, y, City.EdgeLength + 3, City.WallMaterialID, 2);
                    BlockHelper.MakeTorch(City.EdgeLength + 10, y, City.EdgeLength + 3, City.WallMaterialID, 2);
                }
                break;

            case "None":
            case "":
                break;

            default:
                Debug.Fail("Invalid switch result");
                break;
            }
            if (City.HasTorchesOnWalkways)
            {
                // add torches
                BlockHelper.MakeTorch(City.EdgeLength + 6, 79, City.EdgeLength + 13, City.WallMaterialID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 10, 79, City.EdgeLength + 13, City.WallMaterialID, 2);
                // add torches inside
                BlockHelper.MakeTorch(City.EdgeLength + 6, 77, City.EdgeLength + 11, City.WallMaterialID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 10, 77, City.EdgeLength + 11, City.WallMaterialID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 5, 77, City.EdgeLength + 6, City.WallMaterialID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 5, 77, City.EdgeLength + 10, City.WallMaterialID, 2);
            }
            // add openings to the walls
            BlockShapes.MakeBlock(City.EdgeLength + 7, 73, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 9, 73, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 7, 74, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 9, 74, City.EdgeLength + 12, BlockInfo.Air.ID, 2, 100, -1);
            // add blocks on top of the towers
            BlockShapes.MakeHollowLayers(City.EdgeLength + 4, City.EdgeLength + 12, 81, 81,
                                         City.EdgeLength + 4, City.EdgeLength + 12,
                                         City.WallMaterialID, 1, City.WallMaterialData);

            // alternating top blocks
            for (int x = City.EdgeLength + 4; x <= City.EdgeLength + 12; x += 2)
            {
                for (int z = City.EdgeLength + 4; z <= City.EdgeLength + 12; z += 2)
                {
                    if (x == City.EdgeLength + 4 ||
                        x == City.EdgeLength + 12 ||
                        z == City.EdgeLength + 4 ||
                        z == City.EdgeLength + 12)
                    {
                        BlockShapes.MakeBlock(x, 82, z, City.WallMaterialID, 1, 100, City.WallMaterialData);
                    }
                }
            }
            // add central columns
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 8, City.EdgeLength + 8, 73, 82,
                                             City.EdgeLength + 8, City.EdgeLength + 8, City.WallMaterialID, 1,
                                             City.WallMaterialData);
            BlockHelper.MakeLadder(City.EdgeLength + 7, 73, 82, City.EdgeLength + 8, 2, City.WallMaterialID);
            BlockHelper.MakeLadder(City.EdgeLength + 9, 73, 82, City.EdgeLength + 8, 2, City.WallMaterialID);
            // add torches on the roof
            if (City.HasTorchesOnWalkways)
            {
                BlockShapes.MakeBlock(City.EdgeLength + 6, 81, City.EdgeLength + 6, BlockInfo.Torch.ID, 1, 100, -1);
                BlockShapes.MakeBlock(City.EdgeLength + 6, 81, City.EdgeLength + 10, BlockInfo.Torch.ID, 2, 100, -1);
                BlockShapes.MakeBlock(City.EdgeLength + 10, 81, City.EdgeLength + 10, BlockInfo.Torch.ID, 1, 100, -1);
            }
            // add cobwebs
            BlockShapes.MakeBlock(City.EdgeLength + 5, 79, City.EdgeLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 5, 79, City.EdgeLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 79, City.EdgeLength + 5, BlockInfo.Cobweb.ID, 1, 30, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 79, City.EdgeLength + 11, BlockInfo.Cobweb.ID, 1, 30, -1);

            // add chests
            MakeGuardChest(bm, City.EdgeLength + 11, 73, City.EdgeLength + 11);
            MakeGuardChest(bm, City.MapLength - (City.EdgeLength + 11), 73, City.EdgeLength + 11);
            MakeGuardChest(bm, City.EdgeLength + 11, 73, City.MapLength - (City.EdgeLength + 11));
            MakeGuardChest(bm, City.MapLength - (City.EdgeLength + 11), 73, City.MapLength - (City.EdgeLength + 11));

            // add archery slots
            BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 74, 77,
                                     City.EdgeLength + 8, City.EdgeLength + 8, BlockInfo.Air.ID, 2);
            BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 76, 76,
                                     City.EdgeLength + 7, City.EdgeLength + 9, BlockInfo.Air.ID, 2);
            if (!City.HasWalls)
            {
                BlockHelper.MakeLadder(City.EdgeLength + 13, 64, 72, City.EdgeLength + 8, 2, City.WallMaterialID);
            }
            // include beds
            BlockHelper.MakeBed(City.EdgeLength + 5, City.EdgeLength + 6, 64, City.EdgeLength + 8, City.EdgeLength + 8, 2);
            BlockHelper.MakeBed(City.EdgeLength + 5, City.EdgeLength + 6, 64, City.EdgeLength + 10, City.EdgeLength + 10, 2);
            BlockHelper.MakeBed(City.EdgeLength + 11, City.EdgeLength + 10, 64, City.EdgeLength + 8, City.EdgeLength + 8, 2);
            // make columns to orientate torches
            BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 5, 64, 73,
                                     City.EdgeLength + 5, City.EdgeLength + 5, BlockInfo.Wood.ID, 2);
            BlockShapes.MakeSolidBox(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71,
                                     City.EdgeLength + 5, City.EdgeLength + 5, BlockInfo.Wood.ID, 2);
            BlockShapes.MakeSolidBox(City.EdgeLength + 5, City.EdgeLength + 5, 64, 71,
                                     City.EdgeLength + 11, City.EdgeLength + 11, BlockInfo.Wood.ID, 2);
            BlockShapes.MakeSolidBox(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71,
                                     City.EdgeLength + 11, City.EdgeLength + 11, BlockInfo.Wood.ID, 2);
            // add ladders
            BlockHelper.MakeLadder(City.EdgeLength + 5, 64, 73, City.EdgeLength + 6, 2, BlockInfo.Wood.ID);
            // make torches
            if (City.HasTorchesOnWalkways)
            {
                BlockHelper.MakeTorch(City.EdgeLength + 10, 66, City.EdgeLength + 5, BlockInfo.Wood.ID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 6, 66, City.EdgeLength + 11, BlockInfo.Wood.ID, 2);
                BlockHelper.MakeTorch(City.EdgeLength + 10, 66, City.EdgeLength + 11, BlockInfo.Wood.ID, 2);
            }
            // make columns for real
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 5, City.EdgeLength + 5, 64, 73, City.EdgeLength + 5,
                                             City.EdgeLength + 5, City.WallMaterialID, 2, City.WallMaterialData);
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 5,
                                             City.EdgeLength + 5, City.WallMaterialID, 2, City.WallMaterialData);
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 5, City.EdgeLength + 5, 64, 71, City.EdgeLength + 11,
                                             City.EdgeLength + 11, City.WallMaterialID, 2, City.WallMaterialData);
            BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 11, City.EdgeLength + 11, 64, 71, City.EdgeLength + 11,
                                             City.EdgeLength + 11, City.WallMaterialID, 2, City.WallMaterialData);
            // make cobwebs
            BlockShapes.MakeBlock(City.EdgeLength + 11, 67, City.EdgeLength + 8, BlockInfo.Cobweb.ID, 2, 75, -1);
            // make doors from the city to the guard tower
            BlockShapes.MakeBlock(City.EdgeLength + 11, 65, City.EdgeLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.GoldBlock.ID, 1, 100, -1);
            BlockHelper.MakeDoor(City.EdgeLength + 11, 64, City.EdgeLength + 12, BlockInfo.GoldBlock.ID, true, 2);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 65, City.EdgeLength + 11, BlockInfo.Air.ID, 1, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.Air.ID, 1, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 11, BlockInfo.StonePlate.ID, 1, 100, -1);
            BlockShapes.MakeBlock(City.EdgeLength + 11, 64, City.EdgeLength + 13, BlockInfo.StonePlate.ID, 2, 100, -1);
            //BlockShapes.MakeBlock(City.intFarmSize + 13, 64, City.intFarmSize + 11, BlockInfo.Stone.ID_PLATE, 1, 100, -1);
            // add guard tower sign
            BlockHelper.MakeSign(City.EdgeLength + 12, 65, City.EdgeLength + 13, "~Guard Tower~~", City.WallMaterialID, 1);
            BlockHelper.MakeSign(City.EdgeLength + 8, 74, City.EdgeLength + 13, "~Guard Tower~~", City.WallMaterialID, 2);
            // make beacon
            frmLogForm.UpdateLog("Creating tower addition: " + City.TowersAdditionType, true, true);
            switch (City.TowersAdditionType)
            {
            case "Fire beacon":
                BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 8, City.EdgeLength + 8, 83, 84,
                                                 City.EdgeLength + 8, City.EdgeLength + 8,
                                                 City.WallMaterialID, 1, City.WallMaterialData);
                BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 6, City.EdgeLength + 10, 85, 85,
                                                 City.EdgeLength + 6, City.EdgeLength + 10,
                                                 City.WallMaterialID, 1, City.WallMaterialData);
                BlockShapes.MakeSolidBox(City.EdgeLength + 6, City.EdgeLength + 10, 86, 86,
                                         City.EdgeLength + 6, City.EdgeLength + 10, BlockInfo.Netherrack.ID, 1);
                BlockShapes.MakeSolidBox(City.EdgeLength + 6, City.EdgeLength + 10, 87, 87,
                                         City.EdgeLength + 6, City.EdgeLength + 10, BlockInfo.Fire.ID, 1);
                break;

            case "Flag":
                BlockShapes.MakeSolidBox(City.EdgeLength + 4, City.EdgeLength + 4, 83, 91,
                                         City.EdgeLength + 12, City.EdgeLength + 12, BlockInfo.Fence.ID, 2);
                BlockShapes.MakeBlock(City.EdgeLength + 4, 84, City.EdgeLength + 13, BlockInfo.Fence.ID, 2, 100, 0);
                BlockShapes.MakeBlock(City.EdgeLength + 4, 91, City.EdgeLength + 13, BlockInfo.Fence.ID, 2, 100, 0);
                int[] intColours = RNG.ShuffleArray(Enumerable.Range(0, 15).ToArray());
                // select a random flag file and turn it into an array
                string[] strFlagLines = File.ReadAllLines(RNG.RandomItemFromArray(Directory.GetFiles("Resources", "Flag_*.txt")));
                for (int x = 0; x < strFlagLines[0].Length; x++)
                {
                    for (int y = 0; y < strFlagLines.GetLength(0); y++)
                    {
                        int WoolColourID = Convert.ToInt32(strFlagLines[y].Substring(x, 1));
                        BlockShapes.MakeSolidBoxWithData(City.EdgeLength + 4, City.EdgeLength + 4,
                                                         90 - y, 90 - y,
                                                         City.EdgeLength + 13 + x, City.EdgeLength + 13 + x,
                                                         BlockInfo.Wool.ID, 2, intColours[WoolColourID]);
                    }
                }
                break;
            }
        }
Ejemplo n.º 5
0
        private static void MakePond(BlockManager bm, int x, int xlen, int z, int zlen)
        {
            int[,] intArea = new int[xlen, zlen];
            int a, b;

            int c = 0, d = 0, clen = -1, dlen = -1;

            if (xlen >= 12 && zlen >= 12)
            {
                c    = RNG.Next(1, intArea.GetUpperBound(0) - 7);
                d    = RNG.Next(1, intArea.GetUpperBound(1) - 7);
                clen = RNG.Next(2, 4);
                dlen = RNG.Next(2, 4);
            }

            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, RNG.Next(3, 6), true);
            intArea = CheckAgainstNeighbours(intArea, 6, 0, 2, 2, 1, false);
            intArea = CheckAgainstNeighbours(intArea, 14, 0, 3, 3, 1, false);

            bool booLava = RNG.NextDouble() < 0.15;

            for (a = 1; a < intArea.GetUpperBound(0); a++)
            {
                for (b = 1; b < intArea.GetUpperBound(1); b++)
                {
                    if (intArea[a, b] == 1)
                    {
                        if (!booLava && RNG.NextDouble() < 0.05)
                        {
                            bm.SetID(x + a, 64, z + b, BlockInfo.SugarCane.ID);
                        }
                        else
                        {
                            bm.SetID(x + a, 64, z + b, BlockInfo.TallGrass.ID);
                            bm.SetData(x + a, 64, z + b, RNG.Next(1, 3));
                        }
                    }
                    else
                    {
                        for (int y = 2; y <= intArea[a, b]; y++)
                        {
                            if (booLava)
                            {
                                bm.SetID(x + a, 65 - y, z + b, BlockInfo.StationaryLava.ID);
                            }
                            else
                            {
                                bm.SetID(x + a, 65 - y, z + b, BlockInfo.StationaryWater.ID);
                                if (y == 2 && RNG.NextDouble() < 0.1)
                                {
                                    bm.SetID(x + a, 66 - y, z + b, BlockInfo.LillyPad.ID);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private static void MakeHill(BlockManager bm, int x, int xlen, int z, int zlen)
        {
            int[,] intArea = new int[xlen, zlen];
            int a, b;

            int c = 0, d = 0, clen = -1, dlen = -1;

            if (xlen >= 8 && zlen >= 8)
            {
                c    = RNG.Next(1, intArea.GetUpperBound(0) - 7);
                d    = RNG.Next(1, intArea.GetUpperBound(1) - 7);
                clen = RNG.Next(3, 5);
                dlen = RNG.Next(3, 5);
            }

            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, RNG.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); a++)
            {
                for (b = 1; b < intArea.GetUpperBound(1); b++)
                {
                    for (int y = 1; y <= intArea[a, b]; y++)
                    {
                        if (y == intArea[a, b])
                        {
                            bm.SetID(x + a, y + 63, z + b, BlockInfo.Grass.ID);
                            switch (RNG.Next(0, 10))
                            {
                            case 0:
                                bm.SetID(x + a, y + 64, z + b, BlockInfo.RedRose.ID);
                                break;

                            case 1:
                                bm.SetID(x + a, y + 64, z + b, BlockInfo.YellowFlower.ID);
                                break;

                            case 2:
                            case 3:
                                bm.SetID(x + a, y + 64, z + b, BlockInfo.TallGrass.ID);
                                bm.SetData(x + a, y + 64, z + b, RNG.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, BlockInfo.Dirt.ID);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private static void MakePaths(AnvilWorld world, BlockManager bm, int[,] intArea)
        {
            for (int x = 0; x < intArea.GetLength(0); x++)
            {
                for (int z = 0; z < intArea.GetLength(1); z++)
                {
                    if (intArea[x, z] == 1)
                    {
                        if (Math.Abs(x - (intArea.GetLength(0) / 2)) == City.pathExtends + 1 &&
                            Math.Abs(z - (intArea.GetLength(1) / 2)) == City.pathExtends + 1)
                        {
                            // don't need these
                        }
                        else if (Math.Abs(x - (intArea.GetLength(0) / 2)) == (City.pathExtends + 1) ||
                                 Math.Abs(z - (intArea.GetLength(1) / 2)) == (City.pathExtends + 1))
                        {
                            if (City.hasMainStreets && MultipleNeighbouringPaths(intArea, x, z))
                            {
                                bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.pathBlockID);
                                bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.pathBlockData);
                            }
                        }
                        else
                        {
                            bm.SetID(_intBlockStart + x, 63, _intBlockStart + z, City.pathBlockID);
                            bm.SetData(_intBlockStart + x, 63, _intBlockStart + z, City.pathBlockData);
                        }
                        if (City.hasMainStreets && City.pathAlternativeBlockID > 0)
                        {
                            if (x > 0 && z > 0 && x < intArea.GetUpperBound(0) && z < intArea.GetUpperBound(1))
                            {
                                if (Math.Abs(x - (intArea.GetLength(0) / 2)) == City.pathExtends ||
                                    Math.Abs(z - (intArea.GetLength(1) / 2)) == City.pathExtends)
                                {
                                    if (Math.Abs(x - (intArea.GetLength(0) / 2)) >= City.pathExtends &&
                                        Math.Abs(z - (intArea.GetLength(1) / 2)) >= City.pathExtends)
                                    {
                                        bm.SetID(_intBlockStart + x, 64, _intBlockStart + z, City.pathAlternativeBlockID);
                                        bm.SetData(_intBlockStart + x, 64, _intBlockStart + z, City.pathAlternativeBlockData);
                                    }
                                }
                            }
                        }
                    }
                }
                if (x % 20 == 0)
                {
                    world.Save();
                }
            }
            if (City.hasMainStreets)
            {
                for (int a = 0; a <= intArea.GetUpperBound(0); a++)
                {
                    if (a % 8 == 0)
                    {
                        switch (City.npcs)
                        {
                        case "Ghostdancer's NPCs":
                            EntityVillager eVillager = new EntityVillager(new TypedEntity("GPoor"));
                            switch (RNG.Next(2))
                            {
                            case 0:
                                eVillager = new EntityVillager(new TypedEntity("GPoor"));
                                break;

                            case 1:
                                eVillager = new EntityVillager(new TypedEntity("GRich"));
                                break;

                            case 2:
                                eVillager = new EntityVillager(new TypedEntity("GMaid"));
                                break;
                            }
                            eVillager.Health = 20;
                            BlockShapes.MakeEntity(_intBlockStart + a, 65, _intBlockStart + (intArea.GetUpperBound(0) / 2), eVillager, 0);
                            BlockShapes.MakeEntity(_intBlockStart + (intArea.GetUpperBound(0) / 2), 65, _intBlockStart + a, eVillager, 0);
                            break;

                        case "Minecraft Villagers":
                            EntityVillager eMob = new EntityVillager();
                            eMob.Health = 20;
                            BlockShapes.MakeEntity(_intBlockStart + a, 65, _intBlockStart + (intArea.GetUpperBound(0) / 2), eMob, 0);
                            BlockShapes.MakeEntity(_intBlockStart + (intArea.GetUpperBound(0) / 2), 65, _intBlockStart + a, eMob, 0);
                            break;
                        }
                    }
                    for (int c = -City.pathExtends; c <= City.pathExtends; c++)
                    {
                        intArea[a, (intArea.GetUpperBound(0) / 2) + c] = 1;
                        intArea[(intArea.GetUpperBound(0) / 2) + c, a] = 1;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private static void SplitArea(BlockManager bm, int[,] intArea, int x1, int z1, int x2, int z2)
        {
            for (int x = x1; x <= x2; x++)
            {
                for (int y = z1; y <= z2; y++)
                {
                    if (x == x1 || x == x2 || y == z1 || y == z2)
                    {
                        if (intArea[x, y] < 500)
                        {
                            intArea[x, y] = 1;
                        }
                    }
                }
            }
            bool booPossibleToSplit = true;
            bool booSplitByX        = false;

            if (Math.Abs(x1 - x2) > 50 && Math.Abs(z1 - z2) > 50)
            {
                booSplitByX = RNG.NextDouble() > 0.5;
            }
            else if (Math.Abs(x1 - x2) > 50)
            {
                booSplitByX = true;
            }
            else if (Math.Abs(z1 - z2) <= 50)
            {
                booPossibleToSplit = false;
            }
            if (City.hasPaths && booPossibleToSplit)
            {
                if (booSplitByX)
                {
                    int intSplitPoint = RNG.Next(x1 + 20, x2 - 20);
                    SplitArea(bm, intArea, x1, z1, intSplitPoint, z2);
                    SplitArea(bm, intArea, intSplitPoint, z1, x2, z2);
                    _intStreet++;
                    if (City.hasPaths)
                    {
                        MakeStreetSign(bm, intSplitPoint - 1, z1 + 1, intSplitPoint - 1, z2 - 1);
                    }
                }
                else
                {
                    int intSplitPoint = RNG.Next(z1 + 20, z2 - 20);
                    SplitArea(bm, intArea, x1, z1, x2, intSplitPoint);
                    SplitArea(bm, intArea, x1, intSplitPoint, x2, z2);
                    _intStreet++;
                    if (City.hasPaths)
                    {
                        MakeStreetSign(bm, x1 + 1, intSplitPoint - 1, x2 - 1, intSplitPoint - 1);
                    }
                }
            }
            else
            {
                structDistrict stdCurrent = new structDistrict();
                stdCurrent.x1 = x1;
                stdCurrent.x2 = x2;
                stdCurrent.z1 = z1;
                stdCurrent.z2 = z2;
                _lstDistricts.Add(stdCurrent);
            }
        }
Ejemplo n.º 9
0
        public static void MakeMoat(frmMace frmLogForm, BlockManager bm)
        {
            frmLogForm.UpdateLog("Moat type: " + City.moatType, true, true);
            switch (City.moatType)
            {
            case "Drop to Bedrock":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 2, 63, a,
                                                 City.mapLength - a, BlockInfo.Air.ID, 0, -1);
                }
                BlockShapes.MakeHollowLayers(City.edgeLength - 2, City.mapLength - (City.edgeLength - 2),
                                             64, 64,
                                             City.edgeLength - 2, City.mapLength - (City.edgeLength - 2), BlockInfo.Fence.ID, 0, -1);
                break;

            case "Cactus":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 63, 63, a,
                                                 City.mapLength - a, BlockInfo.Sand.ID, 0, -1);
                }
                for (int a = City.edgeLength + 1; a <= City.mapLength / 2; a += 2)
                {
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                }
                for (int a = City.edgeLength; a <= City.mapLength / 2; a += 2)
                {
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                }
                if (City.hasGuardTowers)
                {
                    for (int a = City.edgeLength + 3; a <= City.edgeLength + 13; a += 2)
                    {
                        BlockShapes.MakeBlock(a, 64, City.edgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 65, City.edgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                    }
                }
                break;

            case "Cactus Low":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 59, 63,
                                                 a, City.mapLength - a, BlockInfo.Air.ID, 0, -1);
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 58, 58,
                                                 a, City.mapLength - a, BlockInfo.Sand.ID, 0, -1);
                }
                for (int a = City.edgeLength + 1; a <= City.mapLength / 2; a += 2)
                {
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength + 1, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength + 1, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength + 3, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength + 3, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                }
                for (int a = City.edgeLength; a <= City.mapLength / 2; a += 2)
                {
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength + 2, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength + 2, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                    if (RNG.NextDouble() > 0.5)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength + 4, BlockInfo.Cactus.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength + 4, BlockInfo.Cactus.ID, 2, 50, -1);
                    }
                }
                if (City.hasGuardTowers)
                {
                    for (int a = City.edgeLength + 3; a <= City.edgeLength + 13; a += 2)
                    {
                        BlockShapes.MakeBlock(a, 59, City.edgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                        BlockShapes.MakeBlock(a, 60, City.edgeLength + 3, BlockInfo.Air.ID, 2, 100, -1);
                    }
                }
                break;

            case "Lava":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 55, 56,
                                                 a, City.mapLength - a, BlockInfo.Lava.ID, 0, -1);
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 57, 63,
                                                 a, City.mapLength - a, BlockInfo.Air.ID, 0, -1);
                }
                break;

            case "Fire":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 56, 56,
                                                 a, City.mapLength - a, BlockInfo.Netherrack.ID, 0, -1);
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 57, 57,
                                                 a, City.mapLength - a, BlockInfo.Fire.ID, 0, -1);
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 58, 63,
                                                 a, City.mapLength - a, BlockInfo.Air.ID, 0, -1);
                }
                break;

            case "Water":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 59, 63,
                                                 a, City.mapLength - a, BlockInfo.Water.ID, 0, -1);
                }
                break;

            case "Cobweb":
                for (int a = City.edgeLength - 1; a <= City.edgeLength + 5; a++)
                {
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 59, 59,
                                                 a, City.mapLength - a, BlockInfo.Cobweb.ID, 0, -1);
                    BlockShapes.MakeHollowLayers(a, City.mapLength - a, 60, 63,
                                                 a, City.mapLength - a, BlockInfo.Air.ID, 0, -1);
                }
                break;

            default:
                Debug.Fail("Invalid switch result");
                break;
            }
            // drawbridge
            int intBridgeEnd = City.hasMoat ? -2 : 5;

            if (City.moatType == "Lava" || City.moatType == "Fire")
            {
                BlockShapes.MakeSolidBox((City.mapLength / 2) - 2, City.mapLength / 2, 63, 63,
                                         City.edgeLength + intBridgeEnd, City.edgeLength + 6, BlockInfo.StoneBrick.ID, 2);
            }
            else
            {
                BlockShapes.MakeSolidBox((City.mapLength / 2) - 2, City.mapLength / 2, 63, 63,
                                         City.edgeLength + intBridgeEnd, City.edgeLength + 6, BlockInfo.WoodPlank.ID, 2);
            }
            BlockShapes.MakeSolidBox((City.mapLength / 2) - 2, City.mapLength / 2, 64, 65,
                                     City.edgeLength + intBridgeEnd, City.edgeLength + 5, BlockInfo.Air.ID, 2);
        }
Ejemplo n.º 10
0
        public static void Generate(frmMace frmLogForm, BetaWorld worldDest, BetaChunkManager cmDest, BlockManager bmDest,
                                    int x, int z, bool booExportSchematics, string strUndergroundOres)
        {
            #region create a city name
            string strStart, strEnd;
            do
            {
                strStart  = RNG.RandomFileLine(Path.Combine("Resources", City.CityNamePrefixFilename));
                strEnd    = RNG.RandomFileLine(Path.Combine("Resources", City.CityNameSuffixFilename));
                City.Name = City.CityNamePrefix + strStart + strEnd;
            } while (GenerateWorld.lstCityNames.Contains(City.Name) ||
                     strStart.ToLower().Trim() == strEnd.ToLower().Trim() ||
                     (strStart + strEnd).Length > 14);
            GenerateWorld.lstCityNames.Add(City.Name);
            #endregion

            #region determine block sizes
            City.CityLength *= 16;
            City.FarmLength *= 16;
            City.EdgeLength  = 8;
            City.MapLength   = City.CityLength + (City.EdgeLength * 2);
            #endregion

            #region setup classes
            BlockShapes.SetupClass(bmDest);
            BlockHelper.SetupClass(bmDest);
            NoticeBoard.SetupClass();
            if (!SourceWorld.SetupClass(worldDest))
            {
                return;
            }
            #endregion

            #region determine random options
            switch (City.WallMaterialID)
            {
            case BlockType.WOOD_PLANK:
            case BlockType.WOOD:
            case BlockType.LEAVES:
            case BlockType.VINES:
            case BlockType.WOOL:
            case BlockType.BOOKSHELF:
                switch (City.OutsideLightType)
                {
                case "Fire":
                    frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true);
                    City.OutsideLightType = "Torches";
                    break;
                }
                switch (City.MoatType)
                {
                case "Fire":
                case "Lava":
                    frmLogForm.UpdateLog("Fixing fire-spreading combination", true, true);
                    City.MoatType = "Water";
                    break;
                }
                break;
            }
            switch (City.PathType.ToLower().Trim())
            {
            case "stone_raised":
                City.PathBlockID              = BlockInfo.DoubleSlab.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 0;
                City.PathExtends              = 2;
                break;

            case "sandstone_raised":
                City.PathBlockID              = BlockInfo.Sandstone.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 1;
                City.PathExtends              = 2;
                break;

            case "woodplanks_raised":
                City.PathBlockID              = BlockInfo.WoodPlank.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 2;
                City.PathExtends              = 2;
                break;

            case "cobblestone_raised":
                City.PathBlockID              = BlockInfo.Cobblestone.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 3;
                City.PathExtends              = 2;
                break;

            case "brick_raised":
                City.PathBlockID              = BlockInfo.BrickBlock.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 4;
                City.PathExtends              = 2;
                break;

            case "stonebrick_raised":
                City.PathBlockID              = BlockInfo.StoneBrick.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = BlockInfo.Slab.ID;
                City.PathAlternativeBlockData = 5;
                City.PathExtends              = 2;
                break;

            case "stonebrick":
                City.PathBlockID              = BlockInfo.StoneBrick.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = 0;
                City.PathAlternativeBlockData = 0;
                City.PathExtends              = 1;
                break;

            case "sandstone":
                City.PathBlockID              = BlockInfo.Sandstone.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = 0;
                City.PathAlternativeBlockData = 0;
                City.PathExtends              = 1;
                break;

            case "stone":
                City.PathBlockID              = BlockInfo.Stone.ID;
                City.PathBlockData            = 0;
                City.PathAlternativeBlockID   = 0;
                City.PathAlternativeBlockData = 0;
                City.PathExtends              = 1;
                break;

            case "wood":
                City.PathBlockID              = BlockInfo.Wood.ID;
                City.PathBlockData            = RNG.Next(0, 2);
                City.PathAlternativeBlockID   = 0;
                City.PathAlternativeBlockData = 0;
                City.PathExtends              = 1;
                break;
            }
            #endregion

            #region make the city
            frmLogForm.UpdateLog("Creating the " + City.Name, false, false);
            frmLogForm.UpdateLog("City length in blocks: " + City.MapLength, true, true);
            frmLogForm.UpdateLog("Edge length in blocks: " + City.EdgeLength, true, true);
            frmLogForm.UpdateLog("Farm length in blocks: " + City.FarmLength, true, true);
            frmLogForm.UpdateLog("City position in blocks: " + ((x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + "," +
                                 ((z + Chunks.CITY_RELOCATION_CHUNKS) * 16), true, true);
            frmLogForm.UpdateLog("Theme: " + City.ThemeName, true, true);
            frmLogForm.UpdateLog("Creating underground terrain", true, false);
            Chunks.CreateInitialChunks(cmDest, frmLogForm, strUndergroundOres);
            frmLogForm.UpdateProgress(0.21);

            Buildings.structPoint spMineshaftEntrance = new Buildings.structPoint();

            if (City.HasWalls)
            {
                frmLogForm.UpdateLog("Creating walls", true, false);
                Walls.MakeWalls(worldDest, frmLogForm);
            }
            frmLogForm.UpdateProgress(0.24);

            if (City.HasDrawbridges)
            {
                frmLogForm.UpdateLog("Creating entrances", true, false);
                Entrances.MakeEntrances(bmDest);
            }
            frmLogForm.UpdateProgress(0.27);

            if (City.HasMoat)
            {
                frmLogForm.UpdateLog("Creating moat", true, false);
                Moat.MakeMoat(frmLogForm, bmDest);
            }
            frmLogForm.UpdateProgress(0.30);

            if (City.HasBuildings || City.HasPaths)
            {
                frmLogForm.UpdateLog("Creating paths", true, false);
                frmLogForm.UpdateLog("Path type: " + City.PathType, true, true);
                int[,] intArea = Paths.MakePaths(worldDest, bmDest);
                frmLogForm.UpdateProgress(0.33);
                if (City.HasBuildings)
                {
                    frmLogForm.UpdateLog("Creating buildings", true, false);
                    spMineshaftEntrance = Buildings.MakeInsideCity(bmDest, worldDest, intArea, frmLogForm);
                    frmLogForm.UpdateProgress(0.36);
                    if (City.HasMineshaft)
                    {
                        frmLogForm.UpdateLog("Creating mineshaft", true, false);
                        Mineshaft.MakeMineshaft(worldDest, bmDest, spMineshaftEntrance, frmLogForm);
                    }
                }
            }
            frmLogForm.UpdateProgress(0.39);

            if (City.HasGuardTowers)
            {
                frmLogForm.UpdateLog("Creating guard towers", true, false);
                GuardTowers.MakeGuardTowers(bmDest, frmLogForm);
            }
            frmLogForm.UpdateProgress(0.42);

            if (City.HasFarms)
            {
                frmLogForm.UpdateLog("Creating farms", true, false);
                Farms2.MakeFarms(worldDest, bmDest);
            }
            frmLogForm.UpdateProgress(0.45);

            if (City.HasFlowers)
            {
                frmLogForm.UpdateLog("Creating flowers", true, false);
                Flowers.MakeFlowers(worldDest, bmDest);
            }
            frmLogForm.UpdateProgress(0.46);

            if (!City.HasValuableBlocks)
            {
                frmLogForm.UpdateLog("Replacing valuable blocks", true, true);
                cmDest.Save();
                worldDest.Save();
                Chunks.ReplaceValuableBlocks(worldDest, bmDest);
            }
            frmLogForm.UpdateProgress(0.48);

            frmLogForm.UpdateLog("Creating rail data", true, false);
            Chunks.PositionRails(worldDest, bmDest);
            frmLogForm.UpdateProgress(0.50);

            frmLogForm.UpdateLog("Creating lighting data", true, false);
            Chunks.ResetLighting(worldDest, cmDest, frmLogForm);
            frmLogForm.UpdateProgress(0.95);
            #endregion

            #region export schematic
            if (booExportSchematics)
            {
                frmLogForm.UpdateLog("Creating schematic in world folder", true, false);
                AlphaBlockCollection abcExport = new AlphaBlockCollection(City.MapLength, 128, City.MapLength + City.FarmLength);
                for (int xBlock = 0; xBlock < City.MapLength; xBlock++)
                {
                    for (int zBlock = -City.FarmLength; zBlock < City.MapLength; zBlock++)
                    {
                        for (int y = 0; y < 128; y++)
                        {
                            abcExport.SetBlock(xBlock, y, City.FarmLength + zBlock, bmDest.GetBlock(xBlock, y, zBlock));
                        }
                    }
                }
                Schematic CitySchematic = new Schematic(City.MapLength, 128, City.MapLength + City.FarmLength);
                CitySchematic.Blocks = abcExport;
                CitySchematic.Export(worldDest.Path + "\\" + City.Name + ".schematic");
            }
            #endregion

            #region positioning
            frmLogForm.UpdateLog("Creating position data", true, false);
            Chunks.MoveChunks(worldDest, cmDest, x, z);
            frmLogForm.UpdateProgress(1);
            #endregion
        }
Ejemplo n.º 11
0
        private void ShowHelp(object sender, HelpEventArgs hlpevent)
        {
            string strHelp = String.Empty;

            switch (((Control)sender).Name)
            {
            case "btnAbout":
                strHelp = "You just clicked a question mark with a question mark. The world will now implode.";
                break;

            case "btnGenerateCity":
                strHelp = "This button will create a new world in your MineCraft saves directory, with a randomly generated city at the spawn point.\n\nMace doesn't interact with MineCraft directly, so you don't need MineCraft open.";
                break;

            case "picMace":
                strHelp = "Hiring all those graphics artists was definitely worth it.";
                break;
            }
            if (strHelp.Length == 0)
            {
                if (MessageBox.Show("Sorry, no help is available for this control :(\n\nWould you like to fire a random member of the Help Department?", "Help", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Random randSeeds = new Random();
                    RNG.SetSeed(randSeeds.Next());
                    MessageBox.Show("Thank you for submitting this request. We have now fired " + RNG.RandomFileLine(Path.Combine("Resources", "HelpDepartment.txt")) + "\n\nYou monster.", "Requested granted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show(strHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }