Exemple #1
0
        public void OnJSONGenerate()
        {
            if (m_BlockInput)
            {
                return;
            }

            m_BlockInput    = true;
            m_Messages.text = "Generating JSON file...";



            string nameMaze = "Maze_0";

            if (!string.IsNullOrEmpty(m_NameJSONFile.text))
            {
                nameMaze = m_NameJSONFile.text;
            }

            string outputName, outputPath;

            MazeJSONTool.CheckMazeJSONFile(nameMaze, out outputName, out outputPath);
            m_Messages.text = "JSON will be saved in " + outputPath;
            m_JSONPath      = outputPath;


            // Columns and rows
            int nCols    = 5;
            int nRows    = 5;
            int auxParse = 0;

            if (int.TryParse(m_NumberColumnsInput.text, out auxParse))
            {
                if (auxParse > 0)
                {
                    nCols = auxParse;
                }
            }

            if (int.TryParse(m_NumberRownsInput.text, out auxParse))
            {
                if (auxParse > 0)
                {
                    nRows = auxParse;
                }
            }

            //MazeGenerator.Instance.GenerateRandomDataMaze(outputName, nCols, nRows);
            //MazeGenerator.Instance.OnEndGenerateJSONMaze += MazeGenerator_OnEndGenerateJSONMaze;


            // TEST CORRIDORS

            /*List<IVector2> path = new List<IVector2>() { new IVector2(3,2), new IVector2(3, 1), new IVector2(3, 0), new IVector2(4, 0), new IVector2(5,0),
             *              new IVector2(5,1), new IVector2(5,2), new IVector2(6,2), new IVector2(6,3), new IVector2(6,4), new IVector2(5,4), new IVector2(5,5),
             *              new IVector2(4,5), new IVector2(3,5),new IVector2(2,5),new IVector2(2,4), new IVector2(2,3), new IVector2(1,3), new IVector2(1,4),
             *              new IVector2(0,4), new IVector2(0,3), new IVector2(0,2), new IVector2(0,1), new IVector2(0,0), new IVector2(1,0), new IVector2(2,0),
             *              new IVector2(2,1), new IVector2(2,2)};
             * MazeGenerator.Instance.GenerateDataMazeByPath("TestCorridor", 7, 6, path);*/

            List <IVector2> path = new List <IVector2>()
            {
                new IVector2(0, 0), new IVector2(0, 1), new IVector2(1, 1), new IVector2(1, 2),
                new IVector2(2, 2), new IVector2(3, 2), new IVector2(3, 1), new IVector2(3, 0),
                new IVector2(2, 0), new IVector2(1, 0)
            };

            MazeGenerator.Instance.GenerateDataMazeByPath(nameMaze, 4, 3, path);
            MazeGenerator.Instance.OnEndGenerateJSONMaze += MazeGenerator_OnEndGenerateJSONMaze;
        }