public List <List <int> > CutColumn(int[,] matrix) { List <List <int> > ListColumn = new List <List <int> >(); for (int i = 0; i < matrix.GetLength(1); i++) { List <int> Column = new List <int>(); for (int j = 0; j < matrix.GetLength(0); j++) { Column.Add(matrix[j, i]); } ListColumn.Add(Column); } Debug.Log("COLUM"); for (int i = 0; i < ListColumn.Count; i++) { Debug.Log(CtrlGamePlay.RenderList(ListColumn[i])); } return(ListColumn); }
public List <int[, ]> SplitRowMatrix(int[,] matrixs, int[] row, ref List <int> listpoint) { List <int> point = new List <int>(); List <List <int> > ListRow = CutRow(matrixs); Debug.Log("CUT ROW"); for (int i = 0; i < ListRow.Count; i++) { // Debug.Log(CtrlGamePlay.RenderList(ListRow[i])); } List <int[, ]> ListMatrix = new List <int[, ]>(); List <int> Flag = SetUpFlag(matrixs.GetLength(0), row); for (int i = 0; i < ListRow.Count; i++) { // Debug.Log(CtrlGamePlay.RenderList(Flag)); } Debug.Log(ListRow.Count + " " + Flag.Count); List <int[, ]> matrix = new List <int[, ]>(); List <List <int> > Row = new List <List <int> >(); point.Add(0); for (int i = 0; i < Flag.Count; i++) { if (Flag[i] == -1) { if (Row.Count != 0) { ListMatrix.Add(ListToMatrix(Row)); Row = new List <List <int> >(); } Row.Add(ListRow[i]); ListMatrix.Add(ListToMatrix(Row)); Row = new List <List <int> >(); if (!point.Contains(i)) { point.Add(i); if (i + 1 < Flag.Count) { if (!point.Contains(i + 1)) { point.Add(i + 1); } } } else { if (i + 1 < Flag.Count) { if (!point.Contains(i + 1)) { point.Add(i + 1); } } } } else { Row.Add(ListRow[i]); } } if (Row.Count != 0) { ListMatrix.Add(ListToMatrix(Row)); } Debug.Log("RENDER SPLIT POINT ROW : " + CtrlGamePlay.RenderList(point)); listpoint = point; return(ListMatrix); }
public List <int[, ]> SplitColumnMatrix(int[,] matrixs, int[] column, ref List <int> point) { List <int> ListPointRow = new List <int>(); List <int> ListPointColumn = new List <int>(); ListPointRow.Add(0); ListPointColumn.Add(0); List <int> ListPoint = new List <int>(); List <List <int> > ListColumn = CutColumn(matrixs); List <int[, ]> ListMatrix = new List <int[, ]>(); List <int> Flag = SetUpFlag(matrixs.GetLength(1), column); Debug.Log(CtrlGamePlay.RenderList(Flag)); List <int[, ]> matrix = new List <int[, ]>(); List <List <int> > Column = new List <List <int> >(); ListPoint.Add(0); for (int i = 0; i < Flag.Count; i++) { if (Flag[i] == -1) { if (Column.Count != 0) { ListMatrix.Add(ListColumToMatrix(Column)); Column = new List <List <int> >(); } { Column.Add(ListColumn[i]); ListMatrix.Add(ListColumToMatrix(Column)); Column = new List <List <int> >(); } if (!ListPoint.Contains(i)) { ListPoint.Add(i); if (i + 1 < Flag.Count) { if (!ListPoint.Contains(i + 1)) { ListPoint.Add(i + 1); } } } else { if (!ListPoint.Contains(i + 1)) { if (i + 1 < Flag.Count) { ListPoint.Add(i + 1); } } } if (Column.Count != 0) { ListMatrix.Add(ListColumToMatrix(Column)); Column = new List <List <int> >(); } } else { Column.Add(ListColumn[i]); } } if (Column.Count != 0) { ListMatrix.Add(ListColumToMatrix(Column)); } Debug.Log(ListMatrix.Count); for (int i = 0; i < ListMatrix.Count; i++) { Debug.Log(CtrlGamePlay.Render(ListMatrix[i])); } point = ListPoint; return(ListMatrix); }