Пример #1
0
        static void Drawings()
        {
            Vector3 Position = myHero.Position;

            if (Q.Ready)
            {
                if (!QData.Active && myMenu.Get <MenuCheckbox>("drawQMin").Checked)
                {
                    Drawing.DrawCircle(Position, Q.Data.ChargedMinRange, new ColorBGRA(0, 255, 255, 175), 1);
                }

                if (myMenu.Get <MenuCheckbox>("drawQMax").Checked)
                {
                    Drawing.DrawCircle(Position, Q.Data.ChargedMaxRange, new ColorBGRA(0, 255, 255, 175), 1);
                }
            }

            if ((W.Ready || E.Ready) && myMenu.Get <MenuCheckbox>("drawWE").Checked)
            {
                Drawing.DrawCircle(Position, W.Data.Range, new ColorBGRA(124, 252, 0, 175), 1);
            }

            if (R.Ready && myMenu.Get <MenuCheckbox>("drawR").Checked)
            {
                Drawing.DrawCircle(Position, R.Data.Range, new ColorBGRA(255, 255, 0, 225), 1);
            }

            if (RData.Active && myMenu.Get <MenuCheckbox>("drawRMouse").Checked&& myMenu.Get <MenuCombo>("RMode").CurrentValue == 1)
            {
                Drawing.DrawCircle(Game.CursorPosition, R2Range, new ColorBGRA(147, 112, 219, 255), 1);
            }

            if (R.Ready && myMenu.Get <MenuCheckbox>("drawRText").Checked)
            {
                int tmp = -40;
                foreach (var enemy in Enemies)
                {
                    if (enemy.IsValidTarget(R.Data.Range))
                    {
                        int    shot = (int)Math.Ceiling(enemy.APHealth() / R.Data.GetDamage(enemy));
                        string str  = shot > 1 ? "Shots" : "Shot";
                        if (shot <= RData.Count)
                        {
                            tmp += 40;
                            RText.DrawText(null, enemy.ChampionName + " - " + shot.ToString() + " " + str, 0, tmp + RTextPosY, Color.Red);
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 文本消息处理
        /// </summary>
        /// <param name="rtxt"></param>
        /// <returns></returns>
        public string TextHandle(RText rtxt)
        {
            var stxt   = new SText();
            var resutl = string.Empty;

            switch (rtxt.Content)
            {
            case "111":
                stxt.Content      = "嘻嘻";
                stxt.CreateTime   = MySharpUtility.GetTimeSpan();
                stxt.FromUserName = rtxt.ToUserName;
                stxt.ToUserName   = rtxt.FromUserName;
                resutl            = XmlHelper.GetXML <SText>(stxt);
                break;

            default:
                break;
            }
            //new XmlSerializer(typeof(SText)).Serialize(;
            return(resutl);
        }
Пример #3
0
        /// <summary>
        /// Perform the randomization based on the seed and user-provided settings, and then
        /// generate the new ROM.
        /// </summary>
        public static string RandomizerCreate(bool fromClientApp)
        {
            // List of randomizer modules to use; will add modules based on checkbox states
            Randomizers         = new List <IRandomizer>();
            CosmeticRandomizers = new List <IRandomizer>();


            ///==========================
            /// "CORE" MODULES
            ///==========================
            // NOTE: Just in case, link RStages, RWeaponGet, and RTeleporter into one "Core Randomizer" module
            // Their interdependencies are too risky to separate as options, and likely nobody will want to customize this part anyways.
            // Random portrait locations on stage select
            randomStages = new RStages();
            // Random weapon awarded from each stage
            // WARNING: May be dependent on RTeleporters, verify?
            // WARNING: May be dependent on RStages
            randomWeaponGet = new RWeaponGet();
            // Random teleporter destinations in Wily 5
            randomTeleporters = new RTeleporters();


            ///==========================
            /// "GAMEPLAY SEED" MODULES
            ///==========================
            // Caution: RWeaknesses depends on this
            randomWeaponBehavior = new RWeaponBehavior();

            // Depends on RWeaponBehavior (ammo), can use default values
            randomWeaknesses = new RWeaknesses();

            // Caution: RText depends on this, but default values will be used if not enabled.
            randomBossInBossRoom = new RBossRoom();

            // Independent
            randomBossAI = new RBossAI();

            // Independent
            randomItemGet = new RItemGet();

            // Independent
            randomEnemies = new REnemies();

            // Independent
            randomEnemyWeakness = new REnemyWeaknesses();

            // Independent
            randomTilemap = new RTilemap();


            ///==========================
            /// "COSMETIC SEED" MODULES
            ///==========================
            // Caution: Depends on RBossRoom, but can use default values if its not enabled.
            rWeaponNames = new RText();

            // Independent
            randomColors = new RColors();

            // Independent
            randomMusic = new RMusic();



            // Add randomizers according to each flag
            ///==========================
            /// "GAMEPLAY SEED" MODULES
            ///==========================
            if (Settings.Is8StagesRandom)
            {
                Randomizers.Add(randomStages);
            }
            if (Settings.IsWeaponsRandom)
            {
                Randomizers.Add(randomWeaponGet);
            }
            if (Settings.IsWeaponBehaviorRandom)
            {
                Randomizers.Add(randomWeaponBehavior);
            }
            if (Settings.IsWeaknessRandom)
            {
                Randomizers.Add(randomWeaknesses);
            }
            if (Settings.IsBossAIRandom)
            {
                Randomizers.Add(randomBossAI);
            }
            if (Settings.IsItemsRandom)
            {
                Randomizers.Add(randomItemGet);
            }
            if (Settings.IsTeleportersRandom)
            {
                Randomizers.Add(randomTeleporters);
            }
            if (Settings.IsEnemiesRandom)
            {
                Randomizers.Add(randomEnemies);
            }
            if (Settings.IsEnemyWeaknessRandom)
            {
                Randomizers.Add(randomEnemyWeakness);
            }
            if (Settings.IsBossInBossRoomRandom)
            {
                Randomizers.Add(randomBossInBossRoom);
            }
            if (Settings.IsTilemapChangesEnabled)
            {
                Randomizers.Add(randomTilemap);
            }

            ///==========================
            /// "COSMETIC SEED" MODULES
            ///==========================
            if (Settings.IsColorsRandom)
            {
                CosmeticRandomizers.Add(randomColors);
            }
            if (Settings.IsBGMRandom)
            {
                CosmeticRandomizers.Add(randomMusic);
            }
            if (Settings.IsWeaponNamesRandom)
            {
                CosmeticRandomizers.Add(rWeaponNames);
            }


            // Instantiate RNG object r based on RandomMM2.Seed
            InitializeSeed();

            // Create randomization patch
            Patch = new Patch();

            // In tournament mode, offset the seed by 1 call, making seeds mode-dependent
            if (Settings.IsTournamentMode)
            {
                Random.Next();
                RNGCosmetic.Next();
            }

            // Conduct randomization of Gameplay Modules
            foreach (IRandomizer randomizer in Randomizers)
            {
                randomizer.Randomize(Patch, Random);
                Debug.WriteLine(randomizer);
            }

            // Conduct randomization of Cosmetic Modules
            foreach (IRandomizer cosmetic in CosmeticRandomizers)
            {
                cosmetic.Randomize(Patch, RNGCosmetic);
                Debug.WriteLine(cosmetic);
            }

            // Apply additional required incidental modifications
            if (Settings.Is8StagesRandom || Settings.IsWeaponsRandom)
            {
                MiscHacks.FixPortraits(Patch, Settings.Is8StagesRandom, randomStages, Settings.IsWeaponsRandom, randomWeaponGet);
            }
            if (Settings.IsEnemiesRandom)
            {
                MiscHacks.FixM445PaletteGlitch(Patch);
            }

            // Apply final optional gameplay modifications
            if (Settings.FastText)
            {
                MiscHacks.SetFastText(Patch);
            }
            if (Settings.BurstChaserMode)
            {
                MiscHacks.SetBurstChaser(Patch);
            }
            MiscHacks.DrawTitleScreenChanges(Patch, Seed, Settings.IsTournamentMode);
            MiscHacks.SetWily5NoMusicChange(Patch);
            MiscHacks.FixDamageValues(Patch);
            MiscHacks.SetETankKeep(Patch);
            MiscHacks.SkipItemGetPages(Patch);
            MiscHacks.PreventETankUseAtFullLife(Patch);

            // Create file name based on seed and game region
            string seedAlpha   = SeedConvert.ConvertBase10To26(Seed);
            string newfilename = $"MM2-RNG-{seedAlpha}.nes";

            // Apply patch and deliver the ROM; different routine for client vs. web app
            var assembly = Assembly.GetExecutingAssembly();

            if (fromClientApp)
            {
                //File.Copy(Settings.SourcePath, TempFileName, true);
                //using (Stream stream = assembly.GetManifestResourceStream("MM2Randomizer.Resources.MM2.nes"))
                // Load user provided ROM
                using (Stream stream = new FileStream(Settings.SourcePath, FileMode.Open, FileAccess.Read))
                {
                    using (Stream output = File.OpenWrite(TempFileName))
                    {
                        stream.CopyTo(output);
                    }
                }

                // Apply pre-patch changes via IPS patch (manual title screen, stage select, and stage changes)
                Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_musicpatch);
                Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_prepatch);

                // Apply patch with randomized content
                Patch.ApplyRandoPatch(TempFileName);

                // If a file of the same seed already exists, delete it
                if (File.Exists(newfilename))
                {
                    File.Delete(newfilename);
                }

                // Finish the copy/rename and open Explorer at that location
                File.Move(TempFileName, newfilename);
                RecentlyCreatedFileName        = newfilename;
                Settings.HashValidationMessage = "Successfully copied and patched! File: " + newfilename;
                return(newfilename);
            }
            else
            {
                //File.Copy(Settings.SourcePath, TempFileName, true);
                string serverDir = $@"C:\mm2rng\{seedAlpha}";
                Directory.CreateDirectory(serverDir);

                string serverPathTemp = Path.Combine(serverDir, TempFileName);
                string serverPathNew  = Path.Combine(serverDir, newfilename);
                using (Stream stream = new FileStream("MM2.nes", FileMode.Open))
                {
                    using (Stream output = File.OpenWrite(serverPathTemp))
                    {
                        stream.CopyTo(output);
                    }
                }

                // Apply pre-patch changes via IPS patch (manual title screen, stage select, and stage changes)
                Patch.ApplyIPSPatch(serverPathTemp, Properties.Resources.mm2rng_musicpatch);
                Patch.ApplyIPSPatch(serverPathTemp, Properties.Resources.mm2rng_prepatch);

                // Apply patch with randomized content
                Patch.ApplyRandoPatch(serverPathTemp);

                // If a file of the same seed already exists, delete it
                if (File.Exists(serverPathNew))
                {
                    File.Delete(serverPathNew);
                }

                // Finish the copy/rename and open Explorer at that location
                File.Move(serverPathTemp, serverPathNew);
                RecentlyCreatedFileName = serverPathNew;
                return(serverPathNew);
            }
        }
Пример #4
0
 // TODO;
 public static void FixWeaponLetters(Patch Patch, RWeaponGet randomWeaponGet, RStages randomStages, RText rText)
 {
     int[] shuffledWeapons = randomWeaponGet.GetShuffleIndexPermutation();
     rText.FixWeaponLetters(Patch, shuffledWeapons);
 }
Пример #5
0
        /// <summary>
        /// Perform the randomization based on the seed and user-provided settings, and then
        /// generate the new ROM.
        /// </summary>
        public static String RandomizerCreate(String in_SeedString)
        {
            // Initialize the seed
            if (null == in_SeedString)
            {
                RandomMM2.mSeed = SeedFactory.Create(GeneratorType.MT19937);
            }
            else
            {
                RandomMM2.mSeed = SeedFactory.Create(GeneratorType.MT19937, in_SeedString);
            }

            //Random = new Random(RandomMM2.mSeed);
            //RNGCosmetic = new Random(RandomMM2.mSeed);

            // List of randomizer modules to use; will add modules based on checkbox states
            Randomizers         = new List <IRandomizer>();
            CosmeticRandomizers = new List <IRandomizer>();


            ///==========================
            /// "CORE" MODULES
            ///==========================
            // NOTE: Just in case, link RStages, RWeaponGet, and RTeleporter into one "Core Randomizer" module
            // Their interdependencies are too risky to separate as options, and likely nobody will want to customize this part anyways.
            // Random portrait locations on stage select
            randomStages = new RStages();
            // Random weapon awarded from each stage
            // WARNING: May be dependent on RTeleporters, verify?
            // WARNING: May be dependent on RStages
            randomWeaponGet = new RWeaponGet();
            // Random teleporter destinations in Wily 5
            randomTeleporters = new RTeleporters();


            ///==========================
            /// "GAMEPLAY SEED" MODULES
            ///==========================
            // Caution: RWeaknesses depends on this
            randomWeaponBehavior = new RWeaponBehavior();

            // Depends on RWeaponBehavior (ammo), can use default values
            randomWeaknesses = new RWeaknesses();

            // Caution: RText depends on this, but default values will be used if not enabled.
            randomBossInBossRoom = new RBossRoom();

            // Independent
            randomBossAI = new RBossAI();

            // Independent
            randomItemGet = new RItemGet();

            // Independent
            randomEnemies = new REnemies();

            // Independent
            randomEnemyWeakness = new REnemyWeaknesses();

            // Independent
            randomTilemap = new RTilemap();


            ///==========================
            /// "COSMETIC SEED" MODULES
            ///==========================
            // Caution: Depends on RBossRoom, but can use default values if its not enabled.
            rWeaponNames = new RText();

            // Independent
            randomColors = new RColors(Settings.IsFlashingDisabled);

            // Independent
            randomMusic = new RMusic();



            // Add randomizers according to each flag
            ///==========================
            /// "GAMEPLAY SEED" MODULES
            ///==========================
            if (Settings.Is8StagesRandom)
            {
                Randomizers.Add(randomStages);
            }
            if (Settings.IsWeaponsRandom)
            {
                Randomizers.Add(randomWeaponGet);
            }
            if (Settings.IsWeaponBehaviorRandom)
            {
                Randomizers.Add(randomWeaponBehavior);
            }
            if (Settings.IsWeaknessRandom)
            {
                Randomizers.Add(randomWeaknesses);
            }
            if (Settings.IsBossAIRandom)
            {
                Randomizers.Add(randomBossAI);
            }
            if (Settings.IsItemsRandom)
            {
                Randomizers.Add(randomItemGet);
            }
            if (Settings.IsTeleportersRandom)
            {
                Randomizers.Add(randomTeleporters);
            }
            if (Settings.IsEnemiesRandom)
            {
                Randomizers.Add(randomEnemies);
            }
            if (Settings.IsEnemyWeaknessRandom)
            {
                Randomizers.Add(randomEnemyWeakness);
            }
            if (Settings.IsBossInBossRoomRandom)
            {
                Randomizers.Add(randomBossInBossRoom);
            }
            if (Settings.IsTilemapChangesEnabled)
            {
                Randomizers.Add(randomTilemap);
            }

            ///==========================
            /// "COSMETIC SEED" MODULES
            ///==========================
            if (Settings.IsColorsRandom)
            {
                CosmeticRandomizers.Add(randomColors);
            }
            if (Settings.IsBGMRandom)
            {
                CosmeticRandomizers.Add(randomMusic);
            }
            if (Settings.IsWeaponNamesRandom)
            {
                CosmeticRandomizers.Add(rWeaponNames);
            }


            // Create randomization patch
            Patch = new Patch();

            // In tournament mode, offset the seed by 1 call, making seeds mode-dependent
            if (Settings.IsSpoilerFree)
            {
                RandomMM2.mSeed.Next();
            }

            // Conduct randomization of Gameplay Modules
            foreach (IRandomizer randomizer in Randomizers)
            {
                randomizer.Randomize(Patch, RandomMM2.mSeed);
                Debug.WriteLine(randomizer);
            }

            // Conduct randomization of Cosmetic Modules
            foreach (IRandomizer cosmetic in CosmeticRandomizers)
            {
                cosmetic.Randomize(Patch, RandomMM2.mSeed);
                Debug.WriteLine(cosmetic);
            }

            // Apply additional required incidental modifications
            if (Settings.Is8StagesRandom || Settings.IsWeaponsRandom)
            {
                MiscHacks.FixPortraits(Patch, Settings.Is8StagesRandom, randomStages, Settings.IsWeaponsRandom, randomWeaponGet);
                MiscHacks.FixWeaponLetters(Patch, randomWeaponGet, randomStages, rWeaponNames);
            }
            if (Settings.IsEnemiesRandom)
            {
                MiscHacks.FixM445PaletteGlitch(Patch);
            }

            // Apply final optional gameplay modifications
            if (Settings.FastText)
            {
                MiscHacks.SetFastWeaponGetText(Patch);
                MiscHacks.SetFastReadyText(Patch);
                MiscHacks.SetFastWilyMap(Patch);
                MiscHacks.SkipItemGetPages(Patch);
            }

            if (Settings.BurstChaserMode)
            {
                MiscHacks.SetBurstChaser(Patch);
            }

            if (Settings.IsFlashingDisabled)
            {
                MiscHacks.DisableScreenFlashing(Patch, Settings);
            }

            MiscHacks.SetHitPointChargingSpeed(Patch, Settings.HitPointChargingSpeed);
            MiscHacks.SetWeaponEnergyChargingSpeed(Patch, Settings.WeaponEnergyChargingSpeed);
            MiscHacks.SetEnergyTankChargingSpeed(Patch, Settings.EnergyTankChargingSpeed);
            MiscHacks.SetRobotMasterEnergyChargingSpeed(Patch, Settings.RobotMasterEnergyChargingSpeed);
            MiscHacks.SetCastleBossEnergyChargingSpeed(Patch, Settings.CastleBossEnergyChargingSpeed);

            MiscHacks.DrawTitleScreenChanges(Patch, RandomMM2.mSeed.Identifier, Settings);
            MiscHacks.SetWily5NoMusicChange(Patch);
            MiscHacks.NerfDamageValues(Patch);
            MiscHacks.SetETankKeep(Patch);
            MiscHacks.PreventETankUseAtFullLife(Patch);
            MiscHacks.SetFastBossDefeatTeleport(Patch);

            if (Settings.ReduceUnderwaterLag)
            {
                MiscHacks.ReduceUnderwaterLag(Patch);
            }

            if (Settings.DisableDelayScrolling)
            {
                MiscHacks.DisableDelayScroll(Patch);
            }

            // Create file name based on seed and game region
            String newFileName = $"MM2-RNG-{RandomMM2.mSeed.Identifier} ({RandomMM2.mSeed.SeedString}).nes";

            //File.Copy(Settings.SourcePath, TempFileName, true);
            //using (Stream stream = assembly.GetManifestResourceStream("MM2Randomizer.Resources.MM2.nes"))
            // Load user provided ROM
            using (Stream stream = new FileStream(Settings.SourcePath, FileMode.Open, FileAccess.Read))
            {
                using (Stream output = File.OpenWrite(TempFileName))
                {
                    stream.CopyTo(output);
                }
            }

            // Apply pre-patch changes via IPS patch (manual title screen, stage select, stage changes, player sprite)
            Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_musicpatch);
            Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_prepatch);
            MiscHacks.SetNewMegaManSprite(Patch, TempFileName, Settings.SelectedPlayer);

            // Apply patch with randomized content
            Patch.ApplyRandoPatch(TempFileName);

            // If a file of the same seed already exists, delete it
            if (File.Exists(newFileName))
            {
                File.Delete(newFileName);
            }

            // Finish the copy/rename and open Explorer at that location
            File.Move(TempFileName, newFileName);
            RecentlyCreatedFileName        = newFileName;
            Settings.HashValidationMessage = "Successfully copied and patched! File: " + newFileName;
            return(newFileName);
        }
Пример #6
0
        /// <summary>
        /// Perform the randomization based on the seed and user-provided settings, and then
        /// generate the new ROM.
        /// </summary>
        public static string RandomizerCreate(bool fromClientApp)
        {
            randomStages = new RStages();
            randomWeaponGet = new RWeaponGet();
            randomWeaponBehavior = new RWeaponBehavior();
            randomWeaknesses = new RWeaknesses(true);
            randomBossAI = new RBossAI();
            randomItemGet = new RItemGet();
            randomTeleporters = new RTeleporters();
            randomEnemies = new REnemies();
            randomEnemyWeakness = new REnemyWeaknesses();
            randomBossInBossRoom = new RBossRoom();
            randomTilemap = new RTilemap();
            randomColors = new RColors();
            randomMusic = new RMusic();
            rWeaponNames = new RText();

            Randomizers = new List<IRandomizer>();

            // Add randomizers according to each flag
            if (Settings.Is8StagesRandom)
            {
                Randomizers.Add(randomStages);
            }
            if (Settings.IsWeaponsRandom)
            {
                Randomizers.Add(randomWeaponGet);
            }
            if (Settings.IsWeaponBehaviorRandom)
            {
                Randomizers.Add(randomWeaponBehavior);
            }
            if (Settings.IsWeaknessRandom)
            {
                Randomizers.Add(randomWeaknesses);
            }
            if (Settings.IsBossAIRandom)
            {
                Randomizers.Add(randomBossAI);
            }
            if (Settings.IsItemsRandom)
            {
                Randomizers.Add(randomItemGet);
            }
            if (Settings.IsTeleportersRandom)
            {
                Randomizers.Add(randomTeleporters);
            }
            if (Settings.IsEnemiesRandom)
            {
                Randomizers.Add(randomEnemies);
            }
            if (Settings.IsEnemyWeaknessRandom)
            {
                Randomizers.Add(randomEnemyWeakness);
            }
            if (Settings.IsBossInBossRoomRandom)
            {
                Randomizers.Add(randomBossInBossRoom);
            }
            if (Settings.IsTilemapChangesEnabled)
            {
                Randomizers.Add(randomTilemap);
            }
            if (Settings.IsColorsRandom)
            {
                Randomizers.Add(randomColors);
            }
            if (Settings.IsBGMRandom)
            {
                Randomizers.Add(randomMusic);
            }
            if (Settings.IsWeaponNamesRandom)
            {
                Randomizers.Add(rWeaponNames);
            }
                
            // Instantiate RNG object r based on RandomMM2.Seed
            InitializeSeed();

            // Create randomization patch
            Patch = new Patch();
            foreach (IRandomizer randomizer in Randomizers)
            {
                randomizer.Randomize(Patch, Random);
                Debug.WriteLine(randomizer);
            }

            // Create patch with additional modifications
            if (Settings.FastText)
            {
                MiscHacks.SetFastText(Patch, Settings.IsJapanese);
            }
            if (Settings.BurstChaserMode)
            {
                MiscHacks.SetBurstChaser(Patch, Settings.IsJapanese);
            }
            if (Settings.Is8StagesRandom || Settings.IsWeaponsRandom)
            {
                MiscHacks.FixPortraits(Patch, Settings.Is8StagesRandom, randomStages, Settings.IsWeaponsRandom, randomWeaponGet);
            }
            if (Settings.IsEnemiesRandom)
            {
                MiscHacks.FixM445PaletteGlitch(Patch);
            }
            if (!Settings.IsJapanese)
            {
                MiscHacks.DrawTitleScreenChanges(Patch, Seed);
            }
            MiscHacks.SetWily5NoMusicChange(Patch, Settings.IsJapanese);
            MiscHacks.FixDamageValues(Patch);
            MiscHacks.SetETankKeep(Patch);
            MiscHacks.SkipItemGetPages(Patch);

            // Create file name based on seed and game region
            string newfilename = (Settings.IsJapanese) ? "RM2" : "MM2";
            string seedAlpha = SeedConvert.ConvertBase10To26(Seed);
            newfilename = $"{newfilename}-RNG-{seedAlpha}.nes";

            var assembly = Assembly.GetExecutingAssembly();
            if (fromClientApp)
            {
                //File.Copy(Settings.SourcePath, TempFileName, true);
                using (Stream stream = assembly.GetManifestResourceStream("MM2Randomizer.Resources.MM2.nes"))
                {
                    using (Stream output = File.OpenWrite(TempFileName))
                    {
                        stream.CopyTo(output);
                    }
                }

                // Apply pre-patch changes via IPS patch (manual title screen, stage select, and stage changes)
                Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_musicpatch);
                Patch.ApplyIPSPatch(TempFileName, Properties.Resources.mm2rng_prepatch);

                // Apply patch with randomized content
                Patch.ApplyRandoPatch(TempFileName);

                // If a file of the same seed already exists, delete it
                if (File.Exists(newfilename))
                {
                    File.Delete(newfilename);
                }

                // Finish the copy/rename and open Explorer at that location
                File.Move(TempFileName, newfilename);
                RecentlyCreatedFileName = newfilename;
                return newfilename;
            }
            else
            {
                //File.Copy(Settings.SourcePath, TempFileName, true);
                string serverDir = $@"C:\mm2rng\{seedAlpha}";
                Directory.CreateDirectory(serverDir);

                string serverPathTemp = Path.Combine(serverDir, TempFileName);
                string serverPathNew = Path.Combine(serverDir, newfilename);
                using (Stream stream = assembly.GetManifestResourceStream("MM2Randomizer.Resources.MM2.nes"))
                {
                    using (Stream output = File.OpenWrite(serverPathTemp))
                    {
                        stream.CopyTo(output);
                    }
                }

                // Apply pre-patch changes via IPS patch (manual title screen, stage select, and stage changes)
                Patch.ApplyIPSPatch(serverPathTemp, Properties.Resources.mm2rng_musicpatch);
                Patch.ApplyIPSPatch(serverPathTemp, Properties.Resources.mm2rng_prepatch);

                // Apply patch with randomized content
                Patch.ApplyRandoPatch(serverPathTemp);

                // If a file of the same seed already exists, delete it
                if (File.Exists(serverPathNew))
                {
                    File.Delete(serverPathNew);
                }

                // Finish the copy/rename and open Explorer at that location
                File.Move(serverPathTemp, serverPathNew);
                RecentlyCreatedFileName = serverPathNew;
                return serverPathNew;
            }
        }
Пример #7
0
        /// <summary>
        /// 处理不同请求
        /// </summary>
        /// <returns></returns>
        public string Dispatch()
        {
            if (xml == null)
            {
                return(string.Empty);
            }
            //XElement root=new XElement("xml",
            //    new XElement("ToUserName","kkisc"),
            //    new XElement("FromUserName","scikk"));
            //return string.Empty;
            var result = string.Empty;
            //获取消息对应枚举类型
            var msgType = (RequestMsgType)Enum.Parse(typeof(RequestMsgType), xml.Element("MsgType").Value, true);

            #region 判断消息类型
            switch (msgType)
            {
            case RequestMsgType.Text:
                RText rtext = new RText();
                rtext = XmlHelper.GetModel <RText>(rtext, xml);
                MsgHandle mh = new MsgHandle();
                result = mh.TextHandle(rtext);   //处理相关逻辑
                break;

            case RequestMsgType.Image: break;

            case RequestMsgType.Voice: break;

            case RequestMsgType.Video: break;

            case RequestMsgType.Location: break;

            case RequestMsgType.Link: break;

                #region 事件
            case RequestMsgType.Event:
                //获取事件对应枚举类型
                var eventType = (Event)Enum.Parse(typeof(Event), xml.Element("Event").Value, true);
                switch (eventType)
                {
                case Event.subscribe: break;

                case Event.unsubscribe: break;

                case Event.scan: break;

                case Event.LOCATION: break;

                case Event.CLICK: break;

                case Event.VIEW:        //自定义菜单跳转
                    break;

                default:
                    break;
                }
                break;

                #endregion
            default:
                break;
            }
            #endregion
            return(result);
        }
 public override void Visit(RText element)
 {
     throw new ExpectedException();
 }
 public virtual void Visit(RText text)
 {
     VisitTextCallCount += 1;
 }
Пример #10
0
 public StructuredPiece(string line, IEnumerable <RecordMapping> mapping)
 {
     RecordIndexNumber = new RText(line, mapping, Constants.InputFileField.RECORD_INDEX_NUMBER, FormatTypes.RemovePrefixZeros);
     AppCode           = new RText(line, mapping, Constants.InputFileField.AppCode, FormatTypes.RemovePrefixZeros);
     JobId             = new RText(line, mapping, Constants.InputFileField.JobId, FormatTypes.RemovePrefixZeros);
     ReferenceNumber   = new RText(line, mapping, Constants.InputFileField.ReferenceNumber, FormatTypes.None);
     Name1             = new RText(line, mapping, Constants.InputFileField.Name1, FormatTypes.RemovePrefixZeros);
     Name2             = new RText(line, mapping, Constants.InputFileField.Name2, FormatTypes.RemovePrefixZeros);
     Name3             = new RText(line, mapping, Constants.InputFileField.Name3, FormatTypes.RemovePrefixZeros);
     Name4             = new RText(line, mapping, Constants.InputFileField.Name4, FormatTypes.RemovePrefixZeros);
     Address1          = new RText(line, mapping, Constants.InputFileField.Address1, FormatTypes.RemovePrefixZeros);
     Address2          = new RText(line, mapping, Constants.InputFileField.Address2, FormatTypes.RemovePrefixZeros);
     Address3          = new RText(line, mapping, Constants.InputFileField.Address3, FormatTypes.RemovePrefixZeros);
     Address4          = new RText(line, mapping, Constants.InputFileField.Address4, FormatTypes.RemovePrefixZeros);
     Address5          = new RText(line, mapping, Constants.InputFileField.Address5, FormatTypes.RemovePrefixZeros);
     City             = new RText(line, mapping, Constants.InputFileField.City, FormatTypes.RemovePrefixZeros);
     State            = new RText(line, mapping, Constants.InputFileField.State, FormatTypes.RemovePrefixZeros);
     Zip              = new RText(line, mapping, Constants.InputFileField.Zip, FormatTypes.RemovePrefixZeros);
     ReturnAddress1   = new RText(line, mapping, Constants.InputFileField.ReturnAdd1, FormatTypes.RemovePrefixZeros);
     ReturnAddress2   = new RText(line, mapping, Constants.InputFileField.ReturnAdd2, FormatTypes.RemovePrefixZeros);
     ReturnAddress3   = new RText(line, mapping, Constants.InputFileField.ReturnAdd3, FormatTypes.RemovePrefixZeros);
     ReturnAddress4   = new RText(line, mapping, Constants.InputFileField.ReturnAdd4, FormatTypes.RemovePrefixZeros);
     ReturnAddress5   = new RText(line, mapping, Constants.InputFileField.ReturnAdd5, FormatTypes.RemovePrefixZeros);
     ReturnCity       = new RText(line, mapping, Constants.InputFileField.ReturnCity, FormatTypes.RemovePrefixZeros);
     ReturnState      = new RText(line, mapping, Constants.InputFileField.ReturnState, FormatTypes.RemovePrefixZeros);
     ReturnZip        = new RText(line, mapping, Constants.InputFileField.ReturnZip, FormatTypes.RemovePrefixZeros);
     Tray1            = new RText(line, mapping, Constants.InputFileField.Tray1, FormatTypes.RemovePrefixZeros);
     Tray2            = new RText(line, mapping, Constants.InputFileField.Tray2, FormatTypes.RemovePrefixZeros);
     Tray3            = new RText(line, mapping, Constants.InputFileField.Tray3, FormatTypes.RemovePrefixZeros);
     Tray4            = new RText(line, mapping, Constants.InputFileField.Tray4, FormatTypes.RemovePrefixZeros);
     Tray5            = new RText(line, mapping, Constants.InputFileField.Tray5, FormatTypes.RemovePrefixZeros);
     Tray6            = new RText(line, mapping, Constants.InputFileField.Tray6, FormatTypes.RemovePrefixZeros);
     Images           = new RText(line, mapping, Constants.InputFileField.Images, FormatTypes.RemovePrefixZeros);
     PhysicalPages    = new RText(line, mapping, Constants.InputFileField.PhysicalPages, FormatTypes.RemovePrefixZeros);
     UDF1             = new RText(line, mapping, Constants.InputFileField.UDF1, FormatTypes.RemovePrefixZeros);
     UDF2             = new RText(line, mapping, Constants.InputFileField.UDF2, FormatTypes.RemovePrefixZeros);
     UDF3             = new RText(line, mapping, Constants.InputFileField.UDF3, FormatTypes.RemovePrefixZeros);
     UDF4             = new RText(line, mapping, Constants.InputFileField.UDF4, FormatTypes.RemovePrefixZeros);
     UDF5             = new RText(line, mapping, Constants.InputFileField.UDF5, FormatTypes.RemovePrefixZeros);
     UDF6             = new RText(line, mapping, Constants.InputFileField.UDF6, FormatTypes.RemovePrefixZeros);
     UDF7             = new RText(line, mapping, Constants.InputFileField.UDF7, FormatTypes.RemovePrefixZeros);
     UDF8             = new RText(line, mapping, Constants.InputFileField.UDF8, FormatTypes.RemovePrefixZeros);
     UDF9             = new RText(line, mapping, Constants.InputFileField.UDF9, FormatTypes.RemovePrefixZeros);
     UDF10            = new RText(line, mapping, Constants.InputFileField.UDF10, FormatTypes.RemovePrefixZeros);
     PostalProcessing = new RText(line, mapping, Constants.InputFileField.PostalProcessing, FormatTypes.RemovePrefixZeros);
     DeliveryMode     = new RText(line, mapping, Constants.InputFileField.DeliveryMode, FormatTypes.RemovePrefixZeros);
     DeliveryLocation = new RText(line, mapping, Constants.InputFileField.DeliveryLocation, FormatTypes.RemovePrefixZeros);
     ProcessingDate   = new RText(line, mapping, Constants.InputFileField.ProcessingDate, FormatTypes.None);
     PackageType      = new RText(line, mapping, Constants.InputFileField.PackageType, FormatTypes.RemovePrefixZeros);
     Insert1          = new RText(line, mapping, Constants.InputFileField.Insert1, FormatTypes.RemovePrefixZeros);
     Insert2          = new RText(line, mapping, Constants.InputFileField.Insert2, FormatTypes.RemovePrefixZeros);
     Insert3          = new RText(line, mapping, Constants.InputFileField.Insert3, FormatTypes.RemovePrefixZeros);
     Insert4          = new RText(line, mapping, Constants.InputFileField.Insert4, FormatTypes.RemovePrefixZeros);
     Insert5          = new RText(line, mapping, Constants.InputFileField.Insert5, FormatTypes.RemovePrefixZeros);
     Insert6          = new RText(line, mapping, Constants.InputFileField.Insert6, FormatTypes.RemovePrefixZeros);
     Insert7          = new RText(line, mapping, Constants.InputFileField.Insert7, FormatTypes.RemovePrefixZeros);
     Insert8          = new RText(line, mapping, Constants.InputFileField.Insert8, FormatTypes.RemovePrefixZeros);
     PackageWeight    = new RText(line, mapping, Constants.InputFileField.PackageWeight, FormatTypes.RemovePrefixZeros);
     SupressionCode   = new RText(line, mapping, Constants.InputFileField.SupressionCode, FormatTypes.RemovePrefixZeros);
     ValidRecord      = new RText(line, mapping, Constants.InputFileField.ValidRecord, FormatTypes.RemovePrefixZeros);
     SampleRecord     = new RText(line, mapping, Constants.InputFileField.SampleRecord, FormatTypes.RemovePrefixZeros);
     EpresentmentCode = new RText(line, mapping, Constants.InputFileField.EpresentmentCode, FormatTypes.RemovePrefixZeros);
     ClientId         = new RText(line, mapping, Constants.InputFileField.ClientId, FormatTypes.RemovePrefixZeros);
     Plexing          = new RText(line, mapping, Constants.InputFileField.Plexing, FormatTypes.RemovePrefixZeros);
     LetDate          = new RText(line, mapping, Constants.InputFileField.LetDate, FormatTypes.None);
     ProjectName      = new RText(line, mapping, Constants.InputFileField.ProjectName, FormatTypes.RemovePrefixZeros);
     PageStart        = new RText(line, mapping, Constants.InputFileField.PageStart, FormatTypes.RemovePrefixZeros);
     PageEnd          = new RText(line, mapping, Constants.InputFileField.PageEnd, FormatTypes.RemovePrefixZeros);
     EpresentmentInd  = new RText(line, mapping, Constants.InputFileField.EpresentmentInd, FormatTypes.RemovePrefixZeros);
     FileDate         = new RText(line, mapping, Constants.InputFileField.FILE_DATE, FormatTypes.None);
 }