Пример #1
0
        public void loadMap()
        {
            if (getTank().ready())
            {
                string map = presetMap.text;

                string[] split = map.Split(new char[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                uint     rows  = (uint)Int32.Parse(split [0]);
                uint     cols  = (uint)Int32.Parse(split [1]);
                uint[,] result = new uint[rows, cols];
                Position nGoal = null;

                int index = 2;
                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < cols; j++)
                    {
                        result [i, j] = (uint)Int32.Parse(split [index]);
                        index++;
                        if (result [i, j] == 4)
                        {
                            nGoal = new Position((uint)i, (uint)j);
                        }
                    }
                }

                puzzle.rows    = rows;
                puzzle.columns = cols;
                puzzle.setMatrix(result);
                puzzle.setGoal(nGoal);
                board.Initialize(this, puzzle);

                //Inicializar tanque
                tank.Initialize(board);
                CleanInfo();
                UpdateInfo();
            }
        }