Exemplo n.º 1
0
        // Start is called before the first frame update
        void Start()
        {
            timer_nextUpdate = 0;

            mazeMap         = new CellArray2D_BitArray(xSize, ySize, 2);
            generateProcess = new Process_2DGenerateBacktrack(mazeMap, 0, 0);
            printProcess    = new Process_2DPrintByCurrCell(mazeMap, (Process_2DGenerateBacktrack)generateProcess, cellSpacing, cellValParentObj, currentLocationParentObj, cellValPrintPrefab, currentLocationPrefab);

            generateCouldStep = !generateOnStartup;

            if (generateOnStartup)
            {
                generateProcess.RunWhileHasSteps();
                RePrintMapObjects();
#if LOG_DEBUG
                Debug.Log(mazeMap.ToString());
#endif
            }
            else
            {
                if (printMaze)
                {
                    printProcess.FirstPrint();
                }
            }
        }
Exemplo n.º 2
0
        private void Update()
        {
            if (!shouldUpdate)
            {
                return;
            }
            if (!generateCouldStep)
            {
                return;
            }

#if STOPWATCH
            if (!watch.IsRunning)
            {
                watch.Start();
            }
#endif

            timer_nextUpdate += Time.deltaTime;
            if (timer_nextUpdate < timeBetweenUpdates)
            {
                return;
            }
            timer_nextUpdate -= timeBetweenUpdates;

            for (int i = 0; i < stepsPerUpdate; i++)
            {
                if (printMaze)
                {
                    printProcess.RunProcess();
                }

                generateCouldStep = generateCouldStep && generateProcess.RunProcess();

                if (!generateCouldStep)
                {
#if LOG_DEBUG
                    Debug.Log(mazeMap.ToString());
#endif
#if STOPWATCH
                    Debug.Log($"Execution Time: {watch.ElapsedMilliseconds} ms");
#endif
                    mazeMap = null;
                    break;
                }
            }
        }