示例#1
0
    public BoardAction(int lines, bool t_spin, TetrominoAction tetroAction)
    {
        LinesCleared = lines;
        TSpin        = t_spin;
        bool wallKick = tetroAction == TetrominoAction.Rotate_WallKick;

        Type      = ClassifyType(lines, t_spin, wallKick);
        Difficult = (t_spin && lines > 0) || (lines >= 4);
    }
        /// <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);
        }
示例#3
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);
        }