예제 #1
0
    // Update is called once per frame
    void Update()
    {
        point = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);

        if (Input.GetKeyDown(KeyCode.B))
        {
            string s = Shape.Render(Shape.RotationMaxtrix(CtrlData.Cube_3, roll));
            Debug.Log(s);
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            int[,] type10 = new int[1, 1]
            {
                { 1 },
            };

            //  string ss = Shape.Render(Shape.RotationMaxtrix(type10, i));

            type = CtrlGamePlay.Ins.MatrixToType(type10);


            //  type =  CtrlGamePlay.Ins.MatrixToType(type10);
            //   isCorrect = CtrlGamePlay.Ins.isTypeOf(TypeShape.crossBar_3,Shape.Clone(type10));



            //  roll = CtrlGamePlay.RollShape(type, type1);
        }
        Vector2 pos = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);

        row    = (int)pos.x;
        column = (int)pos.y;
        // isCorrect = CtrlGamePlay.IsPushShapeCorrect(CtrlGamePlay.Ins.Board,row, column);
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (ClickUI.clickPause)
        {
            return;
        }
        if (GameManager.Ins.isGamePause || GameManager.Ins.isGameOver)
        {
            return;
        }
        Point = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);

        if (SpriteUse != null)
        {
            if (!SpriteUse.enabled)
            {
                SpriteUse.enabled = true;
            }
        }

        PushToBoard();

        if (Input.GetKeyDown(KeyCode.W))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }

        if (isClick)
        {
            Vector3 pos = PosTarget;

            pos.x = Mathf.Clamp(pos.x, ClampMoveMinX, ClampMoveMaxX);

            PosTarget = pos;

            transform.position = Vector3.MoveTowards(transform.position, PosTarget, Time.deltaTime * Speed);
        }
        if (ListShape.Count <= 0)
        {
            DestroyAllCubeAndShape();
        }
        if (isMovingDown)
        {
            Vector3 pos = transform.position;

            pos.y = Mathf.MoveTowards(pos.y, ClampMoveDown, Time.deltaTime * CtrlGamePlay.Ins.SpeedMoveDown + Time.deltaTime);

            transform.position = pos;
            if (transform.position.y <= ClampMoveDown)
            {
                int offset = Mathf.RoundToInt((CtrlGamePlay.Ins.initPoint.y - transform.position.y) / CtrlGamePlay.Ins.offsetY);
                transform.position = new Vector2(transform.position.x, CtrlGamePlay.Ins.initPoint.y - offset * CtrlGamePlay.Ins.offsetY);


                isMovingDown = false;
            }
        }
    }
예제 #3
0
    public void InitPoint()
    {
        isClick  = true;
        m_isMove = true;
        posInit  = transform.position;

        PointInitCheck = CtrlGamePlay.PositonToPointMatrix(transform.position.x, transform.position.y);
        //   CtrlGamePlay.Ins.TextPointInit.text = "Init : " + PointInitCheck.x + "  " + PointInitCheck.y;
    }
예제 #4
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);
        //}
    }
    private void Awake()
    {
        if (Ins != null)
        {
            Destroy(gameObject);
        }
        else
        {
            Ins = this;
        }



        eventRestGamePlay += ResetGamePlay;
        eventResetGame    += RestGame;
    }
예제 #6
0
    public void Snap_1()
    {
        //for(int i = 0; i < ListShape.Count; i++)
        //{

        //   var a = ListShape[i].GetComponent<DestroySelf>();
        //   Vector2 point  = a.Point;
        //   Vector2 pos = CtrlGamePlay.MatrixToPoint((int)point.x, (int)point.y);
        //   a.transform.position = pos;
        //}
        Vector2 pos   = transform.position;
        Vector2 point = CtrlGamePlay.PositonToMatrix(pos.x, pos.y);

        //  Debug.Log("POS SNAP "+point.ToString());
        transform.position = new Vector3(CtrlGamePlay.Ins.initPoint.x + point.x * CtrlGamePlay.Ins.offsetX, pos.y);
        //  Debug.Log("POSITON SNAP : "+ CtrlGamePlay.MatrixToPoint((int)point.x, (int)point.y));
        //  Debug.Log("POSITON SNAP : "+ CtrlGamePlay.MatrixToPoint((int)point.x, (int)point.y));
    }
예제 #7
0
    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);
    }
예제 #8
0
    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);
    }
예제 #9
0
    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);
    }
예제 #10
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);
    }
예제 #11
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);
    }
예제 #12
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;
            }
        }
    }