コード例 #1
0
        public void Analyze()
        {
            bool isValid = false;

            if (DungeonFlow == null)
            {
                Debug.LogError("No DungeonFlow assigned to analyzer");
            }
            else if (Iterations <= 0)
            {
                Debug.LogError("Iteration count must be greater than 0");
            }
            else if (MaxFailedAttempts <= 0)
            {
                Debug.LogError("Max failed attempt count must be greater than 0");
            }
            else
            {
                isValid = true;
            }

            if (!isValid)
            {
                return;
            }

            prevShouldRandomizeSeed = generator.ShouldRandomizeSeed;

            generator.IsAnalysis          = true;
            generator.DungeonFlow         = DungeonFlow;
            generator.MaxAttemptCount     = MaxFailedAttempts;
            generator.ShouldRandomizeSeed = true;
            analysis            = new GenerationAnalysis(Iterations);
            analysisTime        = Stopwatch.StartNew();
            remainingIterations = targetIterations = Iterations;

            generator.OnGenerationStatusChanged += OnGenerationStatusChanged;
            generator.Generate();
        }
コード例 #2
0
        private void OnGUI()
        {
            generator.DungeonFlow     = (DungeonFlow)EditorGUILayout.ObjectField("Dungeon Flow", generator.DungeonFlow, typeof(DungeonFlow), false);
            generator.MaxAttemptCount = EditorGUILayout.IntField("Max Failed Attempts", generator.MaxAttemptCount);
            iterationCount            = EditorGUILayout.IntField("Iterations", iterationCount);
            maximumAnalysisTime       = EditorGUILayout.FloatField("Max Analysis Time (sec)", maximumAnalysisTime);

            if (GUILayout.Button("Generate"))
            {
                analysis = generator.RunAnalysis(iterationCount, maximumAnalysisTime * 1000);
            }

            if (analysis == null)
            {
                return;
            }

            EditorGUILayout.BeginVertical("box");

            EditorGUILayout.LabelField("Dungeon successfully generated: " + Mathf.RoundToInt(analysis.SuccessPercentage).ToString() + "%");

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            DrawNumberSetData("Main Path Room Count", analysis.MainPathRoomCount);
            DrawNumberSetData("Branch Path Room Count", analysis.BranchPathRoomCount);
            DrawNumberSetData("Total Room Count", analysis.TotalRoomCount);
            DrawNumberSetData("Max Branch Depth", analysis.MaxBranchDepth);
            DrawNumberSetData("Retry Count", analysis.TotalRetries);

            DrawNumberSetData("Pre-Process Time", analysis.PreProcessTime);
            DrawNumberSetData("Main Path Generation Time", analysis.MainPathGenerationTime);
            DrawNumberSetData("Branch Path Generation Time", analysis.BranchPathGenerationTime);
            DrawNumberSetData("Post-Process Time", analysis.PostProcessTime);
            DrawNumberSetData("Total Time", analysis.TotalTime);

            EditorGUILayout.EndVertical();
        }
コード例 #3
0
        public void Analyze()
        {
            bool isValid = false;

            if (DungeonFlow == null)
            {
                Debug.LogError("No DungeonFlow assigned to analyzer");
            }
            else if (Iterations <= 0)
            {
                Debug.LogError("Iteration count must be greater than 0");
            }
            else if (MaxFailedAttempts <= 0)
            {
                Debug.LogError("Max failed attempt count must be greater than 0");
            }
            else
            {
                isValid = true;
            }

            if (!isValid)
            {
                return;
            }

            prevShouldRandomizeSeed = generator.ShouldRandomizeSeed;

            generator.isAnalysis          = true;
            generator.DungeonFlow         = DungeonFlow;
            generator.MaxAttemptCount     = MaxFailedAttempts;
            generator.ShouldRandomizeSeed = true;
            analysis     = new GenerationAnalysis(Iterations);
            analysisTime = 0;

            currentIterations = 0;
            targetIterations  = Iterations;
        }