Пример #1
0
 public virtual void Update(GameTime gameTime)
 {
     // For Mobile devices, this logic will close the Game when the Back button is pressed
     if (ExitOnBack && GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.Back))
     {
         Exit();
     }
 }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            var nextScreen =
                GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.A) ||
                GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.Start) ||
                TouchPanelEx.WasJustPressed();

            if (nextScreen)
            {
                ScreenUtil.Show(new TitleScreen(Parent));
            }
        }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            gamepad = GamePadEx.GetState(PlayerIndex.One);

            if (GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.A))
            {
                ScreenUtil.Show(new Main(this.Parent));
            }
            else if (GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.Back))
            {
                ScreenUtil.Show(new Splash(this.Parent));
            }

            base.Update(gameTime);
        }
Пример #4
0
        public override void Update(GameTime gameTime)
        {
            elapsed += gameTime.ElapsedGameTime.TotalSeconds;

            gamepad = GamePadEx.GetState(PlayerIndex.One);

            var buttonWasPressed = GamePadEx.WasJustPressed(PlayerIndex.One, Buttons.A);

            if (elapsed >= 3.0)
            {
                buttonWasPressed = true;
            }

            if (buttonWasPressed)
            {
                ScreenUtil.Show(new Title(this.Parent));
            }

            base.Update(gameTime);
        }
Пример #5
0
        public override void Update(GameTime gameTime)
        {
            // TODO: Fix, the add 2nd controller
            gamepad = GamePadEx.GetState(Board.Player);

            if (State == GameState.SelectingFromQueue)
            {
                if (GamePadEx.WasJustPressed(Board.Player, Buttons.DPadUp))
                {
                    SelectedQueueIndex = Math.Max(0, SelectedQueueIndex - 1);
                }
                else if (GamePadEx.WasJustPressed(Board.Player, Buttons.DPadDown))
                {
                    SelectedQueueIndex = Math.Min(3, SelectedQueueIndex + 1);
                }

                if (GamePadEx.WasJustPressed(Board.Player, Buttons.A))
                {
                    //ScreenUtil.Show(new Credits(this.Parent));
                    // TODO: move selected piece to top for drop
                    StagedPiece = Board.Player == PlayerIndex.One ?
                                  Board.BlueQueue[SelectedQueueIndex] :
                                  Board.RedQueue[SelectedQueueIndex];
                    (Board.Player == PlayerIndex.One ? Board.BlueQueue : Board.RedQueue)[SelectedQueueIndex]
                        = Piece.Empty;
                    StagedPieceColumn = 3;
                    State             = GameState.SelectingColumn;

                    //Board.ClearPieceFlags();
                }
            }
            else if (State == GameState.SelectingColumn)
            {
                if (GamePadEx.WasJustPressed(Board.Player, Buttons.DPadLeft))
                {
                    StagedPieceColumn = Math.Max(0, StagedPieceColumn - 1);
                }
                else if (GamePadEx.WasJustPressed(Board.Player, Buttons.DPadRight))
                {
                    StagedPieceColumn = Math.Min(7, StagedPieceColumn + 1);
                }

                if (GamePadEx.WasJustPressed(Board.Player, Buttons.A))
                {
                    if (Board.Pieces[StagedPieceColumn, 0].PieceType == PieceTypes.Empty)
                    {
                        Board.Pieces[StagedPieceColumn, 0] = StagedPiece;

                        switch (Board.Player)
                        {
                        case PlayerIndex.One:
                            Board.FillQueue(Board.BlueQueue, PieceTypes.NormalBlue);
                            break;

                        case PlayerIndex.Two:
                            Board.FillQueue(Board.RedQueue, PieceTypes.NormalRed);
                            break;
                        }

                        //Board.ClearPieceFlags();

                        State       = GameState.SelectingFromQueue;
                        StagedPiece = Piece.Empty;
                        Board.TogglePlayer();
                    }
                }
            }



            if (GamePadEx.WasJustPressed(Board.Player, Buttons.Back))
            {
                ScreenUtil.Show(new Title(this.Parent));
            }
            else
            {
                var isAnimating = false;
                if (Board.Animations != null && Board.Animations.Count > 0)
                {
                    foreach (var animation in Board.Animations)
                    {
                        if (animation.IsDone == false)
                        {
                            isAnimating = true;
                            break;
                        }
                    }
                }

                if (isAnimating)
                {
                    // DO NOTHING!
                }
                else if (Board.DoGravity((float)gameTime.ElapsedGameTime.TotalSeconds))
                {
                    // DO NOTHING!
                }
                else
                {
                    if (Board.ScanForPowerUps())
                    {
                    }
                    else
                    {
                        var matchRed  = Board.ScanForMatches(Board.MatchOnRed);
                        var matchBlue = Board.ScanForMatches(Board.MatchOnBlue);

                        if (matchRed == PieceTypes.NormalRed && matchBlue == PieceTypes.NormalBlue)
                        {
                            // TIE GAME :/
                        }
                        else if (matchBlue == PieceTypes.NormalBlue)
                        {
                            // BLUE WINS!
                        }
                        else if (matchRed == PieceTypes.NormalRed)
                        {
                            // RED WINS!
                        }
                        else if (Board.IsFull)
                        {
                            // TIE GAME :/
                        }
                    }
                }
            }

            if (Board.Animations != null && Board.Animations.Count > 0)
            {
                foreach (var animation in Board.Animations)
                {
                    animation.Update(gameTime);
                }
            }
            base.Update(gameTime);
        }