List <List <int> > GetListFromBoolean2D(Boolean2D pArray) { List <List <int> > mapList = new List <List <int> >(); for (int i = 0; i < mapSize; i++) { for (int j = 0; j < mapSize; j++) { bool value; if (pArray.GetElement(i, j, out value) && !value) { mapList.Add(null); continue; } List <int> resultList = new List <int>(); AddResult(i - 1, j, resultList, pArray, 0); AddResult(i, j + 1, resultList, pArray, 2); AddResult(i + 1, j, resultList, pArray, 4); AddResult(i, j - 1, resultList, pArray, 6); if (useObliqueLine) { AddResult(i - 1, j + 1, resultList, pArray, 1); AddResult(i + 1, j + 1, resultList, pArray, 3); AddResult(i + 1, j - 1, resultList, pArray, 5); AddResult(i - 1, j - 1, resultList, pArray, 7); } mapList.Add(resultList); } } return(mapList); }
void AddResult(int i, int j, List <int> list, Boolean2D pArray, int result) { bool value; if (pArray.GetElement(i, j, out value) && value) { list.Add(result); } }