コード例 #1
0
ファイル: GameBoardDrawer.cs プロジェクト: ryan10132/N-Tris
        public void draw(GameBoardData data)
        {
            canvas.Children.Clear();
            MinoDrawSize = canvas.Width / data.Width;

            Rectangle rect = new Rectangle { Stroke = Brushes.Black, StrokeThickness = 2, Height = canvas.Height, Width = canvas.ActualWidth, Fill = Brushes.Black };

            Canvas.SetLeft(rect, 0);
            Canvas.SetTop(rect, 0);
            canvas.Children.Add(rect);

            data.FallingPolyomino.drawPolyomino(canvas, data.FallingPolyominoLocation, MinoDrawSize, false);
            data.FallingPolyomino.drawPolyomino(canvas, data.getGhostPieceLocation(), minoDrawSize, true);

            //todo remove
            Ellipse e = new Ellipse { Fill = Brushes.Red, Height = 10, Width = 10 };
            double x = data.FallingPolyominoLocation.X * minoDrawSize + minoDrawSize / 2 -5;
            double y = canvas.Height - minoDrawSize / 2 - 5;
            y -= minoDrawSize * data.FallingPolyominoLocation.Y;
            Canvas.SetLeft(e, x);
            Canvas.SetTop(e, y);
            canvas.Children.Add(e);

            foreach (Mino m in data.SettledMinos)
            {
                Vector2 v = m.v;
                m.drawMino(canvas, MinoDrawSize, false);
            }
            drawGridLines(canvas);
        }
コード例 #2
0
ファイル: AccessoryDrawer.cs プロジェクト: ryan10132/N-Tris
        internal void drawRight(Canvas accessoryCanvas, GameBoardData e)
        {
            accessoryCanvas.Children.Clear();

            double holdCellWidth = 2 * accessoryCanvas.ActualWidth / 3;

            List<Polyomino> nexts = e.MyPieceDealer.peekNextPolyominos(5);

            double startNextsY = 0;

            for (int i = 0; i < 5; i++)
            {
                double x = (accessoryCanvas.ActualWidth - holdCellWidth) / 2;
                double y = startNextsY + i * holdCellWidth;

                Rectangle fill = new Rectangle { Stroke = Brushes.Black, StrokeThickness = 2, Height = holdCellWidth, Width = holdCellWidth, Fill = Brushes.Black };

                Canvas.SetLeft(fill, x);
                Canvas.SetTop(fill, y);
                accessoryCanvas.Children.Add(fill);

                Polyomino p = nexts[i].Clone();
                p.SRSNormalize();
                Rect r = new Rect(x, y, holdCellWidth, holdCellWidth);
                p.drawPolyomino(accessoryCanvas, r, false);
            }
        }
コード例 #3
0
ファイル: AccessoryDrawer.cs プロジェクト: ryan10132/N-Tris
        internal void draw(Canvas accessoryCanvas, GameBoardData e)
        {
            accessoryCanvas.Children.Clear();

            double holdCellWidth = 2 * accessoryCanvas.ActualWidth / 3;

            Rectangle rect = new Rectangle { Stroke = Brushes.Black, StrokeThickness = 2, Height = holdCellWidth, Width = holdCellWidth, Fill = Brushes.Black };

            Canvas.SetLeft(rect, ( accessoryCanvas.ActualWidth - holdCellWidth ) / 2 );
            Canvas.SetTop(rect, 0);
            accessoryCanvas.Children.Add(rect);

            if (e.HeldPolyomino != null)
            {
                Polyomino p = e.HeldPolyomino.Clone();
                p.SRSNormalize();
                Rect r = new Rect((accessoryCanvas.ActualWidth - holdCellWidth) / 2, 0, holdCellWidth, holdCellWidth);
                p.drawPolyomino(accessoryCanvas, r, false);
            }

            //List<Polyomino> nexts = e.MyPieceDealer.peekNextPolyominos(5);

            //double startNextsY = holdCellWidth * 1.5;

            //for (int i = 0; i < 5; i++)
            //{
            //    double x = (accessoryCanvas.ActualWidth - holdCellWidth) / 2;
            //    double y = startNextsY + i * holdCellWidth;

            //    Rectangle fill = new Rectangle { Stroke = Brushes.Black, StrokeThickness = 2, Height = holdCellWidth, Width = holdCellWidth, Fill = Brushes.Black };

            //    Canvas.SetLeft(fill, x);
            //    Canvas.SetTop(fill, y);
            //    accessoryCanvas.Children.Add(fill);

            //    Polyomino p = nexts[i].Clone();
            //    p.SRSNormalize();
            //    Rect r = new Rect(x,y, holdCellWidth, holdCellWidth);
            //    p.drawPolyomino(accessoryCanvas, r, false);
            //}
        }
コード例 #4
0
 private void BoardChangedEvent_boardChanged(object sender, GameBoardData e)
 {
     accessoryDrawer.drawRight(AccessoryCanvas, e );
 }
コード例 #5
0
 private void boardChangeFired(object sender, GameBoardData e)
 {
     drawer.draw(e);
 }
コード例 #6
0
ファイル: BoardChangedEvent.cs プロジェクト: ryan10132/N-Tris
 public static void fire(Object s, GameBoardData payload)
 {
     boardChanged(s, payload);
 }