Beispiel #1
0
        public void ShowGhost(int row, int col, bool isPlayerLight)
        {
            // Hack to match danny's orientation
            row = 7 - row;

            // create the piece and place it above the destination square
            var newPiece = new Cylinder(S_CYLINDER_WIDTH, S_CYLINDER_HEIGHT, CYLINDER_RESOLUTION, isPlayerLight
                ? new DiffuseMaterial(new SolidColorBrush(S_LIGHT_COLOR))
                : new DiffuseMaterial(new SolidColorBrush(S_DARK_COLOR)));
            double centerX, centerY;

            GetViewCoordinates(col, row, out centerX, out centerY);
            // make the piece transparent
            var pieceColor = (newPiece.Material as DiffuseMaterial).Color;

            pieceColor.A = 70;
            (newPiece.Material as DiffuseMaterial).Color = pieceColor;
            newPiece.MoveTo(new Point3D(centerX, centerY, 0.0));
            mainViewport.Children.Add(newPiece);

            m_ghostPieces.Add(newPiece, new Point(col, row));
        }
Beispiel #2
0
        /// <summary>
        /// Places a piece on the gameboard by visually "dropping the piece."
        /// </summary>
        /// <param name="row">The row of the piece to place.</param>
        /// <param name="col">The column of the piece to place.</param>
        /// <param name="isBlack">If true, the piece color is black; otherwise, it's white.</param>
        public void AddPieceAnimated(int row, int col, bool isPlayerLight)
        {
            // Update the GUI board
            m_GUIboard[row, col] = isPlayerLight ? MinimaxSpot.Light : MinimaxSpot.Dark;

            // Hack to match danny's orientation
            row = 7 - row;

            // create the piece and place it above the destination square
            var newPiece = new Cylinder(S_CYLINDER_WIDTH, S_CYLINDER_HEIGHT, CYLINDER_RESOLUTION, isPlayerLight
                ? new DiffuseMaterial(new SolidColorBrush(S_LIGHT_COLOR))
                : new DiffuseMaterial(new SolidColorBrush(S_DARK_COLOR)));
            double centerX, centerY;

            GetViewCoordinates(col, row, out centerX, out centerY);
            newPiece.MoveTo(new Point3D(centerX, centerY, 20.0));
            mainViewport.Children.Add(newPiece);

            // animate it's descent
            var animationStoryboard = new Storyboard();

            var translateTransform = new TranslateTransform3D(
                centerX, centerY, 20.0);
            var moveDownAnimation = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(500)));

            mainViewport.RegisterName("GamePieceDrop", translateTransform);
            Storyboard.SetTargetName(moveDownAnimation, "GamePieceDrop");
            Storyboard.SetTargetProperty(moveDownAnimation, new PropertyPath(TranslateTransform3D.OffsetZProperty));
            animationStoryboard.Children.Add(moveDownAnimation);
            newPiece.Transform = translateTransform;

            animationStoryboard.Begin(mainViewport);

            mainViewport.UnregisterName("GamePieceDrop");

            m_gamePieces[new Point(row, col)] = newPiece;
        }