예제 #1
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;
            }
        }
예제 #2
0
        public static string GenerateWorldName()
        {
            RNG.SetRandomSeed();
            string strFolder = String.Empty;
            string strWorldName = String.Empty;
            string strType, strStart, strEnd;

            do
            {
                strType      = RNG.RandomFileLine(Path.Combine("Resources", "WorldTypes.txt"));
                strStart     = RNG.RandomFileLine(Path.Combine("Resources", "Adjectives.txt"));
                strEnd       = RNG.RandomFileLine(Path.Combine("Resources", "Nouns.txt"));
                strWorldName = strType + " of " + strStart + strEnd;
                strFolder    = strWorldName.ToMinecraftSaveDirectory();
            } while (strStart.ToLower().Trim() == strEnd.ToLower().Trim() || Directory.Exists(strFolder) || (strStart + strEnd).Length > 14);
            return(strWorldName);
        }
예제 #3
0
        public frmMace()
        {
            InitializeComponent();
            try
            {
                picMace.Load(Path.Combine("Resources", "mace.png"));
                picGhostdancerNPC.Load(Path.Combine("Resources", "npc.jpg"));
                picAbout.Load(Path.Combine("Resources", "about.jpg"));
            }
            catch (Exception)
            {
                MessageBox.Show("Could not find one of the resource files. Please close Mace and ensure you have extracted all of the files from the Mace archive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            RNG.SetRandomSeed();
            CreateSplash();
            Version ver = System.Reflection.Assembly.GetEntryAssembly().GetName().Version;

            this.Text = String.Format("Mace v{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
            ToolTip toolTip1 = new ToolTip();

            toolTip1.AutoPopDelay = 1000000;
            toolTip1.InitialDelay = 500;
            toolTip1.ReshowDelay  = 500;
            toolTip1.ShowAlways   = true;
            toolTip1.SetToolTip(this.lnkGhostdancerMobsForMace, URL_MOBS_FOR_MACE);
            toolTip1.SetToolTip(this.lnkRisugamiModLoader, URL_MOD_LOADER);
            toolTip1.SetToolTip(this.lnkProjectSite, URL_PROJECT_SITE);
            toolTip1.SetToolTip(this.lnkForumTopic, URL_FORUM_TOPIC);
            toolTip1.SetToolTip(this.lnkRobson, URL_ROBSON);
            toolTip1.SetToolTip(this.lnkCredits, URL_CREDITS);
            toolTip1.SetToolTip(this.lnkMedievalBuildingBundle, URL_MEDIEVAL_BUILDING_BUNDLE);
            toolTip1.SetToolTip(this.picAbout, "A visual representation of the Mace code");
            #if DEBUG
            cmbWorldType.SelectedIndex = 0;
            numAmountOfCities.Value    = 1;
            #else
            cmbWorldType.SelectedIndex = 1;
            #endif
            cmbSpawnPoint.SelectedIndex = 2;
            cmbNPCs.SelectedIndex       = 1;
            ShowThemes();
            cbUndergroundOres.SelectedIndex = 2;
        }
예제 #4
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);
        }