예제 #1
0
    public void HighlightCells(int value)
    {
        if (hl_num == value && hl_num != 0)
        {
            HighlightCells(0);
            return;
        }
        hl_num = value;
        string s = value.ToString();

        for (int y = 0; y < 9; y++)
        {
            for (int x = 0; x < 9; x++)
            {
                if (String.Equals(s, values[y, x].text) ||
                    sudokuController.IsInMemoCell(y, x, value))// 하이라이트
                {
                    var colors = btns[y, x].colors;
                    colors.disabledColor = highLightCellColor;
                    colors.normalColor   = highLightCellColor;
                    btns[y, x].colors    = colors;
                }
                else //다른 숫자 원상복구
                {
                    var colors = btns[y, x].colors;
                    colors.disabledColor = disabledColor;
                    colors.normalColor   = normalColor;
                    btns[y, x].colors    = colors;
                }
            }
        }
    }
예제 #2
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pausePanel.SetActive(true);
        }
        //클릭 시 일단 초기화

        #region arrowkeys
        if (Input.GetKeyDown(KeyCode.RightArrow) && (curX != -1 && curY != -1) && curX < 9)
        {
            for (int i = curX + 1; i < 9; i++)
            {
                if (cellManager.btns[curY, i].interactable == true)
                {
                    cellManager.btns[curY, i].Select();
                    curX = i;
                    break;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow) && (curX != -1 && curY != -1) && curX >= 0)
        {
            for (int i = curX - 1; i >= 0; i--)
            {
                if (cellManager.btns[curY, i].interactable == true)
                {
                    cellManager.btns[curY, i].Select();
                    curX = i;
                    break;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.UpArrow) && (curX != -1 && curY != -1) && curY >= 0)
        {
            for (int i = curY - 1; i >= 0; i--)
            {
                if (cellManager.btns[i, curX].interactable == true)
                {
                    cellManager.btns[i, curX].Select();
                    curY = i;
                    break;
                }
            }
        }
        if (Input.GetKeyDown(KeyCode.DownArrow) && (curX != -1 && curY != -1) && curY < 9)
        {
            for (int i = curY + 1; i < 9; i++)
            {
                if (cellManager.btns[i, curX].interactable == true)
                {
                    cellManager.btns[i, curX].Select();
                    curY = i;
                    break;
                }
            }
        }
        #endregion


        if (Input.GetMouseButtonDown(0))
        {
            curY = -1;
            curX = -1;
        }

        if (Input.GetKey(KeyCode.LeftAlt))
        {
            ManualToolsManager.onMemo = true;
        }

        if (Input.GetKeyUp(KeyCode.LeftAlt))
        {
            ManualToolsManager.onMemo = false;
        }

        if (Input.GetKey(KeyCode.LeftControl))
        {
            ty = curY;
            tx = curX;

            curY = -1;
            curX = -1;
        }

        if (Input.GetKeyUp(KeyCode.LeftControl))
        {
            curY = ty;
            curX = tx;
        }

        for (int i = 0; i < AlphaKeys.Length; i++)
        {
            if (Input.GetKeyDown(AlphaKeys[i]) || Input.GetKeyDown(KeypadKeys[i]))
            {
                if (curX != -1 && curY != -1) // 스도쿠 내부의 버튼을 선택하고 있으면
                {
                    sudokuController.RecordSudokuLog();
                    if (ManualToolsManager.onMemo)                            //memo on
                    {
                        if (sudokuController.IsInMemoCell(curY, curX, i + 1)) //메모 지워주기
                        {
                            memoManager.DeleteMemoCell(curY, curX, i + 1);
                            cellManager.HighlightCells(i + 1);
                        }
                        else //메모 쓰기
                        {
                            sudokuController.CheckNewValueNormal(curY, curX, i + 1); //정상 확인
                            memoManager.FillMemoCell(curY, curX, i + 1);
                        }
                    }
                    else // memo off
                    {
                        if (sudokuController.IsInCell(curY, curX, i + 1)) //숫자 지워주기
                        {
                            cellManager.DeleteCell(curY, curX);
                            cellManager.HighlightCells(i + 1);
                        }
                        else
                        {
                            sudokuController.CheckNewValueNormal(curY, curX, i + 1); //정상 확인

                            cellManager.FillCell(curY, curX, i + 1);

                            //Checker
                            sudokuController.FinishSudoku();

                            cellManager.HighlightCells(i + 1);
                        }
                    }
                }
                else // no cursor
                {
                    numberHighlighterManager.CallHighlightFunc(i + 1);
                }
                return;
            }
        }

        //Q를 누르면 지워짐
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (curX != -1 && curY != -1) // 스도쿠 내부의 버튼을 선택하고 있으면
            {
                cellManager.DeleteCell(curY, curX);
                memoManager.DeleteMemoCell(curY, curX);
                cellManager.HighlightCells(0);
            }
            return;
        }
    }