Пример #1
0
        void Start()
        {
            string file = EditorUtility.OpenFilePanel("Seleccionar nivel", "", "txt");

            StreamReader archivo = new StreamReader(file); // NOMBRE DEL ARCHIVO

            string mensaje = archivo.ReadLine();           // Linea que se graba en el archivo

            string tamañoMatriz = mensaje;

            int bandera = 0;

            List <string> datosFilas    = new List <string>();
            List <string> datosColumnas = new List <string>();

            while (mensaje != null)
            {
                if (mensaje == "FILAS")
                {
                    bandera = 1;
                }
                if (mensaje == "COLUMNAS")
                {
                    bandera = 2;
                }

                if (bandera == 1)
                {
                    datosFilas.Add(mensaje);
                }
                if (bandera == 2)
                {
                    datosColumnas.Add(mensaje);
                }
                mensaje = archivo.ReadLine();
            }

            archivo.Close();  // Cerrar el archivo

            tablero = new Matriz(datosFilas, datosColumnas, tamañoMatriz);

            mBoard.Create(file);

            tablero.porPintar = mBoard.mAllCells;

            tablero.animado = false;

            tablero.B(0, 0);
        }
Пример #2
0
        static void Main(string[] args)
        {
            StreamReader archivo = new StreamReader("2x3.txt"); // NOMBRE DEL ARCHIVO

            string mensaje = archivo.ReadLine();                // Linea que se graba en el archivo

            string tamañoMatriz = mensaje;

            int bandera = 0;

            List <string> datosFilas    = new List <string>();
            List <string> datosColumnas = new List <string>();

            while (mensaje != null)
            {
                if (mensaje == "FILAS")
                {
                    bandera = 1;
                }
                if (mensaje == "COLUMNAS")
                {
                    bandera = 2;
                }

                if (bandera == 1)
                {
                    datosFilas.Add(mensaje);
                }
                if (bandera == 2)
                {
                    datosColumnas.Add(mensaje);
                }
                mensaje = archivo.ReadLine();
            }

            archivo.Close();  // Cerrar el archivo


            Matriz tablero = new Matriz(datosFilas, datosColumnas, tamañoMatriz);

            //Console.WriteLine(tablero.validar2(1, 2));

            tablero.B(0, 0);
        }