Пример #1
0
        /// <summary>
        /// The method that determines which action is being taken
        /// </summary>
        /// <returns>The actions being returned from the tetris handler</returns>
        public TetrominoAction GetTetrominoActions(GameTime gameTime)
        {
            TetrominoAction action = TetrominoAction.None;

            inputDelta -= gameTime.ElapsedGameTime.Milliseconds;
            if (inputDelta <= 0)
            {
                inputDelta = InputStep;
                gameplayScreen.ResetInput();

                foreach (TouchLocation tl in InputHandler.GetCurrentTouchLocationCollection())
                {
                    Rectangle rect = new Rectangle((int)tl.Position.X, (int)tl.Position.Y, 1, 1);
                    if (tl.State == TouchLocationState.Pressed || tl.State == TouchLocationState.Moved)
                    {
                        if (gameplayScreen.LeftButton.Intersects(rect))
                        {
                            action = TetrominoAction.Left;
                        }
                        else if (gameplayScreen.MiddleButton.Intersects(rect))
                        {
                            action = TetrominoAction.HardDrop;
                        }
                        else if (gameplayScreen.RightButton.Intersects(rect))
                        {
                            action = TetrominoAction.Right;
                        }
                        else if (gameplayScreen.RotateButton.Intersects(rect))
                        {
                            action = TetrominoAction.Rotate;
                        }
                    }
                }
            }


            foreach (TouchLocation tl in InputHandler.GetCurrentTouchLocationCollection())
            {
                Rectangle rect = new Rectangle((int)tl.Position.X, (int)tl.Position.Y, 1, 1);
                if (tl.State == TouchLocationState.Pressed)
                {
                    if (gameplayScreen.HoldBox.Intersects(rect))
                    {
                        action = TetrominoAction.Hold;
                    }
                }
            }

            return(action);
        }
Пример #2
0
        /// <summary>
        /// The method that determines which action is being taken
        /// </summary>
        /// <returns>The actions being returned from the tetris handler</returns>
        public TetrominoAction GetTetrominoActions(GameTime gameTime)
        {
            TetrominoAction action = TetrominoAction.None;

            actionInputDelta -= gameTime.ElapsedGameTime.Milliseconds;

            if (actionInputDelta <= 0)
            {
                actionInputDelta = ActionInput;
                gameplayScreen.ResetInput();

                int value = RandomGenerator.Instance.Next(0, actions.Length);
                action = actions[value];
            }

            return(action);
        }