public List<Region> GetInterestRegion(Region pointRegion) { List<Region> listResult = new List<Region>(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { int checkX = pointRegion.x + x; int checkY = pointRegion.y + y; if (checkX >= 0 && checkX < NumberRegionVerAndHor && checkY >= 0 && checkY < NumberRegionVerAndHor) { listResult.Add(Region.arrRegion[checkX, checkY]); } } } return listResult; }
public void InitRegion() { Region.arrRegion = new Region[NumberRegionVerAndHor, NumberRegionVerAndHor]; for (int x = 0; x < NumberRegionVerAndHor; x++) { for (int y = 0; y < NumberRegionVerAndHor; y++) { Region region = new Region() { x = x, y = y }; Region.arrRegion[x, y] = region; } } }