Пример #1
0
        private void menuItem2_Click(object sender, EventArgs e)
        {
            try
            {
                if ((menuItem2.Text == "Start") && (mikeman.Visible == true))
                {
                    //Play Gong tune

                    path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
                    //MessageBox.Show("Im gonna play!:"+path );


                    PlaySound(path + "\\chime_down.wav");

                    mikeman.Visible = false;
                    menuItem1.Text  = "End Turn";

                    //Ask User Questions
                    //Display the First Question of the first player
                    //Starting new game for a new player
                    menuItem2.Text = "Next";
                    curplayer++;
                    //Restarting a new game for a new player
                    labpname.Text = "Player " + curplayer.ToString();
                    labscore.Text = "0";
                    if (smode == 1)
                    {
                        //Single Player Game

                        //Setting the time duration
                        labtcount.Text = (nq * 10).ToString();

                        tcount = (nq * 10);

                        MessageBox.Show("You have " + tcount.ToString() + " seconds to complete the challenge! You must answer a minimum of 80% of the questions correctly to clear the game.");
                    }
                    else
                    {
                        labtcount.Text = "0";
                        tcount         = 0;
                    }
                    entirequestions();
                    tagging();
                    playgame();
                    scount = 0;
                    //Generate the first Quesiton
                    qcount = 0;
                    entirequestions();
                    tagging();
                    q1r.Visible   = false;
                    q2r.Visible   = false;
                    q3r.Visible   = false;
                    q4r.Visible   = false;
                    q1w.Visible   = false;
                    q2w.Visible   = false;
                    q3w.Visible   = false;
                    q4w.Visible   = false;
                    labc1.Enabled = true;
                    labc2.Enabled = true;
                    labc3.Enabled = true;
                    labc4.Enabled = true;
                    //Resume Game play
                    playgame();
                    return;
                }
                qcount++;
                q1r.Visible   = false;
                q2r.Visible   = false;
                q3r.Visible   = false;
                q4r.Visible   = false;
                q1w.Visible   = false;
                q2w.Visible   = false;
                q3w.Visible   = false;
                q4w.Visible   = false;
                labc1.Enabled = true;
                labc2.Enabled = true;
                labc3.Enabled = true;
                labc4.Enabled = true;
                //Check if another Question is left
                if (qcount < nq)
                {
                    //There is another Quesiton left
                    entirequestions();
                    tagging();
                    playgame();
                }
                else
                {
                    //Player has completed his turn
                    //Stop the game trackers
                    pausegame();
                    //Saving the scores and the times
                    pscore[curplayer - 1] = scount;
                    ptime[curplayer - 1]  = tcount;
                    menuItem2.Text        = "Start";
                    if ((nplay != 1) && (curplayer < nplay))
                    {
                        mikeman.Visible = true;
                        menuItem1.Text  = "";

                        labmik.Text = "Player " + (curplayer + 1).ToString();
                        flasher flashform = new flasher(tcount, scount, nq, curplayer, this);
                        flashform.Show();
                        flashform.BringToFront();
                    }
                    else
                    {
                        if (nplay == 1)
                        {
                            //There is only a single player
                            //Check for Scores
                            if ((scount >= 0.8 * nq))
                            {
                                //Sufficient scores obtained
                                final finalForm = new final(ptime, pscore, 1, tq, nq);
                                finalForm.Show();
                                this.Dispose();
                            }
                            else
                            {
                                //Insufficient Scoring
                                Nat natForm = new Nat(nq, tq, 2);
                                natForm.Show();
                                this.Dispose();
                            }
                        }
                        else
                        {
                            //This is the last player
                            if (quitcount == nplay)
                            {
                                //All have Quit
                                Allq allqform = new Allq();
                                allqform.Show();
                            }
                            else
                            {
                                final finalForm = new final(ptime, pscore, nplay, tq, nq);
                                finalForm.Show();
                            }
                            this.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }
Пример #2
0
        private void counter_Tick(object sender, EventArgs e)
        {
            try
            {
                //Check the pervious scores
                //Find the Best Score
                for (int i = 0; i < curplayer - 1; i++)
                {
                    if (ptime[i] == tcount)
                    {
                        if (pscore[i] > scount)
                        {
                            //Break the game
                            //Saving the scores and the times
                            pscore[curplayer - 1] = scount;
                            ptime[curplayer - 1]  = tcount;
                            pausegame();
                            PlaySound(path + "\\blip.wav");
                            MessageBox.Show("You have been knocked out. Player " + (i + 1).ToString() + " got " + pscore[i].ToString() + " points by this time!");
                            //Another player is on the roll
                            if ((nplay != 1) && (curplayer < nplay))
                            {
                                menuItem2.Text  = "Start";
                                mikeman.Visible = true;
                                menuItem1.Text  = "";


                                labmik.Text = "Player " + (curplayer + 1).ToString();
                                flasher flashform = new flasher(tcount, scount, nq, curplayer, this);
                                flashform.Show();
                                flashform.BringToFront();
                            }
                            else
                            {
                                //This is the last player

                                if (quitcount == nplay)
                                {
                                    //All have Quit
                                    Allq allqform = new Allq();
                                    allqform.Show();
                                }
                                else
                                {
                                    final finalForm = new final(ptime, pscore, nplay, tq, nq);
                                    finalForm.Show();
                                }
                                this.Dispose();
                            }
                            return;
                        }
                    }
                }

                labtcount.Text = (Int32.Parse(labtcount.Text) + 1).ToString();
                tcount++;
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }
Пример #3
0
        public void leavegame()
        {
            try
            {
                //Check if there is another player on line
                if (curplayer == 0)
                {
                    //First Player game incomplete - So, Quit the Game
                    this.Dispose();
                    return;
                }
                pausegame();
                if (nplay == 1)
                {
                    //There is only one player
                    pausegame();

                    this.Dispose();
                }
                else if (curplayer == nplay)
                {
                    //The Current player is the last player
                    pausegame();
                    pscore[curplayer - 1] = scount;
                    ptime[curplayer - 1]  = tcount;



                    if (quitcount == nplay)
                    {
                        //All have Quit
                        Allq allqform = new Allq();
                        allqform.Show();
                    }
                    else
                    {
                        final finalForm = new final(ptime, pscore, nplay, tq, nq);
                        finalForm.Show();
                    }

                    this.Dispose();
                }
                else
                {
                    //There are more players. So skip the current one
                    //Saving the scores and the times

                    //Set the mikeman ON

                    mikeman.Visible = true;

                    menuItem1.Text = "";

                    labmik.Text = "Player " + (curplayer + 1).ToString();

                    pscore[curplayer - 1] = scount;
                    ptime[curplayer - 1]  = tcount;

                    menuItem2.Text = "Start";

                    flasher flashform = new flasher(tcount, scount, nq, curplayer, this);

                    flashform.Show();
                }
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }