Esempio n. 1
0
        private void OnSwitchEnd(CellPair switchedCells)
        {
            var matchedCells = _cellManager.CheckCellsOnMatch(switchedCells.FirstCell, switchedCells.SecondCell);

            if (matchedCells.Length == 0)
            {
                switchedCells.Switch();
            }
            else
            {
                CollectMatchedCells(matchedCells);
            }

            switchedCells.OnSwitchEnd -= OnSwitchEnd;
            _switchedCellPair          = null;
        }
Esempio n. 2
0
        private void SwitchCells(Cell firstCell, Cell secondCell)
        {
            if (_switchedCellPair != null)
            {
                return;
            }
            CellPair switchedCells = new CellPair(firstCell, secondCell);

            if (switchedCells.IsNeighbors == false)
            {
                return;
            }

            switchedCells.OnSwitchEnd += OnSwitchEnd;

            bool isSwitchPass = switchedCells.Switch();

            if (isSwitchPass)
            {
                _switchedCellPair = switchedCells;
            }
        }