Exemplo n.º 1
0
    CellController _clickedCellController; // выделеная яечкйка
    void Start()
    {
        _puzzle = PuzzleGame.Instance.GetNewGame(1);

        for (int x = 0; x < 9; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                PuzzleCell cell = _puzzle.GetCell(x, y);
                cell.OnCellOpen += OnCellOpened;
                var cellButton = GameObject.Find($"{x}_{y}");

                CellController controller = cellButton.GetComponent <CellController>();
                controller.Cell         = cell;
                controller.X            = x; //колонка
                controller.Y            = y; //строка
                controller.CellName     = cellButton.name;
                controller.CellClicked += OnCellClicked;
                _cells[x, y]            = controller;
                controller.DrawCell();
            }
        }

        //Find keypad buttons
        for (int i = 1; i < 10; i++)
        {
            var keyPadButton = GameObject.Find($"Num{i}").GetComponent <Button>();
            int number       = i;
            keyPadButton.onClick.AddListener(() => OnKeyPadButtonClicked(number));
        }
    }
Exemplo n.º 2
0
 private void OnKeyPadButtonClicked(int number) // на нум паде
 {
     if (!_clickedCellController.Cell.IsOpen)
     {
         if (_clickedCellController.Cell.Value == number)
         {
             _clickedCellController.Cell.Open();
             _clickedCellController.DrawCell();
         }
     }
 }