Esempio n. 1
0
    public void Test_1()
    {
        Debug.Log(CtrlGamePlay.Render(ConverStringToMatrix(GetSimulateRoll(TypeShape.three_cube, 0))));
        string phrase = "1 123 231 321 31 123 123 123 12";
        //string[] words = phrase.Split(' ');

        //foreach (var word in words)
        //{
        //    Debug.Log(word);
        //}
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    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);
    }
Esempio n. 4
0
    public void InitMatrixRoll()
    {
        InfoRollShape = new Dictionary <TypeShape, List <string> >();
        for (int i = 0; i < 11; i++)
        {
            InfoRollShape.Add(GetShapeType(i), new List <string>());
        }
        for (int i = 0; i < InfoRollShape.Count; i++)
        {
            switch (i)
            {
            case 0:
                string ss = "1";
                InfoRollShape[TypeShape.crossBar_1].Add(ss);
                break;

            case 1:

                for (int j = 0; j < 2; j++)
                {
                    string s1 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.crossBar_2, false)));
                    InfoRollShape[TypeShape.crossBar_2].Add(s1);
                }
                break;

            case 2:

                for (int j = 0; j < 2; j++)
                {
                    string s2 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.crossBar_3, false)));
                    InfoRollShape[TypeShape.crossBar_3].Add(s2);
                }


                break;

            case 3:

                for (int j = 0; j < 2; j++)
                {
                    string s3 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.crossBar_4, false)));
                    InfoRollShape[TypeShape.crossBar_4].Add(s3);
                }

                break;

            case 4:
                for (int j = 0; j < 4; j++)
                {
                    string s4 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.three_cube, false)));
                    InfoRollShape[TypeShape.three_cube].Add(s4);
                }

                break;

            case 5:
                for (int j = 0; j < 4; j++)
                {
                    string s5 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.L3_0, false)));
                    InfoRollShape[TypeShape.L3_0].Add(s5);
                }
                break;

            case 6:
                for (int j = 0; j < 4; j++)
                {
                    string s6 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.L3_90, false)));
                    InfoRollShape[TypeShape.L3_90].Add(s6);
                }

                break;

            case 7:
                for (int j = 0; j < 4; j++)
                {
                    string s7 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.L4_90, false)));
                    InfoRollShape[TypeShape.L4_90].Add(s7);
                }
                break;

            case 8:
                for (int j = 0; j < 4; j++)
                {
                    string s8 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.L_4_0, false)));
                    InfoRollShape[TypeShape.L_4_0].Add(s8);
                }
                break;

            case 9:
                for (int j = 0; j < 4; j++)
                {
                    string s9 = CtrlGamePlay.Render(Shape.SplitMatrix(CtrlGamePlay.SimulateRoll(j, TypeShape.T, false)));
                    InfoRollShape[TypeShape.T].Add(s9);
                }
                break;
            }
        }
    }