void EnablePlayerInput()
 {
     LeftButton.SetActive(true);
     RightButton.SetActive(true);
     JumpButton.SetActive(true);
     ScoreLabel.SetActive(true);
 }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (rightClicked)
        {
            RightClickTransition();
        }

        if (leftClicked)
        {
            LeftClickTransition();
        }

        if (currentPage == NumberOfPages() && !leftClicked && !rightClicked)
        {
            RightButton.SetActive(false);
            LeftButton.SetActive(true);
        }
        else if (currentPage == 0 && !leftClicked && !rightClicked)
        {
            LeftButton.SetActive(false);
            RightButton.SetActive(true);
        }
        else if (rightClicked || leftClicked)
        {
            RightButton.SetActive(false);
            LeftButton.SetActive(false);
        }
        else
        {
            RightButton.SetActive(true);
            LeftButton.SetActive(true);
        }
    }
 void DisablePlayerInput()
 {
     LeftButton.SetActive(false);
     RightButton.SetActive(false);
     JumpButton.SetActive(false);
     ScoreLabel.SetActive(false);
 }
Beispiel #4
0
    void Operate()
    {
        xy LT, RB = new xy();

        LT.x      = startPos.x < endPos.x ? startPos.x : endPos.x;
        LT.y      = startPos.y < endPos.y ? startPos.y : endPos.y;
        RB.x      = startPos.x > endPos.x ? startPos.x : endPos.x;
        RB.y      = startPos.y > endPos.y ? startPos.y : endPos.y;
        OverlayLT = LT;
        OverlayRB = RB;
        if (Oper == 1) // +
        {
            bool isable = true;
            int  cnt    = 0;
            for (int i = LT.x; i <= RB.x; i++)
            {
                for (int j = LT.y; j <= RB.y; j++)
                {
                    cnt++;
                    if (gridNow[i, j] != 0)
                    {
                        isable = false;
                    }
                }
            }
            if (isable && cnt == Num)
            {
                SavePreData();
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int j = LT.y; j <= RB.y; j++)
                    {
                        gridcs.ChangeBlockColor(i, j, color);
                    }
                }

                FinishOperate();
            }
            else
            {
                PopDisable();
            }
        }
        else if (Oper == 2) // -
        {
            bool isable = true;
            int  cnt    = 0;
            for (int i = LT.x; i <= RB.x; i++)
            {
                for (int j = LT.y; j <= RB.y; j++)
                {
                    cnt++;
                    if (gridNow[i, j] == 0)
                    {
                        isable = false;
                    }
                }
            }
            if (isable && cnt == Num)
            {
                SavePreData();
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int j = LT.y; j <= RB.y; j++)
                    {
                        gridcs.ChangeBlockColor(i, j, 0);
                    }
                }
                FinishOperate();
            }
            else
            {
                PopDisable();
            }
        }
        else if (Oper == 3) // ×
        {
            Overlay.SetActive(true);
            Direction_Button.SetActive(true);
            bool isable = true;
            for (int i = LT.x; i <= RB.x; i++)
            {
                for (int j = LT.y; j <= RB.y; j++)
                {
                    if (gridNow[i, j] == 0)
                    {
                        isable = false;
                    }
                }
            }
            if (!isable)
            {
                Overlay.SetActive(false);
                Direction_Button.SetActive(false);
                goto end;
            }

            bool isableUp, isableDown, isableLeft, isableRight;
            isableUp = isableDown = isableLeft = isableRight = true;

            //위로 가능한지 확인
            if (LT.y - (Num - 1) * (RB.y - LT.y + 1) < 0)
            {
                isableUp = false;;
            }
            else
            {
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int j = LT.y - 1; j >= LT.y - (Num - 1) * (RB.y - LT.y + 1); j--)
                    {
                        if (gridNow[i, j] != 0)
                        {
                            isableUp = false;
                        }
                    }
                }
            }

            //아래로 가능한지 확인
            if (RB.y + (Num - 1) * (RB.y - LT.y + 1) >= gridSize)
            {
                isableDown = false;;
            }
            else
            {
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int j = RB.y + 1; j <= RB.y + (Num - 1) * (RB.y - LT.y + 1); j++)
                    {
                        if (gridNow[i, j] != 0)
                        {
                            isableDown = false;
                        }
                    }
                }
            }
            //왼쪽로 가능한지 확인
            if (LT.x - (Num - 1) * (RB.x - LT.x + 1) < 0)
            {
                isableLeft = false;
            }
            else
            {
                for (int i = LT.x - 1; i >= LT.x - (Num - 1) * (RB.x - LT.x + 1); i--)
                {
                    for (int j = LT.y; j <= RB.y; j++)
                    {
                        if (gridNow[i, j] != 0)
                        {
                            isableLeft = false;
                        }
                    }
                }
            }

            //오른쪽으로 가능한지 확인

            if (RB.x + (Num - 1) * (RB.x - LT.x + 1) >= gridSize)
            {
                isableRight = false;
            }
            else
            {
                for (int i = RB.x + 1; i <= RB.x + (Num - 1) * (RB.x - LT.x + 1); i++)
                {
                    for (int j = LT.y; j <= RB.y; j++)
                    {
                        if (gridNow[i, j] != 0)
                        {
                            isableRight = false;
                        }
                    }
                }
            }


            UpButton.transform.position    = (gridViewArr[LT.x, LT.y] + gridViewArr[RB.x + 1, LT.y]) / 2f + new Vector2(0f, 50f) * ratio;
            DownButton.transform.position  = (gridViewArr[LT.x, RB.y + 1] + gridViewArr[RB.x + 1, RB.y + 1]) / 2f - new Vector2(0f, 50f) * ratio;
            LeftButton.transform.position  = (gridViewArr[LT.x, LT.y] + gridViewArr[LT.x, RB.y + 1]) / 2f - new Vector2(50f, 0f) * ratio;
            RightButton.transform.position = (gridViewArr[RB.x + 1, LT.y] + gridViewArr[RB.x + 1, RB.y + 1]) / 2f + new Vector2(50f, 0f) * ratio;
            if (isableUp || isableDown || isableLeft || isableRight)
            {
                isOverlay = true;
            }

            UpButton.SetActive(isableUp);
            DownButton.SetActive(isableDown);
            LeftButton.SetActive(isableLeft);
            RightButton.SetActive(isableRight);

            end :;
        }
        else if (Oper == 4) // ÷
        {
            Overlay.SetActive(true);
            Direction_Button_Division.SetActive(true);
            bool isable = true;
            for (int i = LT.x; i <= RB.x; i++)
            {
                for (int j = LT.y; j <= RB.y; j++)
                {
                    if (gridNow[i, j] == 0)
                    {
                        isable = false;
                    }
                }
            }
            if (!isable)
            {
                Overlay.SetActive(false);
                Direction_Button_Division.SetActive(false);
                goto end;
            }

            bool isVertical, isHorizental;
            isVertical = isHorizental = true;

            if ((RB.x - LT.x + 1) % Num != 0)
            {
                isHorizental = false;
            }
            else
            {
                for (int j = LT.y; j <= RB.y; j++)
                {
                    for (int k = 0; k < ((RB.x - LT.x + 1) / Num); k++)
                    {
                        for (int i = LT.x + ((RB.x - LT.x + 1) / Num) + k; i <= RB.x; i += ((RB.x - LT.x + 1) / Num))
                        {
                            if (gridNow[i, j] != gridNow[LT.x + k, j])
                            {
                                isHorizental = false;
                            }
                        }
                    }
                }
            }
            if ((RB.y - LT.y + 1) % Num != 0)
            {
                isVertical = false;
            }
            else
            {
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int k = 0; k < ((RB.y - LT.y + 1) / Num); k++)
                    {
                        for (int j = LT.y + ((RB.y - LT.y + 1) / Num) + k; j <= RB.y; j += ((RB.y - LT.y + 1) / Num))
                        {
                            if (gridNow[i, j] != gridNow[i, LT.y + k])
                            {
                                isVertical = false;
                            }
                        }
                    }
                }
            }

            DownButton_Division.transform.position  = (gridViewArr[LT.x, LT.y] + gridViewArr[RB.x + 1, LT.y]) / 2f - new Vector2(0f, 50f) * ratio;
            UpButton_Division.transform.position    = (gridViewArr[LT.x, RB.y + 1] + gridViewArr[RB.x + 1, RB.y + 1]) / 2f + new Vector2(0f, 50f) * ratio;
            RightButton_Division.transform.position = (gridViewArr[LT.x, LT.y] + gridViewArr[LT.x, RB.y + 1]) / 2f + new Vector2(50f, 0f) * ratio;
            LeftButton_Division.transform.position  = (gridViewArr[RB.x + 1, LT.y] + gridViewArr[RB.x + 1, RB.y + 1]) / 2f - new Vector2(50f, 0f) * ratio;
            if (isVertical || isHorizental)
            {
                isOverlay = true;
            }

            UpButton_Division.SetActive(isVertical);
            DownButton_Division.SetActive(isVertical);
            LeftButton_Division.SetActive(isHorizental);
            RightButton_Division.SetActive(isHorizental);

            end :;
        }
        else if (Oper == 5) // change_color
        {
            if (color_from != 0 && color_to != 0)
            {
                SavePreData();
                for (int i = LT.x; i <= RB.x; i++)
                {
                    for (int j = LT.y; j <= RB.y; j++)
                    {
                        if (gridNow[i, j] == color_from)
                        {
                            gridcs.ChangeBlockColor(i, j, color_to);
                        }
                    }
                }

                FinishOperate();
            }
        }
        else if (Oper == 6) // erase_line
        {
            if (is_Vertical == 1)
            {
                SavePreData();
                int i = LT.x;
                for (int j = 0; j < gridSize; j++)
                {
                    gridcs.ChangeBlockColor(i, j, 0);
                }

                FinishOperate();
            }
            else if (is_Vertical == 2)
            {
                SavePreData();
                int j = LT.y;
                for (int i = 0; i < gridSize; i++)
                {
                    gridcs.ChangeBlockColor(i, j, 0);
                }

                FinishOperate();
            }
        }
        else // ?
        {
        }
    }