private void fillTheTrianglarArea(int[,] mapCopy) { for (int i = 0; i < X_RANGE; i++) { int buttomRow = -1; // impossible index: -1 int upperRow = -1; for (int j = 0; j < Y_RANGE; j++) { if (buttomRow != -1) { if (mapCopy[i, j] == CHECKED_AREA_EDGE) { upperRow = j; } } else { if (mapCopy[i, j] == CHECKED_AREA_EDGE) { buttomRow = j; } } } if (buttomRow != -1 && upperRow != -1) // pass two edge through this vertical line { for (int k = buttomRow; k <= upperRow; k++) { if (map[i, k] == UNLABEL) { map[i, k] = CHECKED; demoGraph.drawCheckedArea(i + 25, k + 50); } } } else if (buttomRow != -1 && upperRow == -1) // the vertex of trianglar { if (map[i, buttomRow] == UNLABEL) { map[i, buttomRow] = CHECKED; demoGraph.drawCheckedArea(i + 25, buttomRow + 50); } } } }
public GridMap() { demoGraph = GameObject.FindGameObjectWithTag("Player").GetComponent <RRTDrawer>(); map = new int[450, 350]; for (int i = 5; i <= 45; i++) { for (int j = 5; j <= 45; j++) { map[i, j] = CHECKED; demoGraph.drawCheckedArea(i + 25, j + 50); } } }