Esempio n. 1
0
    private void Awake()
    {
        // initialize
        mazePopulator = gameObject.AddComponent <MazePopulator>();

        // Obtain seeds
        string seedDataFilePathBase = Application.streamingAssetsPath + "/SeedData/mazeDifficultySeeds";
        string creatorName          = "";

        switch (mazeShape)
        {
        case 0: { creatorName = (new MazeFrameCreatorSquare3D(mazeSize)).GetType().FullName + "-" + mazeSize.ToString() + "-" + mazeScale.ToString(); break; }

        case 1: { creatorName = (new MazeFrameCreatorMeshIcosahedron(nDivisions)).GetType().FullName + "-" + nDivisions.ToString() + "-" + mazeScale.ToString(); break; }
        }

        if (nQuadrants != 0)
        {
            seedData = new SeedData[nQuadrants];
            for (int i = 0; i < nQuadrants; i++)
            {
                string seedDataFilePath = seedDataFilePathBase + "-" + creatorName + "-" + "quadrant" + (i + 1) + "of" + nQuadrants + ".json";
                seedData[i] = SeedDataController.LoadSeedData(seedDataFilePath);
            }
        }
        else
        {
            string seedDataFilePath = seedDataFilePathBase + "-" + creatorName + ".json";
            seedData = new SeedData[1] {
                SeedDataController.LoadSeedData(seedDataFilePath)
            };
        }

        for (int i = 0; i < seedData.Length; i++)
        {
            foreach (int diff in difficulties)
            {
                if (diff > (seedData[i].seeds.Length - 1))
                {
                    throw new System.Exception("Difficulty level not present in seeds");
                }
            }
        }
    }
Esempio n. 2
0
    private void Awake()
    {
        CreateSingleton();

        if (forcedMazeSeed != 0)
        {
            Random.InitState(forcedMazeSeed);
        }

        startPos = new Vector2Int(Random.Range(0, width), Random.Range(0, height));
        maze     = GenerateMaze(width, height, adjacentCellChance, startPos);
        mazeData = new CellData[width, height];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                mazeData[x, y] = new CellData();
            }
        }

        mazePopulator = new MazePopulator(maze, mazeData, startPos);
    }