示例#1
0
        private void Sign_btn_Click_1(object sender, RoutedEventArgs e)
        {
            if (Ply2_txt.Text == "" || Ply1_txt.Text == "")
            {
                MessageBox.Show("Please enter name");
            }
            else
            {
                string Py1name = Ply1_txt.Text;
                string Py2name = Ply2_txt.Text;

                using (var db = new GamesDBEntities())
                {
                    Game newgame = new Game();
                    newgame.Name     = Ply1_txt.Text;
                    newgame.PingPong = 0;
                    newgame.Quiz     = 0;
                    newgame.Catch    = 0;
                    db.Games.Add(newgame);
                    db.SaveChanges();

                    Game newgame1 = new Game();
                    newgame1.Name     = Ply2_txt.Text;
                    newgame1.PingPong = 0;
                    newgame1.Quiz     = 0;
                    newgame1.Catch    = 0;
                    db.Games.Add(newgame1);
                    db.SaveChanges();
                }
            }
        }
示例#2
0
 void Initialize()
 {
     using (var db = new GamesDBEntities())
     {
         game = db.Games.ToList();
     }
 }
示例#3
0
        void Initialize()
        {
            using (var db = new GamesDBEntities())
            {
                games = db.Games.ToList();
                var p1 = new Game();
                p1     = db.Games.OrderByDescending(o => o.IdUser).Skip(1).First();
                p1Name = p1.Name;
                p1ID   = p1.IdUser;

                var p2 = new Game();
                p2     = db.Games.OrderByDescending(o => o.IdUser).First();
                p2Name = p2.Name;
                p2ID   = p2.IdUser;
            }
        }
示例#4
0
        public void dp_tick(object sender, EventArgs e)
        {
            ball.movement();
            jug1.movement();
            jug2.movement();
            if (ball.x <= 0)
            {
                ball.retex();
                pj2++;
                j2.Content = pj2;

                using (var db = new GamesDBEntities())
                {
                    Game updateply1 = new Game();
                    updateply1          = db.Games.Find(p1ID);
                    updateply1.PingPong = pj2;
                    db.SaveChanges();
                }
            }
            if (ball.x >= 570)
            {
                ball.retex();
                pj1++;
                j1.Content = pj1;

                using (var db = new GamesDBEntities())
                {
                    Game updateply2 = new Game();
                    updateply2          = db.Games.Find(p2ID);
                    updateply2.PingPong = pj1;
                    db.SaveChanges();
                }
            }
            if (ball.y <= 0 || ball.y >= 250)
            {
                ball.retey();
            }
            if (ball.x <= (jug1.x + jug1.w) && ball.y >= jug1.y && ball.y <= (jug1.y + jug1.h))
            {
                ball.retex();
            }
            if ((ball.x + ball.t) >= jug2.x && ball.y >= jug2.y && ball.y <= (jug2.y + jug2.h))
            {
                ball.retex();
            }
        }
示例#5
0
        private void Play2_btn_Click(object sender, RoutedEventArgs e)
        {
            Boolean winner = true;

            for (int j = 0; j < listBoxply2.SelectedItems.Count; j++)
            {
                char selectedChar = listBoxply2.SelectedItems[j].ToString()[0];
                if (m_to_remember.Contains(selectedChar) == false)
                {
                    winner = false;
                    break;
                }
                if (winner)
                {
                    P2counter++;
                    play2.Content = $"Player 2 score: {P2counter}";

                    using (var db = new GamesDBEntities())
                    {
                        Game updateply1 = new Game();
                        updateply1      = db.Games.Find(p1ID);
                        updateply1.Quiz = P1counter;
                        db.SaveChanges();

                        Game updateply2 = new Game();
                        updateply2      = db.Games.Find(p2ID);
                        updateply2.Quiz = P2counter;
                        db.SaveChanges();
                    }
                }

                else
                {
                    MessageBox.Show("Wrong Try again!");
                }
            }
        }
示例#6
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            db = new GamesDBEntities();

            gameData.ItemsSource = db.Games.ToList();
        }