Exemple #1
0
        public static void StressTestFloor(ZoneSegmentBase structure, int zoneIndex, SegLoc floorIndex, int amount)
        {
            ExampleDebug.Printing = -1;
            ulong zoneSeed = 0;

            try
            {
                Dictionary <int, int> generatedItems   = new Dictionary <int, int>();
                Dictionary <int, int> generatedEnemies = new Dictionary <int, int>();
                List <TimeSpan>       generationTimes  = new List <TimeSpan>();
                Stopwatch             watch            = new Stopwatch();

                for (int ii = 0; ii < amount; ii++)
                {
                    zoneSeed = MathUtils.Rand.NextUInt64();

                    ZoneGenContext zoneContext = CreateZoneGenContext(zoneSeed, zoneIndex, floorIndex, structure);

                    TestFloor(watch, structure, zoneContext, generatedItems, generatedEnemies, generationTimes);
                }

                PrintContentAnalysis(generatedItems, generatedEnemies);

                PrintTimeAnalysis(generationTimes);
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogInfo("ERROR: " + zoneSeed);
                PrintError(ex);
            }
            finally
            {
                ExampleDebug.Printing = 0;
            }
        }
Exemple #2
0
        public static ZoneGenContext CreateZoneGenContext(ulong zoneSeed, int zoneIndex, SegLoc floorIndex, ZoneSegmentBase structure)
        {
            ReNoise totalNoise = new ReNoise(zoneSeed);

            ulong[]        doubleSeed = totalNoise.GetTwoUInt64((ulong)floorIndex.Segment);
            ZoneGenContext newContext = CreateZoneGenContextSegment(doubleSeed[0], zoneIndex, floorIndex.Segment, structure);

            INoise idNoise = new ReNoise(doubleSeed[1]);

            newContext.CurrentID = floorIndex.ID;
            newContext.Seed      = idNoise.GetUInt64((ulong)floorIndex.ID);

            return(newContext);
        }
Exemple #3
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();
            }
        }
Exemple #4
0
 protected DestState(DestState other)
 {
     Dest = other.Dest; Relative = other.Relative;
 }
Exemple #5
0
 public DestState(SegLoc dest, bool relative)
 {
     Dest = dest; Relative = relative;
 }
Exemple #6
0
 public DestState(SegLoc dest)
 {
     Dest = dest;
 }