Example #1
0
 private void BtnAnswer_Click(object sender, EventArgs e)
 {
     if (BoxAnswer.Text.Length > 1)
     {
         MessageBox.Show("You only can put 1 word");
     }
     else
     {
         //Set Label based on GameHelper
         LblAnswer.Text = gameplayHelper.Guest(BoxAnswer.Text[0]);
         BoxAnswer.Text = "";
         if (!LblAnswer.Text.Contains("_"))
         {
             questionIndex++;
             if (questionIndex >= db.Questions.Count() || questionIndex >= 10)
             {
                 MessageBox.Show("Terima kasih telah bermain");
                 this.Close();
             }
             point        += 10;
             LblPoint.Text = "Point : " + point.ToString();
             gameplayHelper.setQuestion(db.Questions.Find(randomNumber[questionIndex]));
             LblQuestion.Text = gameplayHelper.question.question;
             LblAnswer.Text   = gameplayHelper.Guest(' ');
         }
     }
 }
Example #2
0
        public Gameplay()
        {
            InitializeComponent();
            CenterToScreen();
            //Generate Random Number
            db = new DataConnection();
            //GET ALL QUESTION
            questions      = db.Questions.ToList();
            gameplayHelper = new GameplayHelper();
            //GENERATE RANDOM NUMBER FOR QUESTION
            randomNumber = new RandomGenerator().create(db.Questions.Count());
            Question que = questions[randomNumber[questionIndex]];

            gameplayHelper.setQuestion(que);
            LblQuestion.Text = gameplayHelper.question.question;
            LblAnswer.Text   = gameplayHelper.Guest(' ');
        }