コード例 #1
0
        // Author: Brandon Wegner, Samuel Stahl
        //Checks for collision in two states:

        //State 1: about to place - If AboutToPlace flag is set and action is MoveDown call placeshape
        //else calculates action as usual to check for legal action and apply accordingly

        //State 2: not about to place - Check's for collision and returns true if action not legal
        // else returns false and calls GameShape.ApplyAction()
        public static void ApplyAction(InputAction action, BlockGrid grid, GameShape shape)
        {
            if (shape.isAboutToPlace)
            {
                if (action == InputAction.MoveDown)
                {
                    grid.PlaceShape(shape);
                }
                else
                {
                    shape.ResetAboutToPlaceFlag();
                    checkAndApply(action, grid, shape);
                }
            }
            else
            {
                checkAndApply(action, grid, shape);
            }
        }