Exemple #1
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            if (pl_cur.lvl_3_sc < score)
            {
                pl_cur.lvl_3_sc = score;
            }
            Pldb.SubmitChanges();

            //base.OnNavigatingFrom(e);
        }
Exemple #2
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            d2 = DateTime.Now;
            t  = d2 - d1;

            if (pl_cur.lvl_2_sc < score)
            {
                pl_cur.lvl_2_sc = score;
            }
            if (t > t_parse)
            {
                pl_cur.lvl_2_ht = t.Hours.ToString() + ":" + t.Minutes.ToString() + ":" + t.Seconds;;
            }

            Pldb.SubmitChanges();

            //base.OnNavigatingFrom(e);
        }
        public Page1()
        {
            InitializeComponent();
            int i = 0;
            IQueryable <player> EmpQuery = from pl in Pldb.Players where pl.pl_name == cur_pl_name select pl;
            player pl_cur = EmpQuery.FirstOrDefault();

            pl_name_prog.Text = cur_pl_name;
            l_1_sc.Text       = pl_cur.lvl_1_sc.ToString();
            l_2_sc.Text       = pl_cur.lvl_2_sc.ToString();
            l_3_sc.Text       = pl_cur.lvl_3_sc.ToString();
            ht_lvl_1.Text     = pl_cur.lvl_1_ht;
            ht_lvl_2.Text     = pl_cur.lvl_2_ht;
            ht_lvl_3.Text     = pl_cur.lvl_3_ht;

            IQueryable <player> plQuery = from pl in Pldb.Players orderby pl.lvl_1_sc + pl.lvl_2_sc + pl.lvl_3_sc descending select pl;

            playerlist = plQuery.ToList();
            foreach (player p in playerlist)
            {
                i++;

                if (p.pl_name == cur_pl_name)
                {
                    p.rank = i;
                    Pldb.SubmitChanges();
                    break;
                }
            }

            rank_dat.Text = i.ToString();

            BitmapImage retreivedImage = new BitmapImage();

            using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var isoFileStream = isoStore.OpenFile(cur_pl_name + ".jpg", System.IO.FileMode.Open))
                    retreivedImage.SetSource(isoFileStream);
                user_image.Source = retreivedImage;
            }
        }
        private void sign_Click(object sender, RoutedEventArgs e)
        {
            using (PlayerDataContext Pldb = new PlayerDataContext(strConnectionString))
            {
                if (Pldb.DatabaseExists() == false)
                {
                    Pldb.CreateDatabase();
                }

                if (sign_up_name.IsChecked == true)
                {
                    player newPlayer = new player
                    {
                        pl_name  = user.Text,
                        lvl_1_sc = 0,
                        lvl_2_sc = 0,
                        lvl_3_sc = 0,
                        pl_pwrd  = pwd.Password,
                        lvl_1_ht = "00:00:00",
                        lvl_2_ht = "00:00:00",
                        lvl_3_ht = "00:00:00",
                        corr_10  = false,
                        corr_3   = false,
                        corr_5   = false,
                        rn_1     = false
                    };

                    try
                    {
                        Pldb.Players.InsertOnSubmit(newPlayer);
                        Pldb.SubmitChanges();
                        IsolatedStorageSettings.ApplicationSettings["cur_uid"] = user.Text;
                        NavigationService.Navigate(new Uri("/photocapt.xaml", UriKind.Relative));
                    }
                    catch
                    {
                        MessageBox.Show("The username already exists.Enter a different username OR Sign in with this username.");
                    }
                }

                else
                {
                    IQueryable <player> EmpQuery = from pl in Pldb.Players where pl.pl_pwrd == pwd.Password && pl.pl_name == user.Text select pl;
                    player pl_cur = EmpQuery.FirstOrDefault();
                    if (pl_cur == null)
                    {
                        MessageBox.Show("Either username or password is incorrect or both are incorrect");
                    }
                    else
                    {
                        IsolatedStorageSettings.ApplicationSettings["cur_uid"] = user.Text;
                        NavigationService.Navigate(new Uri("/mainmenu.xaml", UriKind.Relative));
                    }
                }
                //IQueryable<player> EmpQuery = from pl in Pldb.Players where pl.pl_pwrd == pwd.Password select pl;
                //player pl_cur = EmpQuery.FirstOrDefault();

                //        if(pl_cur==null)
                //        {
                //            pl_cur.lvl_1_sc = 0;
                //            pl_cur.lvl_2_sc = 0;
                //            pl_cur.lvl_3_sc = 0;
                //            Pldb.Players.InsertOnSubmit(pl_cur);
                //            Pldb.SubmitChanges();

                //        }

                //player newPlayer = new player
                //{
                //    pl_name = user.Text,
                //    lvl_1_sc = 0,
                //    lvl_2_sc = 0,
                //    lvl_3_sc = 0,
                //    pl_pwrd=pwd.Password
                //};


                //            Pldb.Players.InsertOnSubmit(newPlayer);
                //            Pldb.SubmitChanges();
                //IsolatedStorageSettings.ApplicationSettings["cur_uid"] = user.Text;
            }

            // NavigationService.Navigate(new Uri("/Prog.xaml", UriKind.Relative));
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text == counter.ToString())
            {
                score = score + size;

                consec_3++;
                consec_5++;
                consec_10++;
                //if (pl_cur.lvl_1_sc < score)
                //{
                //    pl_cur.lvl_1_sc = score;

                //}
                corr_count++;

                String t = score.ToString();
                scoreblock_ent.Text = t;

                textBox1.Text = "";
                rt.Play();
                wrong1.Stop();
                right1.Begin();
                ch       = true;
                gameover = 4;

                if (consec_10 == 3)
                {
                    pl_cur.corr_3 = true;

                    Pldb.SubmitChanges();
                }

                if (consec_10 == 5)
                {
                    pl_cur.corr_5 = true;
                    Pldb.SubmitChanges();
                }

                if (consec_10 == 10)
                {
                    pl_cur.corr_10 = true;
                    Pldb.SubmitChanges();
                }
            }

            else
            {
                right1.Stop();
                wr.Play();
                wrong1.Begin();
                ch        = false;
                consec_10 = 0;
                gameover--;
                if (gameover == 0)
                {
                    MessageBoxResult q = MessageBox.Show("Sorry!!you gave 4 consecutive wrong answers...Try Again!!!And burn the scoreboard with your concentration and reflexes!!!!!", "Game Over", MessageBoxButton.OK);
                    if (q == MessageBoxResult.OK)
                    {
                        d2 = DateTime.Now;
                        t  = d2 - d1;

                        if (pl_cur.lvl_1_sc < score)
                        {
                            pl_cur.lvl_1_sc = score;
                        }

                        if (t > t_parse)
                        {
                            pl_cur.lvl_1_ht = t.Hours.ToString() + ":" + t.Minutes.ToString() + ":" + t.Seconds;;
                        }
                        Pldb.SubmitChanges();
                        NavigationService.Navigate(new Uri("/level_2.xaml", UriKind.Relative));
                        //NavigationService.Navigate(new Uri(string.Format(NavigationService.Source +
                        //            "?Refresh=true&random={0}", Guid.NewGuid())));
                    }
                }
            }

            disp_num.IsEnabled    = true;
            disp_num.Opacity      = 100;
            check_score.Opacity   = 0;
            check_score.IsEnabled = false;
            if (corr_count > 5)
            {
                lvl2.IsEnabled = true;
                lvl2_unl.Text  = "CONGRATURATIONS!!!!!\r\nLEVEL 2 UNLOCKED";
            }
        }