示例#1
0
        private void Cell_Click(object sender, EventArgs e)
        {
            FieldCell clickedCell = (FieldCell)sender;

            if (clickedCell.Gem == null)
            {
                return;
            }

            if (_prevCell != null)
            {
                clickedCell.Gem.WasMoved = true;
                _prevCell.Gem.WasMoved   = true;
                Move = new CurrentMove(clickedCell, _prevCell);
                GemsController.SwapGems(Move.FirstCell, Move.SecondCell);

                foreach (var cell in GameField)
                {
                    if (cell.Gem != null)
                    {
                        cell.Gem.IsClicked = false;
                    }
                    GemsController.UpdateGemTexture(cell.Gem);
                }

                _prevCell = null;
            }
            else
            {
                clickedCell.Gem.IsClicked = true;
                GemsController.UpdateGemTexture(clickedCell.Gem);
                _prevCell = clickedCell;
            }
        }
示例#2
0
        private static bool IsCurrentMoveImposible()
        {
            if (Move.FirstCell != null && Move.SecondCell != null)
            {
                if (Move.FirstCell.Gem == null || Move.SecondCell.Gem == null)
                {
                    return(true);
                }

                if (Move.FirstCell.Gem.WasMoved && Move.SecondCell.Gem.WasMoved)
                {
                    GemsController.SwapGems(Move.FirstCell, Move.SecondCell);
                    Move.FirstCell  = null;
                    Move.SecondCell = null;
                }
            }

            return(false);
        }