Пример #1
0
        public void SetWindow(GeneralWindow window)
        {
            //window settings
            window.WindowStyle   = WindowStyle.None;
            window.SizeToContent = SizeToContent.WidthAndHeight;

            window.Background = Brushes.Black;
            window.Foreground = Brushes.White;

            //main stack panel
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;
            window.Content    = stack;

            //insert tetris play area in grid
            _tetrisGrid = new TetrisFE(new Size(16, 8), new ShapesGeneratorWithPrediction(3), TetrisTimers.Basic);
            stack.Children.Add(_tetrisGrid);
            _tetrisGrid.Play();

            //insert preditction panel and score panel
            stack.Children.Add(new PredictionFE(_tetrisGrid));
            stack.Children.Add(new ScoreHistoryFe(new ScoreCounter(_tetrisGrid)));

            //key control
            _keyControl = KeyLayouts.SinglePlayerLayout;
        }
Пример #2
0
        public void SetWindow(GeneralWindow window)
        {
            //window settings
            window.WindowStyle   = WindowStyle.None;
            window.SizeToContent = SizeToContent.WidthAndHeight;

            window.Background = Brushes.Black;
            window.Foreground = Brushes.White;

            //main stack panel


            //Shared shape generator for both players
            var shapeGenerator = new ShapesGeneratorWithPrediction(3);

            //Creating GameArea for both players
            _tetrisFirstPlayer  = new TetrisFE(new Size(16, 8), shapeGenerator, TetrisTimers.Basic);
            _tetrisSecondPlayer = new TetrisFE(new Size(16, 8), shapeGenerator, TetrisTimers.Basic);

            //creating score counter for both players
            var scoreFirstPlayer  = new ScoreFE(new ScoreCounter(_tetrisFirstPlayer));
            var scoreSecondPlayer = new ScoreFE(new ScoreCounter(_tetrisSecondPlayer));

            //arange screen


            //create stack panel for first player
            StackPanel firstPlayerStack = new StackPanel();

            firstPlayerStack.Children.Add(scoreFirstPlayer);
            firstPlayerStack.Children.Add(_tetrisFirstPlayer);

            //create stack panel for second player
            StackPanel secondPlayerStack = new StackPanel();

            secondPlayerStack.Children.Add(scoreSecondPlayer);
            secondPlayerStack.Children.Add(_tetrisSecondPlayer);

            //add all to main stack panel
            StackPanel mainStack = new StackPanel();

            mainStack.Orientation = Orientation.Horizontal;
            window.Content        = mainStack;

            mainStack.Children.Add(firstPlayerStack);
            mainStack.Children.Add(new PredictionFE(shapeGenerator));
            mainStack.Children.Add(secondPlayerStack);

            //creating keycontrol for both players TODO make user settings for this
            _keysFirstPlayer  = KeyLayouts.LeftSideOfKeyboardLayout;
            _keysSecondPlayer = KeyLayouts.NumPadArowsLayout;

            //let the game begin
            _tetrisSecondPlayer.Play();
            _tetrisFirstPlayer.Play();
        }
Пример #3
0
        //if Tetris grid has generator with prediction - save ptr to property
        private void SetShapeGenerator(TetrisFE positionGrid)
        {
            //unsubsribe from event
            if (_shapeGenerator != null)
            {
                _shapeGenerator.ShapePoped -= OnShapeGeneratorPoped;
            }

            //get predicting shape generator
            _shapeGenerator = positionGrid.ShapeGenerator as IShapeGeneratorWithPrediction;

            //subrscibe event when shape is generated
            _shapeGenerator.ShapePoped += OnShapeGeneratorPoped;
        }
Пример #4
0
        //public bool IsPredicting { get; private set; }

        public PredictionFE(TetrisFE positionGrid)
        {
            SetShapeGenerator(positionGrid);
            positionGrid.ShapeGeneratorChanged += OnShapeGeneratorChanged;
            OnShapeGeneratorPoped(null);
        }