Exemplo n.º 1
0
 public PuzzlePage()
 {
     InitializeComponent();
     SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
     // Puzzle Game
     this.game              = new PuzzleGame(3);
     this.game.GameStarted += delegate
     {
         this.ResetWinTransition.Begin();
         this.StatusPanel.Visibility         = Visibility.Visible;
         this.TapToContinueTextBlock.Opacity = 0;
         this.TotalMovesTextBlock.Text       = this.game.TotalMoves.ToString();
     };
     this.game.GameOver += delegate
     {
         this.WinTransition.Begin();
         this.TapToContinueTextBlock.Opacity = 1;
         this.StatusPanel.Visibility         = Visibility.Visible;
         this.TotalMovesTextBlock.Text       = this.game.TotalMoves.ToString();
     };
     this.game.PieceUpdated += delegate(object sender, PieceUpdatedEventArgs args)
     {
         int pieceSize = ImageSize / this.game.ColsAndRows;
         this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.LeftProperty, (int)args.NewPosition.X * pieceSize);
         this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.TopProperty, (int)args.NewPosition.Y * pieceSize);
         this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
     };
     this.InitBoard();
 }
        public PuzzlePage()
        {
            InitializeComponent();

            SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

            // Puzzle Game
            this.game = new PuzzleGame(3);

            this.game.GameStarted += delegate
            {
                this.ResetWinTransition.Begin();
                this.StatusPanel.Visibility = Visibility.Visible;
                this.TapToContinueTextBlock.Opacity = 0;
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };

            this.game.GameOver += delegate
            {
                this.WinTransition.Begin();
                this.TapToContinueTextBlock.Opacity = 1;
                this.StatusPanel.Visibility = Visibility.Visible;
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };

            this.game.PieceUpdated += delegate(object sender, PieceUpdatedEventArgs args)
            {
                int pieceSize = ImageSize / this.game.ColsAndRows;
                this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.LeftProperty, (int)args.NewPosition.X * pieceSize);
                this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.TopProperty, (int)args.NewPosition.Y * pieceSize);
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };

            this.InitBoard();
        }
Exemplo n.º 3
0
 //Constructor
 public PuzzlePage(PuzzleGame game, double DoubleTapSpeed, int ImageSize, Canvas[] puzzlePieces, Stream imageStream, long lastTapTicks, int movingPieceId, int movingPieceDirection, double movingPieceStartingPosition)
 {
     InitializeComponent();
     this.game = game;
     this.DoubleTapSpeed = DoubleTapSpeed;
     this.ImageSize = ImageSize;
     this.puzzlePieces = puzzlePieces;
     this.imageStream = imageStream;
     this.lastTapTicks = lastTapTicks;
     this.movingPieceId = movingPieceId;
     this.movingPieceDirection = movingPieceDirection;
     this.movingPieceStartingPosition = movingPieceStartingPosition;
 }