示例#1
0
    void ClickMenuBtn(GameObject go)
    {
        if (!_AudioSource.isPlaying)
        {
            _AudioSource.Play();
        }
        MagicStaticValue.GetInstance()._HintCount = 10;
        switch (go.name)
        {
        case "0_Button":
            MagicStaticValue.GetInstance()._Level = 30;
            break;

        case "1_Button":
            MagicStaticValue.GetInstance()._Level = 40;
            break;

        case "2_Button":
            MagicStaticValue.GetInstance()._Level = 50;
            break;

        case "3_Button":
            MagicStaticValue.GetInstance()._Level = 60;
            break;

        case "4_Button":
            MagicStaticValue.GetInstance()._Level = 70;
            break;

        default:
            break;
        }
        MenuAnim.SetBool("IsStart", true);
        Invoke("OpenScene", 3.2f);
    }
示例#2
0
 public static MagicStaticValue GetInstance()
 {
     if (staticValue == null)
     {
         staticValue = new MagicStaticValue();
     }
     return(staticValue);
 }
示例#3
0
    void Init()
    {
        _LastSudokuBtn = null;
        fTime          = 0.0f;
        _iSteps        = 0;
        _fPercent      = 0.0f;

        _TimeText.text = "";
        _StepText.text = "0steps\n0%";
        switch (MagicStaticValue.GetInstance()._Level)
        {
        case 30:
            _TitleText.text = "Easy";
            break;

        case 40:
            _TitleText.text = "Normal";
            break;

        case 50:
            _TitleText.text = "Hard";
            break;

        case 60:
            _TitleText.text = "Crazy";
            break;

        case 70:
            _TitleText.text = "Burn Brain";
            break;

        default:
            _TitleText.text = "";
            break;
        }


        if (MagicStaticValue.GetInstance()._HintCount > 0)
        {
            _HintText.text = "+" + MagicStaticValue.GetInstance()._HintCount;
        }
        else
        {
            _HintText.text = "";
        }


        _SudokuNumberPanel.SetActive(false);

        InitSudokuItem();
    }
示例#4
0
    void HintSudoku()
    {
        if (_LastSudokuBtn == null || _OldSudokuInfor == null ||
            MagicStaticValue.GetInstance()._HintCount <= 0)
        {
            return;
        }

        Text tempText = _LastSudokuBtn.transform.FindChild("Text").GetComponent <Text>();

        if (tempText.color == Color.white / 2.0f && tempText.text != "")
        {
            return;
        }

        ItemIndex tempItem = _LastSudokuBtn.GetComponent <ItemIndex>();

        if (tempText.text == "" || tempItem.isRotation)
        {
            Debug.Log(tempItem.X + "  " + tempItem.Y);
            tempText.text  = _OldSudokuInfor[tempItem.X, tempItem.Y].ToString();
            tempText.color = Color.white / 2.0f;

            if (tempItem.isRotation)
            {
                tempItem.isRotation = false;
            }
        }

        _SudokuNumberPanel.SetActive(false);

        MagicStaticValue.GetInstance()._HintCount--;

        if (MagicStaticValue.GetInstance()._HintCount > 0)
        {
            _HintText.text = "+" + MagicStaticValue.GetInstance()._HintCount;
        }
        else
        {
            MagicStaticValue.GetInstance()._HintCount = 0;
            _HintText.text = "";
        }
    }
示例#5
0
    void GetSukuInfor()
    {
        if (SudokuFactory.GetInstance().listSudoku.Count <= 0)
        {
            return;
        }

        _SudokuInfor = SudokuFactory.GetInstance().listSudoku[0];

        _OldSudokuInfor = new int[_SudokuLength, _SudokuLength];
        for (int i = 0; i < _SudokuLength; i++)
        {
            for (int j = 0; j < _SudokuLength; j++)
            {
                _OldSudokuInfor[i, j] = _SudokuInfor[i, j].Num;
            }
        }

        //int tempLevel = _Level[Random.Range(0, _Level.Length)];
        int tempLevel = MagicStaticValue.GetInstance()._Level;

        Debug.Log("困难等级:" + tempLevel);

        for (int i = 0; i < tempLevel; i++)
        {
            int tempX = Random.Range(0, _SudokuLength);
            int tempY = Random.Range(0, _SudokuLength);
            if (_SudokuInfor[tempX, tempY].Num != 0)
            {
                _SudokuInfor[tempX, tempY].Num = 0;
            }
            else
            {
                i--;
            }
        }

        SudokuFactory.GetInstance().listSudoku.RemoveAt(0);
        SudokuFactory.GetInstance().GetSudoku(3);
    }
示例#6
0
    void InitSudokuItem()
    {
        GetSukuInfor();
        if (_SudokuInfor == null)
        {
            return;
        }

        _ArraySudokuItem = new GameObject[MagicStaticValue.GetInstance()._Level];
        int AllItemIndex = 0;

        if (_SudokuItemInfor == null)
        {
            _SudokuItemInfor = new GameObject[_SudokuLength, _SudokuLength];

            for (int i = 0; i < _SudokuLength; i++)
            {
                for (int j = 0; j < _SudokuLength; j++)
                {
                    GameObject go = Instantiate(_SudokuItem);
                    go.transform.parent     = _SudokuPanel.transform;
                    go.transform.localScale = Vector3.one;
                    if (_SudokuInfor[i, j].Num != 0)
                    {
                        go.GetComponent <Button>().enabled = false;
                        go.transform.FindChild("Text").GetComponent <Text>().text = _SudokuInfor[i, j].Num.ToString();
                    }
                    else
                    {
                        go.transform.FindChild("Text").GetComponent <Text>().text = "";
                        _ArraySudokuItem[AllItemIndex] = go;
                        AllItemIndex++;
                    }
                    go.GetComponent <ItemIndex>().X = i;
                    go.GetComponent <ItemIndex>().Y = j;

                    go.GetComponent <Button>().onClick.AddListener(delegate() { ClickSudokuItem(go); });

                    _SudokuItemInfor[i, j] = go;
                }
            }
        }
        else
        {
            for (int i = 0; i < _SudokuLength; i++)
            {
                for (int j = 0; j < _SudokuLength; j++)
                {
                    GameObject go = _SudokuItemInfor[i, j];
                    if (_SudokuInfor[i, j].Num != 0)
                    {
                        go.GetComponent <Button>().enabled = false;
                        go.transform.FindChild("Text").GetComponent <Text>().text  = _SudokuInfor[i, j].Num.ToString();
                        go.transform.FindChild("Text").GetComponent <Text>().color = Color.black;
                    }
                    else
                    {
                        go.GetComponent <Button>().enabled = true;
                        go.transform.FindChild("Text").GetComponent <Text>().text = "";
                        _ArraySudokuItem[AllItemIndex] = go;
                        AllItemIndex++;
                    }
                    go.GetComponent <ItemIndex>().PlayRotationAnimation();
                }
            }
        }
    }