Ejemplo n.º 1
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/EyeemMemory;component/MainPage.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.TitlePanel = ((System.Windows.Controls.StackPanel)(this.FindName("TitlePanel")));
     this.ApplicationTitle = ((System.Windows.Controls.TextBlock)(this.FindName("ApplicationTitle")));
     this.PageTitle = ((System.Windows.Controls.TextBlock)(this.FindName("PageTitle")));
     this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
     this.button1 = ((System.Windows.Controls.Button)(this.FindName("button1")));
     this.StartImage = ((System.Windows.Controls.Image)(this.FindName("StartImage")));
     this.myCard = ((EyeemMemory.EyeemMemoryCard)(this.FindName("myCard")));
     this.searchBox = ((System.Windows.Controls.TextBox)(this.FindName("searchBox")));
     this.AlbumList = ((System.Windows.Controls.ListBox)(this.FindName("AlbumList")));
 }
Ejemplo n.º 2
0
        public void setNextCard(EyeemMemoryCard myCard)
        {
            click++;
            if (click % 2 == 0) 
            {
                moves++;
            }

            if (moves == 0)
            {
                var currentPage = ((App)Application.Current).RootFrame.Content as EyeemGameField;

                //startDt = DateTime.Now;
                gameTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
                
                gameTimer.Start();
                
            }

            myCard.FrontImage.Visibility = Visibility.Collapsed;
            
            if (firstCard == null)
            {
                firstCard = myCard;
            }
            else if (secondCard == null)
            {
                var currentPage = ((App)Application.Current).RootFrame.Content as EyeemGameField;
                currentPage.Moves.Text = "" + moves;

                secondCard = myCard;
                App app = (App)Application.Current;
                app.canPlay = false;
                
                validationTimer.Interval = new TimeSpan(0, 0, 1);
                validationTimer.Start();

            }
        }
Ejemplo n.º 3
0
        private void checkCards(){

            if (firstCard != null && secondCard != null)
            {
                bool result = firstCard.myPhoto.id == secondCard.myPhoto.id;

                if (result)
                {
                    winMoves++;

                    Stream stream = TitleContainer.OpenStream("sounds/yes/"+RandomNumber(1,10)+".wav");
                    SoundEffect effect = SoundEffect.FromStream(stream);
                    FrameworkDispatcher.Update();
                    effect.Play();

                    wonCards.Add(firstCard);
                    wonCards.Add(secondCard);
                    firstCard.canBeChanged = false;
                    secondCard.canBeChanged = false;

                    if (winMoves == 10)
                    {
                        gameTimer.Stop();
                       
                        IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
                        App app = (App)Application.Current;

                        EyeemHighscore newHighscore = new EyeemHighscore();
                        newHighscore.albumName = app.selectedAlbum.name;
                        newHighscore.moves = moves;
                        
                        if (gametimeSeconds >= 10)
                        {
                            newHighscore.seconds = "" + gametimeSeconds;
                        }
                        else
                        {
                            newHighscore.seconds = "0" + gametimeSeconds;
                        }

                        if (gametimeMinutes >= 10)
                        {
                            newHighscore.minutes = "" + gametimeMinutes;
                        }
                        else
                        {
                            newHighscore.minutes = "0" + gametimeMinutes;
                        }
                        
                        app.highscoreList.Add(newHighscore);
                        
                        List<EyeemHighscore> SortedList = app.highscoreList.OrderBy(o => o.moves).ToList();
                        app.highscoreList = SortedList;

                        if (app.highscoreList.Capacity > 10)
                        {
                            app.highscoreList = app.highscoreList.GetRange(0, 9);
                        }

                        settings["highscore"] = app.highscoreList;
                        settings.Save();

                        var messagePrompt = new MessagePrompt
                        {
                            Title = "Congratulations",
                            Body = new TextBlock { Text = "You won! " },
                            IsAppBarVisible = true,
                            IsCancelVisible = false
                        };
                        messagePrompt.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(messagePrompt_Completed);
                        messagePrompt.Show();
                    }
                    else
                    {
                        gameTimer.Stop();

                        Popup showPhotoPopup;
                        showPhotoPopup = new Popup();
                        showPhotoPopup.Child = new PhotoPopup(firstCard.myPhoto);
                        showPhotoPopup.IsOpen = true;
                        showPhotoPopup.VerticalOffset = 10;
                        showPhotoPopup.HorizontalOffset = 0;
                        showPhotoPopup.Closed += (s1, e1) =>
                        {
                            gameTimer.Start();
                        };

                        /*var photoBox = new MessagePrompt
                        {
                            Title = "Great Move!",
                            Body = new Image { Stretch = Stretch.Uniform, Source = new BitmapImage(new Uri(firstCard.myPhoto.photoUrl)) },
                            IsAppBarVisible = true
                        };
                        photoBox.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(photoBox_Completed);
                        photoBox.Show();*/

                        firstCard = null;
                        secondCard = null;
                    }
                }
                else
                {
                    Stream stream = TitleContainer.OpenStream("sounds/no/"+RandomNumber(1,10)+".wav");
                    SoundEffect effect = SoundEffect.FromStream(stream);
                    FrameworkDispatcher.Update();
                    effect.Play();

                    firstCard.FrontImage.Visibility = Visibility.Visible;
                    secondCard.FrontImage.Visibility = Visibility.Visible;
                    firstCard = null;
                    secondCard = null;
                }
            }
            
        }
Ejemplo n.º 4
0
 public void reset()
 {
     moves = 0;
     click = 0;
     wonCards.Clear();
     winMoves = 0;
     
     //gameTimer = new DispatcherTimer();
     gameTimer.Stop();
     
     gametimeSeconds = 0;
     gametimeMinutes = 0;
     firstCard = null;
     secondCard = null;
     //gameTimer.Interval = null ;
     
 }
Ejemplo n.º 5
0
        public void buildGameField()
        {

            availablePositions =  new int[]{0,1,2,3,10,11,12,13,20,21,22,23,30,31,32,33,40,41,42,43};

            App app = (App)Application.Current;
            EyeemMemoryCard myCard = null;
          
            int imageIndex = 0;

            for (int i = 0; i < 20; i++)
            {
                if (imageIndex > 9)
                {
                    imageIndex = 0;
                }

                myCard = new EyeemMemoryCard("grey", app.selectedAlbum.photos.items[imageIndex]);
                this.GameField.Children.Add(myCard);

                int position = GetRandomPosition();

                int row = position / 10;
                int colum = position % 10;

                Grid.SetRow(myCard,row);
                Grid.SetColumn(myCard, colum);
                colum++;

                
                imageIndex++;
            }
         }