Esempio n. 1
0
        private static void MakeGuardChest(BlockManager bm, int x, int y, int z)
        {
            TileEntityChest tec = new TileEntityChest();

            if (City.HasItemsInChests)
            {
                for (int a = 0; a < 5; a++)
                {
                    tec.Items[a] = BlockHelper.MakeItem(RNG.RandomItem(ItemInfo.IronSword.ID,
                                                                       ItemInfo.WoodenSword.ID,
                                                                       ItemInfo.StoneSword.ID), 1);
                }
                tec.Items[6] = BlockHelper.MakeItem(ItemInfo.Bow.ID, 1);
                tec.Items[7] = BlockHelper.MakeItem(ItemInfo.Arrow.ID, 64);
                int intArmourStartID = RNG.RandomItem(ItemInfo.LeatherCap.ID,
                                                      ItemInfo.ChainHelmet.ID,
                                                      ItemInfo.IronHelmet.ID);
                for (int a = 9; a < 18; a++)
                {
                    // random armour
                    tec.Items[a] = BlockHelper.MakeItem(intArmourStartID + RNG.Next(4), 1);
                }
            }
            bm.SetID(x, y, z, BlockInfo.Chest.ID);
            bm.SetTileEntity(x, y, z, tec);
        }
Esempio n. 2
0
        private void btnGenerateRandomSeedIdea_Click(object sender, EventArgs e)
        {
            RNG.SetRandomSeed();
            switch (RNG.Next(4))
            {
            case 0:
                txtWorldSeed.Text = "{" + RNG.RandomItem("Your name", "A friend's name",
                                                         "Your pet's name", "Your shoe size", "Your lucky number") + "}";
                break;

            case 1:
                txtWorldSeed.Text = "{Your favourite " + RNG.RandomItem(
                    "food", "place", "activity", "Buffy character", "film", "book", "website", "game",
                    "mathematician", "tv show", "subject", "colour", "letter", "breed of hippo",
                    "celebrity", "c# hashtable key", "animal", "drink", "minecraft block", "potion",
                    "tv character", "colonel", "film character", "shade of green", "cluedo weapon",
                    "minecraft enemy", "capital", "ore", "keen commander", "dancing ghost") + "}";
                break;

            case 2:
                txtWorldSeed.Text = RNG.RandomFileLine(Path.Combine("Resources", "Adjectives.txt")).ToLower().Trim();
                break;

            case 3:
                txtWorldSeed.Text = RNG.RandomFileLine(Path.Combine("Resources", "Nouns.txt")).ToLower().Trim();
                break;

            default:
                txtWorldSeed.Text = "";
                break;
            }
        }
Esempio n. 3
0
        private static void MakeEmblem()
        {
            if (City.cityEmblemType.ToLower() != "none")
            {
                int      intBlockyBlock = RNG.RandomItem(BlockInfo.GoldBlock.ID, BlockInfo.IronBlock.ID, BlockInfo.DiamondBlock.ID);
                string[] strEmblem;
                strEmblem = File.ReadAllLines(Path.Combine("Resources", "Emblem " + City.cityEmblemType + ".txt"));

                for (int y = 0; y < strEmblem.GetLength(0); y++)
                {
                    strEmblem[y] = strEmblem[y].Replace("  ", " ");
                    strEmblem[y] = strEmblem[y].Replace("\t", " "); //tab
                    string[] strLine = strEmblem[y].Split(' ');
                    for (int x = 0; x < strLine.GetLength(0); x++)
                    {
                        string[] strSplit = strLine[x].Split(':');
                        if (strSplit.GetLength(0) == 1)
                        {
                            Array.Resize(ref strSplit, 2);
                        }
                        if (strSplit[0] == "-1")
                        {
                            strSplit[0] = intBlockyBlock.ToString();
                        }
                        BlockShapes.MakeBlock(((City.mapLength / 2) - (strLine.GetLength(0) + 6)) + x, 71 - y,
                                              City.edgeLength + 5, Convert.ToInt32(strSplit[0]), 2, 100,
                                              Convert.ToInt32(strSplit[1]));
                    }
                    for (int x = strLine.GetLength(0) + 1; x < strLine.GetLength(0) + 5; x++)
                    {
                        BlockShapes.MakeBlock((City.mapLength / 2) - (6 + x), 69,
                                              City.edgeLength + 5, BlockInfo.Air.ID, 2, 100, 0);
                        BlockShapes.MakeBlock((City.mapLength / 2) - (6 + x), 70,
                                              City.edgeLength + 5, BlockInfo.Air.ID, 2, 100, 0);
                    }
                }
            }
        }
Esempio n. 4
0
 private static int SelectRandomResource(double dblDepth)
 {
     if (dblDepth > 0.66)
     {
         return(RNG.RandomItem(BlockInfo.CoalOre.ID,
                               BlockInfo.IronOre.ID));
     }
     else if (dblDepth > 0.33)
     {
         return(RNG.RandomItem(BlockInfo.CoalOre.ID,
                               BlockInfo.IronOre.ID,
                               BlockInfo.LapisOre.ID,
                               BlockInfo.RedstoneOre.ID));
     }
     else
     {
         return(RNG.RandomItem(BlockInfo.CoalOre.ID,
                               BlockInfo.IronOre.ID,
                               BlockInfo.LapisOre.ID,
                               BlockInfo.RedstoneOre.ID,
                               BlockInfo.GoldOre.ID,
                               BlockInfo.DiamondOre.ID));
     }
 }
Esempio n. 5
0
        static public void Generate(frmMace frmLogForm, string UserWorldName, string strWorldSeed,
                                    string strWorldType, bool booWorldMapFeatures, int TotalCities, string[] strCheckedThemes,
                                    int ChunksBetweenCities, string strSpawnPoint, bool booExportSchematics,
                                    string strSelectedNPCs, string strUndergroundOres)
        {
            frmLogForm.UpdateLog("Started at " + DateTime.Now.ToLocalTime(), false, true);

            worldCities = new WorldCity[TotalCities];
            lstCityNames.Clear();
            Chunks.biomes.Clear();

            RNG.SetRandomSeed();

            #region create minecraft world directory from a random unused world name
            string strFolder = String.Empty, strWorldName = String.Empty;

            UserWorldName = UserWorldName.ToSafeFilename();
            if (UserWorldName.Trim().Length == 0)
            {
                UserWorldName = "random";
            }

            if (UserWorldName.ToLower().Trim() != "random")
            {
                if (Directory.Exists(UserWorldName.ToMinecraftSaveDirectory()))
                {
                    if (MessageBox.Show("A world called \"" + UserWorldName + "\" already exists. " +
                                        "Would you like to use a random name instead?", "World already exists",
                                        MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        frmLogForm.UpdateLog("Cancelled, because a world with this name already exists.", false, false);
                        return;
                    }
                }
                else
                {
                    strWorldName = UserWorldName;
                    strFolder    = strWorldName.ToMinecraftSaveDirectory();
                }
            }
            if (strWorldName.Length == 0)
            {
                strWorldName = Utils.GenerateWorldName();
                strFolder    = strWorldName.ToMinecraftSaveDirectory();
            }
            Directory.CreateDirectory(strFolder);
            frmLogForm.btnSaveLogNormal.Tag  = Path.Combine(strFolder, "LogNormal.txt");
            frmLogForm.btnSaveLogVerbose.Tag = Path.Combine(strFolder, "LogVerbose.txt");
            frmLogForm.UpdateLog("World name: " + strWorldName, false, true);
            #endregion

            #region get handles to world, chunk manager and block manager
            AnvilWorld worldDest = AnvilWorld.Create(@strFolder);
            worldDest.Level.LevelName = "Creating. Don't open until Mace is finished.";
            RegionChunkManager cmDest = worldDest.GetChunkManager();
            BlockManager       bmDest = worldDest.GetBlockManager();
            bmDest.AutoLight = false;
            #endregion

            #region Determine themes
            // "how does this work, robson?"
            // well, I'm glad you asked!
            // we keep selecting a random unused checked theme, until they've all been used once.
            // after that, all other cities will have a random checked theme

            int maxFarmSize = 0;

            strCheckedThemes = RNG.ShuffleArray(strCheckedThemes);
            for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++)
            {
                if (CurrentCityID <= strCheckedThemes.GetUpperBound(0))
                {
                    worldCities[CurrentCityID].ThemeName = strCheckedThemes[CurrentCityID];
                }
                else
                {
                    worldCities[CurrentCityID].ThemeName = RNG.RandomItem(strCheckedThemes);
                }
                City.themeName = worldCities[CurrentCityID].ThemeName;
                worldCities[CurrentCityID].ChunkLength = GetThemeRandomXMLElementNumber("options", "city_size");
                int farmSize = GetThemeLastXMLElementNumber("options", "farm_size");
                maxFarmSize = Math.Max(maxFarmSize, farmSize);
            }
            #endregion

            GenerateCityLocations(TotalCities, ChunksBetweenCities + maxFarmSize);

            int intRandomCity = RNG.Next(TotalCities);

            for (int CurrentCityID = 0; CurrentCityID < TotalCities; CurrentCityID++)
            {
                MakeCitySettings(frmLogForm, worldCities[CurrentCityID].ThemeName, CurrentCityID, strSelectedNPCs);
                if (!GenerateCity.Generate(frmLogForm, worldDest, cmDest, bmDest, worldCities[CurrentCityID].x, worldCities[CurrentCityID].z, booExportSchematics, strUndergroundOres))
                {
                    frmLogForm.UpdateLog("World generation failed/cancelled.", false, false);
                    return;
                }
                #region set spawn point
                if (City.id == intRandomCity)
                {
                    switch (strSpawnPoint)
                    {
                    case "Away from the cities":
                        worldDest.Level.Spawn = new SpawnPoint(0, 65, 0);
                        break;

                    case "Inside a random city":
                        worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2),
                                                               65,
                                                               ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2));
                        break;

                    case "Outside a random city":
                        worldDest.Level.Spawn = new SpawnPoint(((worldCities[intRandomCity].x + Chunks.CITY_RELOCATION_CHUNKS) * 16) + (City.mapLength / 2),
                                                               65,
                                                               ((worldCities[intRandomCity].z + Chunks.CITY_RELOCATION_CHUNKS) * 16) + 2);
                        break;

                    default:
                        Debug.Fail("invalid spawn point");
                        break;
                    }
                    frmLogForm.UpdateLog("Spawn point set to " + worldDest.Level.Spawn.X + "," + worldDest.Level.Spawn.Y + "," + worldDest.Level.Spawn.Z, false, true);
                }
                #endregion
            }

            #region weather
            frmLogForm.UpdateLog("Setting weather", false, true);
            worldDest.Level.Time = RNG.Next(24000);
            if (RNG.NextDouble() < 0.15)
            {
                frmLogForm.UpdateLog("Rain", false, true);
                worldDest.Level.IsRaining = true;
                // one-quarter to three-quarters of a day
                worldDest.Level.RainTime = RNG.Next(6000, 18000);
                if (RNG.NextDouble() < 0.25)
                {
                    frmLogForm.UpdateLog("Thunder", false, true);
                    worldDest.Level.IsThundering = true;
                    worldDest.Level.ThunderTime  = worldDest.Level.RainTime;
                }
            }
            #endregion

            #region world details
            worldDest.Level.LevelName = strWorldName;
            frmLogForm.UpdateLog("Setting world type: " + strWorldType, false, true);
            switch (strWorldType.ToLower())
            {
            case "creative":
                worldDest.Level.GameType = GameType.CREATIVE;
                break;

            case "survival":
                worldDest.Level.GameType = GameType.SURVIVAL;
                break;

            case "hardcore":
                worldDest.Level.GameType = GameType.SURVIVAL;
                worldDest.Level.Hardcore = true;
                break;

            default:
                Debug.Fail("Invalidate world type selected.");
                break;
            }
            frmLogForm.UpdateLog("World map features: " + booWorldMapFeatures.ToString(), false, true);
            worldDest.Level.UseMapFeatures = booWorldMapFeatures;
            if (strWorldSeed != String.Empty)
            {
                long seed = 0;
                if (long.TryParse(strWorldSeed, out seed))
                {
                    worldDest.Level.RandomSeed = seed;
                    frmLogForm.UpdateLog("Specified world seed: " + worldDest.Level.RandomSeed, false, true);
                }
                else
                {
                    worldDest.Level.RandomSeed = strWorldSeed.ToJavaHashCode();
                    frmLogForm.UpdateLog("Specified world seed: " + strWorldSeed, false, true);
                    frmLogForm.UpdateLog("Specified world seed converted to a number: " + worldDest.Level.RandomSeed, false, true);
                }
            }
            else
            {
                worldDest.Level.RandomSeed = RNG.Next();
                frmLogForm.UpdateLog("Random world seed: " + worldDest.Level.RandomSeed, false, true);
            }
            worldDest.Level.LastPlayed = (DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks) / 10000;
            frmLogForm.UpdateLog("World time: " + worldDest.Level.LastPlayed, false, true);
            #endregion

            cmDest.Save();
            worldDest.Save();

            Chunks.SetBiomeData(@strFolder);

            frmLogForm.UpdateLog("\nCreated the " + strWorldName + "!", false, false);
            frmLogForm.UpdateLog("It'll be at the top of your MineCraft world list.", false, false);

            frmLogForm.UpdateLog("Finished at " + DateTime.Now.ToLocalTime(), false, true);
        }
Esempio n. 6
0
        public static string RandomValueFromXMLElement(string strFilenameXML, string strParentNode, string strChildNode)
        {
            string strValues = ValueFromXMLElement(strFilenameXML, strParentNode, strChildNode);

            return(RNG.RandomItem(strValues.Split(',')));
        }
Esempio n. 7
0
        // todo low: this is way too big
        private static void MakeLevel(BetaWorld world, BlockManager bm, int intDepth, int intMineshaftSize,
                                      Buildings.structPoint spMineshaftEntrance, frmMace frmLogForm)
        {
            frmLogForm.UpdateLog("Creating mineshaft level " + intDepth, true, true);

            string[] strResourceNames = Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"),
                                                                  "level" + intDepth, "names").Split(',');
            int[] intResourceChances = Utils.ValueFromXMLElement(
                Path.Combine("Resources", "Mineshaft.xml"), "level" + intDepth, "chances").Split(',').StringArrayToIntArray();
            int intTorchChance = Convert.ToInt32(Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"),
                                                                           "level" + intDepth, "torch_chance"));

            MineshaftBlocks[,] mbAreaFull = new MineshaftBlocks[intMineshaftSize + (MULTIPLIER * 2), intMineshaftSize + (MULTIPLIER * 2)];

            int intXPosOriginal = spMineshaftEntrance.x - _intBlockStartBuildings;
            int intZPosOriginal = spMineshaftEntrance.z - _intBlockStartBuildings;

            _intBlockStartBuildings -= 2;
            int[,] intAreaOverview   = new int[(mbAreaFull.GetLength(0) / MULTIPLIER), (mbAreaFull.GetLength(1) / MULTIPLIER)];
            int intXPos = intXPosOriginal / MULTIPLIER;
            int intZPos = intZPosOriginal / MULTIPLIER;

            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air;
            CreateRouteXPlus(intAreaOverview, intXPos + 1, intZPos, 0);
            CreateRouteZPlus(intAreaOverview, intXPos, intZPos + 1, 1);
            CreateRouteXMinus(intAreaOverview, intXPos - 1, intZPos, 2);
            CreateRouteZMinus(intAreaOverview, intXPos, intZPos - 1, 3);
            int intOffsetX = (intXPosOriginal - (intXPos * MULTIPLIER)) - 2;
            int intOffsetZ = (intZPosOriginal - (intZPos * MULTIPLIER)) - 2;

            List <structSection> lstSections = new List <structSection>();

            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Placeholder;
            intAreaOverview = AddMineshaftSections(intAreaOverview, intDepth);
            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air;

            for (int x = 0; x < intAreaOverview.GetLength(0); x++)
            {
                for (int z = 0; z < intAreaOverview.GetLength(1); z++)
                {
                    if (intAreaOverview[x, z] >= 100)
                    {
                        structSection structCurrentSection = new structSection();
                        structCurrentSection.bldMineshaftSection = SourceWorld.GetBuilding(intAreaOverview[x, z] - 100);
                        structCurrentSection.x = ((x * MULTIPLIER) + intOffsetX) - 1;
                        structCurrentSection.z = ((z * MULTIPLIER) + intOffsetZ) - 1;
                        for (int x2 = x; x2 <= x + (structCurrentSection.bldMineshaftSection.intSizeX - 1) / 7; x2++)
                        {
                            for (int z2 = z; z2 <= z + (structCurrentSection.bldMineshaftSection.intSizeZ - 1) / 7; z2++)
                            {
                                if (intAreaOverview[x2, z2] == structCurrentSection.bldMineshaftSection.intID + 100)
                                {
                                    intAreaOverview[x2, z2] = (int)MineshaftBlocks.Structure;
                                }
                            }
                        }
                        lstSections.Add(structCurrentSection);
                    }
                }
            }
            for (int x = 4; x < mbAreaFull.GetLength(0) - 4; x++)
            {
                for (int z = 4; z < mbAreaFull.GetLength(1) - 4; z++)
                {
                    if (intAreaOverview.GetLength(0) > x / MULTIPLIER && intAreaOverview.GetLength(1) > z / MULTIPLIER)
                    {
                        switch (mbAreaFull[x + intOffsetX, z + intOffsetZ])
                        {
                        case MineshaftBlocks.NaturalTerrain:
                        case MineshaftBlocks.Air:
                        case MineshaftBlocks.Placeholder:
                        case MineshaftBlocks.EntranceSection:
                            mbAreaFull[x + intOffsetX, z + intOffsetZ] = (MineshaftBlocks)intAreaOverview[x / MULTIPLIER, z / MULTIPLIER];
                            break;
                        }
                    }
                    if ((x + 3) % 5 == 0 && (z + 3) % 5 == 0 && intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                    {
                        if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] >= 100)
                        {
                            for (int x2 = 0; x2 < 5; x2++)
                            {
                                mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Structure;
                            }
                        }
                        if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                        {
                            for (int x2 = 0; x2 < 5; x2++)
                            {
                                if (x2 == 1 || x2 == 3)
                                {
                                    mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.CeilingSupport;
                                    mbAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = MineshaftBlocks.CeilingSupport;
                                }
                                else
                                {
                                    mbAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Support;
                                    mbAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = MineshaftBlocks.Support;
                                }
                            }
                            for (int x2 = 0; x2 <= 5; x2++)
                            {
                                if (mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] == MineshaftBlocks.Support)
                                {
                                    mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] = MineshaftBlocks.RailWithSupport;
                                }
                                else
                                {
                                    mbAreaFull[x + intOffsetX + x2, z + intOffsetZ] = MineshaftBlocks.Rail;
                                }
                            }
                        }
                        if (intAreaOverview[x / MULTIPLIER, (z / MULTIPLIER) + 1] == (int)MineshaftBlocks.Air)
                        {
                            for (int z2 = 0; z2 < 5; z2++)
                            {
                                if (z2 == 1 || z2 == 3)
                                {
                                    mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = MineshaftBlocks.CeilingSupport;
                                    mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = MineshaftBlocks.CeilingSupport;
                                }
                                else
                                {
                                    mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = MineshaftBlocks.Support;
                                    mbAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = MineshaftBlocks.Support;
                                }
                            }
                            for (int z2 = 0; z2 <= 5; z2++)
                            {
                                if (mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] == MineshaftBlocks.Support)
                                {
                                    mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] = MineshaftBlocks.RailWithSupport;
                                }
                                else
                                {
                                    mbAreaFull[x + intOffsetX, z + intOffsetZ + z2] = MineshaftBlocks.Rail;
                                }
                            }
                        }
                        if (intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                        {
                            MakeChestAndOrTorch(intAreaOverview, mbAreaFull, (x - 3) / MULTIPLIER, z / MULTIPLIER,
                                                x + intOffsetX - 2, z + intOffsetZ);
                            MakeChestAndOrTorch(intAreaOverview, mbAreaFull, (x + 3) / MULTIPLIER, z / MULTIPLIER,
                                                x + intOffsetX + 2, z + intOffsetZ);
                            MakeChestAndOrTorch(intAreaOverview, mbAreaFull, x / MULTIPLIER, (z - 3) / MULTIPLIER,
                                                x + intOffsetX, z + intOffsetZ - 2);
                            MakeChestAndOrTorch(intAreaOverview, mbAreaFull, x / MULTIPLIER, (z + 3) / MULTIPLIER,
                                                x + intOffsetX, z + intOffsetZ + 2);
                        }
                    }
                }
            }
            mbAreaFull[intXPosOriginal, intZPosOriginal] = MineshaftBlocks.EntranceSection;
            int intSupportMaterial = RNG.RandomItem(BlockInfo.Wood.ID, BlockInfo.WoodPlank.ID, BlockInfo.Fence.ID);

            for (int x = 0; x < mbAreaFull.GetLength(0); x++)
            {
                for (int z = 0; z < mbAreaFull.GetLength(1); z++)
                {
                    if (intDepth <= 4)
                    {
                        if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Gravel.ID)
                        {
                            bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockInfo.Stone.ID);
                        }
                    }
                    if (intDepth <= 2)
                    {
                        if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Sand.ID ||
                            bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockInfo.Sandstone.ID)
                        {
                            bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockInfo.Dirt.ID);
                        }
                    }
                    switch (mbAreaFull[x, z])
                    {
                    case MineshaftBlocks.NaturalTerrain:
                        break;

                    case MineshaftBlocks.Air:
                        for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID);
                        }
                        break;

                    case MineshaftBlocks.EntranceSection:
                    case MineshaftBlocks.Rail:
                        for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            if (y == 38 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Gravel.ID);
                            }
                            else if (y == 39 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Rails.ID);
                            }
                            else
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Air.ID);
                            }
                        }
                        break;

                    case MineshaftBlocks.RailWithSupport:
                        for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            if (y == 38 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Gravel.ID);
                            }
                            else if (y == 39 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Rails.ID);
                            }
                            else if (y == 40 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Air.ID);
                            }
                            else
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         intSupportMaterial);
                            }
                        }
                        break;

                    case MineshaftBlocks.Support:
                        for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                     intSupportMaterial);
                        }
                        break;

                    case MineshaftBlocks.ChestAndOrTorch:
                        for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            if (y == 39 - (5 * intDepth) &&
                                RNG.NextDouble() > 0.9)
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Chest.ID);
                                MakeChestItems(bm, x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intResourceChances, strResourceNames);
                            }
                            else if (y == 41 - (5 * intDepth) &&
                                     RNG.NextDouble() < (double)intTorchChance / 100)
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         BlockInfo.Torch.ID);
                                if (mbAreaFull[x - 1, z] == 0)
                                {
                                    bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 1);
                                }
                                else if (mbAreaFull[x + 1, z] == 0)
                                {
                                    bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 2);
                                }
                                else if (mbAreaFull[x, z - 1] == 0)
                                {
                                    bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 3);
                                }
                                else
                                {
                                    bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 4);
                                }
                            }
                            else
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID);
                            }
                        }
                        break;

                    case MineshaftBlocks.CeilingSupport:
                        for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                        {
                            if (y == 41 - (5 * intDepth))
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         intSupportMaterial);
                            }
                            else
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID);
                            }
                        }
                        break;

                    case MineshaftBlocks.Unused9:
                        for (int y = 39 - (5 * intDepth); y <= 41 - (5 * (intDepth - 1)); y++)
                        {
                            bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockInfo.Air.ID);
                        }
                        break;

                    case MineshaftBlocks.Structure:
                        // this will be overwritten later
                        break;

                    default:
                        Debug.Fail("Invalid switch result");
                        break;
                    }
                }
            }
            foreach (structSection MineshaftSection in lstSections)
            {
                SourceWorld.InsertBuilding(bm, new int[0, 0], _intBlockStartBuildings, MineshaftSection.x, MineshaftSection.z,
                                           MineshaftSection.bldMineshaftSection, 38 - (5 * intDepth), -1);
            }
            world.Save();
            _intBlockStartBuildings += 2;
            //#if DEBUG
            //    File.WriteAllText("output_area_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaOverview));
            //    File.WriteAllText("output_map_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaFull));
            //#endif
        }
Esempio n. 8
0
        private static string RandomSign()
        {
            string strSignText = "*~*~*~*";

            int intRand;

            do
            {
                intRand = RNG.Next(intAmountOfSignTypes);
            } while (intRand >= 5 && _booSignUsed[intRand]);
            _booSignUsed[intRand] = true;

            do
            {
                switch (intRand)
                {
                case 0:
                case 1: strSignText = String.Format("{0} {1} {2} for {3}~-{4} {5}.{6}.",
                                                    RNG.RandomItem("I will", "I can", "Will", "Can", "Can you"),
                                                    RNG.RandomItem("trade", "swap", "sell"),
                                                    RNG.RandomItem("gold", "iron", "dirt", "tools", "glass", "flowers", "cake", "mushrooms"),
                                                    RNG.RandomItem("obsidian", "wood", "sand", "bricks", "coal", "stone", "cookies", "diamonds"),
                                                    RNG.RandomItem("See", "Talk to"),
                                                    RNG.RandomLetter().ToString().ToUpper(),
                                                    RNG.RandomLetter().ToString().ToUpper());
                    break;

                case 2: strSignText = String.Format("{0} of the holy {1} are meeting this {2}",
                                                    RNG.RandomItem("Church", "Order"),
                                                    RNG.RandomFileLine(Path.Combine("Resources", "ChurchNoun.txt")),
                                                    RNG.RandomDay());
                    break;

                case 3: strSignText = String.Format("{0} {1} has lost her {2}. {3}",
                                                    RNG.RandomItem("Mrs", "Miss"),
                                                    RNG.RandomFileLine(Path.Combine("Resources", "Adjectives.txt")),
                                                    RNG.RandomItem("cat", "dog", "glasses", "marbles", "knitting"),
                                                    RNG.RandomItem("Reward offered", "Please help"));
                    break;

                case 4: strSignText = String.Format("{0} for sale~-{1} {2}.{3}.",
                                                    RNG.RandomItem("Armour", "Property", "House", "Weapons", "Gold", "Bodyguard", "Pet wolf", "Books", "Tools"),
                                                    RNG.RandomItem("See", "Talk to"),
                                                    RNG.RandomLetter().ToString().ToUpper(),
                                                    RNG.RandomLetter().ToString().ToUpper());
                    break;

                case 5: strSignText = "Lost pet creeper. Last seen near the mini crater";
                    break;

                case 6: strSignText = "Israphel~~Wanted dead~or alive";
                    break;

                case 7: strSignText = "Lost Jaffa Cakes. Please return to Honeydew";
                    break;

                case 8: strSignText = "Read note " + RNG.Next(500, 999);
                    break;

                case 9: strSignText = "Buy one get one free on gravestones!";
                    break;

                case 10: strSignText = "Archery practice this " + RNG.RandomDay() + " afternoon";
                    break;

                case 11: strSignText = "Seen a crime? Tell the nearest city guard";
                    break;

                case 12: strSignText = "New city law: No minors can be miners";
                    break;

                case 13: strSignText = "Council meeting this " + RNG.RandomDay();
                    break;

                case 14: strSignText = "Numbers for lovers:~" + RNG.RandomItem("220 284", "1184 1210", "2620 2924", "5020 5564", "6232 6368");
                    break;

                default:
                    Debug.Fail("Invalid switch result");
                    break;
                }
            } while (!strSignText.IsValidSign());
            return(strSignText);
        }