Example #1
0
        public override void Update(GameTime gameTime)
        {
            if (_input.mouseClick())
            {
                if (_restartButton.Contains(_input.MousePosition()))
                {
                    ((MatchCutesGame)Game).restart();
                }
                else if (_quitButton.Contains(_input.MousePosition()))
                {
                    Game.Exit();
                }
            }


            base.Update(gameTime);
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            if (!_ScoreServ.gameOver)
            {
                _dropDownTimer += gameTime.ElapsedGameTime.TotalSeconds;

                if (_dropDownTimer >= time_between_block_drops)
                {
                    _dropDownTimer -= time_between_block_drops;
                    moveFallingGems();
                }

                if (_remainingMoves <= 0 && _ScoreServ.Score < 50000)
                {
                    spawnRow();
                }
                else if (_remainingMoves <= 0 && _ScoreServ.Score >= 50000)
                {
                    spawnRow();
                    moveFallingGems();
                    spawnRow();
                }

                if (!_blocksAreFalling)
                {
                    if (_input.mouseClick())
                    {
                        if (gameFrame.Contains(_input.MousePosition()))
                        {
                            {
                                if (_selected.X == -1 && _selected.Y == -1)
                                {
                                    _selected.X = _input.MousePosition().X / 80;
                                    _selected.Y = _input.MousePosition().Y / 80;
                                    GemType selectedGem = Playfield[_selected.X, _selected.Y];
                                    if (selectedGem == GemType.None)
                                    {
                                        _selected.X = _selected.Y = -1;
                                    }
                                }
                                else
                                {
                                    Point   newSelection = new Point(_input.MousePosition().X / 80, _input.MousePosition().Y / 80);
                                    GemType selectedGem  = Playfield[newSelection.X, newSelection.Y];
                                    if (selectedGem == GemType.None || (_selected.X == newSelection.X) && _selected.Y == newSelection.Y)
                                    {
                                        _selected.X = _selected.Y = -1;
                                    }
                                    else
                                    {
                                        int distance = Math.Abs(_selected.X - newSelection.X) + Math.Abs(_selected.Y - newSelection.Y);
                                        if (distance == 1)
                                        {
                                            Playfield[newSelection.X, newSelection.Y] = Playfield[_selected.X, _selected.Y];
                                            Playfield[_selected.X, _selected.Y]       = selectedGem;
                                            _selected.X = _selected.Y = -1;
                                            _remainingMoves--;
                                            _dropDownTimer = time_between_block_drops;
                                            _ScoreServ.clickCount++;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    detectClusters();
                }
            }
            base.Update(gameTime);
        }