Ejemplo n.º 1
0
        public static void TestFloor(Stopwatch watch, ZoneSegmentBase structure, ZoneGenContext zoneContext, Dictionary <int, int> generatedItems, Dictionary <int, int> generatedEnemies, List <TimeSpan> generationTimes)
        {
            TimeSpan before = watch.Elapsed;

            watch.Start();
            IGenContext context = structure.GetMap(zoneContext);

            watch.Stop();
            TimeSpan diff = watch.Elapsed - before;

            generationTimes.Add(diff);


            BaseMapGenContext mapContext = context as BaseMapGenContext;

            if (generatedItems != null)
            {
                foreach (MapItem mapItem in mapContext.Map.Items)
                {
                    if (mapItem.IsMoney)
                    {
                        MathUtils.AddToDictionary <int>(generatedItems, -1, mapItem.Value);
                        MathUtils.AddToDictionary <int>(generatedItems, 0, 1);
                    }
                    else
                    {
                        MathUtils.AddToDictionary <int>(generatedItems, mapItem.Value, 1);
                    }
                }
            }
            if (generatedEnemies != null)
            {
                foreach (Team team in mapContext.Map.MapTeams)
                {
                    foreach (Character character in team.Players)
                    {
                        MathUtils.AddToDictionary <int>(generatedEnemies, character.BaseForm.Species, 1);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void MapMenu(string prevState, int zoneIndex, SegLoc floorIndex, ZoneSegmentBase structure)
        {
            ulong zoneSeed = MathUtils.Rand.NextUInt64();

            try
            {
                ulong newSeed;
                if (UInt64.TryParse((string)Registry.GetValue(DiagManager.REG_PATH, "SeedChoice", ""), out newSeed))
                {
                    zoneSeed = newSeed;
                }

                Registry.SetValue(DiagManager.REG_PATH, "SeedChoice", zoneSeed.ToString());

                while (true)
                {
                    Console.Clear();

                    ConsoleKey key            = ConsoleKey.Enter;
                    string     state          = prevState + ">" + floorIndex.ID + ": ";
                    bool       threwException = false;
                    try
                    {
                        ZoneGenContext newContext = CreateZoneGenContext(zoneSeed, zoneIndex, floorIndex, structure);

                        IGenContext context = structure.GetMap(newContext);

                        ExampleDebug.SteppingIn = false;

                        BaseMapGenContext stairsMap = context as BaseMapGenContext;
                        state += stairsMap.Map.Name.DefaultText.Replace('\n', ' ');
                        string seedMsg = "ZSeed: " + zoneSeed + "    MSeed: " + newContext.Seed;
                        //Console.WriteLine(state);

                        key = ExampleDebug.PrintTiles(context, state + "\n" + "Arrow Keys=Navigate|Enter=Retry|ESC=Back|F2=Stress Test|F3=Custom Seed|F4=Step In" + "\n" + seedMsg, true, true, true);
                    }
                    catch (Exception ex)
                    {
                        DiagManager.Instance.LogInfo("ERROR at F" + floorIndex.ID + " SEED:" + zoneSeed);
                        PrintError(ex);
                        Console.WriteLine("Press Enter to retry error scenario.");
                        key            = Console.ReadKey().Key;
                        threwException = true;
                    }


                    if (key == ConsoleKey.Escape)
                    {
                        Registry.SetValue(DiagManager.REG_PATH, "SeedChoice", "");
                        break;
                    }
                    else if (key == ConsoleKey.F2)
                    {
                        while (true)
                        {
                            Console.Clear();
                            Console.WriteLine(state + ">Bulk Gen");
                            Console.WriteLine("Specify amount to bulk gen");
                            int amt = GetInt(false);
                            if (amt > -1)
                            {
                                Console.WriteLine("Generating floor " + amt + " times.");
                                StressTestFloor(structure, zoneIndex, floorIndex, amt);
                                ConsoleKeyInfo afterKey = Console.ReadKey();
                                if (afterKey.Key == ConsoleKey.Escape)
                                {
                                    break;
                                }
                            }
                            else if (amt == -1)
                            {
                                break;
                            }
                        }
                    }
                    else if (key == ConsoleKey.F3)
                    {
                        Console.Clear();
                        Console.WriteLine(state + ">Custom Seed");
                        Console.WriteLine("Specify a ZONE seed value");
                        string input = Console.ReadLine();
                        ulong  customSeed;
                        if (UInt64.TryParse(input, out customSeed))
                        {
                            zoneSeed = customSeed;
                        }
                    }
                    else if (key == ConsoleKey.F4)
                    {
                        ExampleDebug.SteppingIn = true;
                    }
                    else if (key == ConsoleKey.Enter)
                    {
                        if (!threwException)
                        {
                            zoneSeed = MathUtils.Rand.NextUInt64();
                        }
                    }
                    Registry.SetValue(DiagManager.REG_PATH, "SeedChoice", zoneSeed.ToString());
                }
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogInfo("ERROR at F" + floorIndex.ID + " ZSEED:" + zoneSeed);
                PrintError(ex);
                Registry.SetValue(DiagManager.REG_PATH, "SeedChoice", "");
                Console.ReadKey();
            }
        }