示例#1
0
 public void PencilClick()
 {
     theCounter = counterStart;
     PencilOn   = !PencilOn;
     UpdateUI();
     UpdateAllBlockUI();
     SudokuGameManager.PlaySound(PencilOn ? pencilOnClip : pencilOffClip);
 }
示例#2
0
    // Save date, time and level of a completed game into a json file
    private void SaveResultToFile()
    {
        SudokuResult result = new SudokuResult()
        {
            date  = System.DateTime.Now.ToShortDateString(),
            time  = SudokuGameManager.GetTimeString(SudokuGameManager.GameTime),
            level = SudokuGameManager.GameMode.ToString()
        };

        string jsonResult = JsonUtility.ToJson(result);

        File.WriteAllText(Application.dataPath + "/sudoku_results.txt", jsonResult);
        Debug.Log("Sudoku result saved");
    }
示例#3
0
    public void SetNumber(int i)
    {
        theCounter = counterStart;
        if (CurrentSelected != null && CurrentSelected.canEdit)
        {
            if (PencilOn)
            {
                SudokuGameManager.PlaySound(editNoteClip);
                AddState(CurrentSelectedIndex, CurrentSelected.num, CurrentSelected.hintNum);
                CurrentSelected.num            = 0;
                CurrentSelected.hintNum[i - 1] = !CurrentSelected.hintNum[i - 1];
            }
            else if (CurrentSelected.num != i)
            {
                SudokuGameManager.PlaySound(editValueClip);
                var state = AddState(CurrentSelectedIndex, CurrentSelected.num, CurrentSelected.hintNum);

                CurrentSelected.num     = i;
                CurrentSelected.hintNum = new bool[9];
                if (SudokuGameManager.AutoRemoveNotes)
                {
                    List <Block> blockList = new List <Block>();
                    blockList.AddRange(CurrentSelected.rowList);
                    blockList.AddRange(CurrentSelected.colList);
                    blockList.AddRange(CurrentSelected.boxList);

                    foreach (var block in blockList)
                    {
                        if (block.hintNum[i - 1])
                        {
                            state.AddBlockState(blocks.IndexOf(block), block.num, block.hintNum);
                            block.hintNum[i - 1] = false;
                        }
                    }
                }
            }

            SaveSudoku();
            UpdateAllBlockUI();
        }
    }
示例#4
0
 public void UpdateTimeUI()
 {
     timeLable.text = SudokuGameManager.GetTimeString(SudokuGameManager.GameTime);
 }
示例#5
0
 public void playSound(AudioClip clip)
 {
     SudokuGameManager.PlaySound(clip);
 }
示例#6
0
    IEnumerator ShowGameOverPopup()
    {
        SudokuGameManager.IsGamePause = true;
        int c = CurrentSelectedIndex % 9;
        int r = CurrentSelectedIndex / 9;

        DeSelectAll();
        for (int i = 0; i < 9; i++)
        {
            for (int a = r - i, b = c - i; b <= c + i; b++)
            {
                if (a >= 0 && b >= 0 && a < 9 && b < 9)
                {
                    BlockAnimUpperBg(a * 9 + b);
                }
            }
            for (int a = r + i, b = c - i; b <= c + i; b++)
            {
                if (a >= 0 && b >= 0 && a < 9 && b < 9)
                {
                    BlockAnimUpperBg(a * 9 + b);
                }
            }
            for (int a = r - i, b = c - i; a <= r + i; a++)
            {
                if (a >= 0 && b >= 0 && a < 9 && b < 9)
                {
                    BlockAnimUpperBg(a * 9 + b);
                }
            }
            for (int a = r - i, b = c + i; a <= r + i; a++)
            {
                if (a >= 0 && b >= 0 && a < 9 && b < 9)
                {
                    BlockAnimUpperBg(a * 9 + b);
                }
            }
            yield return(new WaitForSeconds(.05f));
        }
        if (SudokuGameManager.GameTime <= SudokuGameManager.HighScoreTime)
        {
            SudokuGameManager.HighScoreTime = SudokuGameManager.GameTime;
        }

        yield return(new WaitForSeconds(0.7f));

        LeanTween.alphaCanvas(gameCompletedDailog, 1, 0.1f);
        gameCompletedDailog.GetComponent <Animator>().Play("GameOver");
        SudokuGameManager.PlaySound(gameWinClip);
        gameCompletedDailog.blocksRaycasts = true;
        timeLbl.text     = SudokuGameManager.GetTimeString(SudokuGameManager.GameTime);
        bestTimeLbl.text = SudokuGameManager.GetTimeString(SudokuGameManager.HighScoreTime);
        modeLbl.text     = SudokuGameManager.GameMode.ToString();

        SaveResultToFile();

        Timer.Schedule(this, 0.6f, () =>
        {
            CUtils.ShowInterstitialAd();
        });
    }