Beispiel #1
0
        public GameEngine(GameField playfieldInfo, GameRenderer renderer)
        {
            this.playfieldInfo             = playfieldInfo;
            this.renderer                  = renderer;
            this.frameRenderTimer          = new DispatcherTimer();
            this.frameRenderTimer.Interval = TimeSpan.FromMilliseconds(frameRenderingInterval);
            this.frameRenderTimer.Tick    += OnFrameRenderTimerTick;

            this.highscore = ScoringSystem.GetHighscore();

            this.InitializeEndGameAnimationWorker();

            this.endGameBlocksBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8FC461"));
            this.endGameBlocksBrush.Freeze();
        }
Beispiel #2
0
        public static Game GetGame()
        {
            var pieceFactory = new PieceFactory(new TetrisBlockFactory());
            var score        = new Score(10, 1000, 100, Score.DefaultScoreMultiplier());
            var board        = new Board(pieceFactory, new Size(10, 22), new Point(4, 1));
            var renderer     = new GameRenderer(board, score, 20);

            renderer.Border     = new Pen(new LinearGradientBrush(new Point(renderer.Size), new Point(0, 0), Color.DarkGray, Color.FloralWhite));
            renderer.Background = new LinearGradientBrush(new Point(0, 0), new Point(renderer.Size), Color.DarkGray, Color.FloralWhite);
            renderer.Font       = SystemFonts.DefaultFont;
            renderer.FontBrush  = Brushes.Black;

            var game = new Game(renderer);

            return(game);
        }
Beispiel #3
0
        public TetrisGameViewModel(Grid gameRenderSurface, Grid nextShapeRenderSurface)
        {
            var playfield = new GameField();
            var renderer  = new GameRenderer(gameRenderSurface, nextShapeRenderSurface, playfield);

            this.gameEngine = new GameEngine(playfield, renderer);
            this.gameEngine.GamePropertyChanged       += GameEngine_PropertyChanged;
            this.gameEngine.EndGameAnimationCompleted += GameEngine_EndGameAnimationCompleted;

            this.StartGameCommand  = new RelayCommand(OnStartGame, OnCanStartGame);
            this.EndGameCommand    = new RelayCommand(OnEndGame, OnCanEndGame);
            this.PauseGameCommand  = new RelayCommand(OnPause, OnCanPauseGame);
            this.ResumeGameCommand = new RelayCommand(OnResume, OnCanResumeGame);
            this.MoveCommand       = new RelayCommand(OnMove);
            this.RotateCommand     = new RelayCommand(OnRotate);

            this.Highscore = ScoringSystem.GetHighscore();
        }