Esempio n. 1
0
        private static void ExecuteCommand(GameCommand command, ref Game g, GameView view)
        {
            switch (command)
            {
            case GameCommand.MoveLeft:
                TryMoveShape(ref g, view, -1, 0);
                break;

            case GameCommand.MoveRight:
                TryMoveShape(ref g, view, 1, 0);
                break;

            case GameCommand.MoveDown:
                TryMoveShape(ref g, view, 0, 1);
                break;

            case GameCommand.Land:
                while (TryMoveShape(ref g, view, 0, 1))
                {
                    System.Threading.Thread.Sleep(GAME_QUANTUM);
                }
                break;

            case GameCommand.Rotate:
                Shape rotated = BL.RotateShape(g.CurrentShape);
                if (BL.IsPositionPossible(g.Field, rotated))
                {
                    Point2D[] makeEmpty;
                    Point2D[] makeFilled;

                    BL.CalcChangedPoints(g.CurrentShape, rotated, out makeEmpty, out makeFilled);
                    g.CurrentShape = rotated;
                    UI.DrawPoints(makeEmpty, ShapeKind.Empty, view);
                    UI.DrawPoints(makeFilled, g.CurrentShape.Kind, view);
                }
                break;
            }
        }