Esempio n. 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;
            }
        }
Esempio n. 2
0
        private static void CheckGemAndActivateBonus(FieldCell cell)
        {
            switch (cell.Gem.Type)
            {
            case GemType.Bomb:
                ActivatedBombs.Add((FieldCell)cell.Clone());
                GemsController.DeleteGem(cell);
                break;

            case GemType.VerticalLine:
            case GemType.HorizontalLine:
                BonusController.LaunchDestroyers(cell);
                GemsController.DeleteGem(cell);
                break;
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public override void Update(GameTime gameTime)
        {
            if (IsTimerEnded(gameTime))
            {
                _gameOverWindow?.Update(gameTime);

                return;
            }

            GameBoardConroller.MatchAndClear(GameField);

            UpdateActivatedBonuses();

            UpdateDestroyers(gameTime);

            BonusController.BlowActivatedBombs();

            BonusController.UseDestoyers();

            if (Destroyers.Count == 0)
            {
                GemsController.MoveGems(GameField);

                GemsController.GenerateNewGems(GameField);
            }

            if (IsCurrentMoveImposible())
            {
                return;
            }

            foreach (var cell in GameField)
            {
                cell.Update(gameTime);
                cell.Gem?.Update(gameTime);
            }
        }