public static int[,] RotationMaxtrix(int[,] Matrix, int countRoll) { int[,] cloneMatrix = CtrlGamePlay.CloneBoard(Matrix); int[,] MatrixRotaion = new int[cloneMatrix.GetLength(0), cloneMatrix.GetLength(1)]; int count = 4; for (int x = 0; x < countRoll; x++) { count = 4; for (int i = 0; i < 4; i++) { count--; for (int j = 0; j < 4; j++) { MatrixRotaion[i, j] = cloneMatrix[j, count]; } } cloneMatrix = CtrlGamePlay.CloneBoard(MatrixRotaion); } return(cloneMatrix); }
public List <int[, ]> SplitMatrix(int[,] matrix, int[] row1, int[] col1) { int[,] type = CtrlGamePlay.CloneBoard(matrix); List <int[, ]> ListRowtMatrix = new List <int[, ]>(); List <int[, ]> ListColumnMatrix = new List <int[, ]>(); List <int[, ]> TotalMatrix = new List <int[, ]>(); List <int> ListPointRow = new List <int>(); List <int> ListPointColumn = new List <int>(); ListPointRow.Add(0); ListPointColumn.Add(0); List <List <int[, ]> > ListColumMatrix_1 = new List <List <int[, ]> >(); if (row1 != null) { ListRowtMatrix = SplitRowMatrix(type, row1, ref ListPointRow); for (int i = 0; i < ListRowtMatrix.Count; i++) { Debug.Log("Split Row"); Debug.Log(CtrlGamePlay.Render(ListRowtMatrix[i])); } } if (ListRowtMatrix.Count != 0 && col1 != null) { for (int i = 0; i < ListRowtMatrix.Count; i++) { Debug.Log("Split Col"); ListColumMatrix_1.Add(SplitColumnMatrix(ListRowtMatrix[i], col1, ref ListPointColumn)); } for (int j = 0; j < ListColumMatrix_1.Count; j++) { for (int k = 0; k < ListColumMatrix_1[j].Count; k++) { Debug.Log(CtrlGamePlay.Render(ListColumMatrix_1[j][k])); } } if (ListColumMatrix_1.Count != 0) { for (int j = 0; j < ListColumMatrix_1.Count; j++) { for (int k = 0; k < ListColumMatrix_1[j].Count; k++) { ListColumnMatrix.Add(ListColumMatrix_1[j][k]); } } } for (int i = 0; i < ListColumnMatrix.Count; i++) { TotalMatrix.Add(ListColumnMatrix[i]); } } else if (col1 != null) { ListColumnMatrix = SplitColumnMatrix(type, col1, ref ListPointColumn); for (int i = 0; i < ListColumnMatrix.Count; i++) { TotalMatrix.Add(ListColumnMatrix[i]); } List <Vector2> Points = new List <Vector2>(); } else if (row1 != null) { for (int i = 0; i < ListRowtMatrix.Count; i++) { TotalMatrix.Add(ListRowtMatrix[i]); } } else { TotalMatrix.Add(type); } List <Vector2> ListPoint = GrounpPoint(ListPointRow, ListPointColumn); Debug.Log("SPLIT POINT "); for (int i = 0; i < ListPoint.Count; i++) { Debug.Log(ListPoint[i].x + " " + ListPoint[i].y); } for (int i = 0; i < TotalMatrix.Count; i++) { Debug.Log("SHAPE : " + CtrlGamePlay.Render(TotalMatrix[i])); } return(TotalMatrix); }