static LevelConfig ParseToLevel() { var level = new LevelConfig(); level.Init(); for (int row = 0; row < LevelConfig.HeightCells; row++) { for (int col = LevelConfig.WidthCells - 1; col >= 0; col--) { TileState state; switch (mat[col, row]) { case 2: state = TileState.Obstacle; break; case 3: state = TileState.Start; level.startX = col; level.startY = row; break; case 4: state = TileState.Target; level.targetX = col; level.targetY = row; break; case 0: case 1: default: state = TileState.Free; break; } level.SetValue(col, row, (int)state); } } return(level); }