Esempio n. 1
0
        private void timer2_tick(object sender, EventArgs e)
        {
            if (roomform.parent.loginForm.parent.canRunTimer)
            {
                try
                {
                    time  += 0.1;
                    isdraw = 0;
                    if (Mycnt.State != ConnectionState.Open)
                    {
                        Mycnt.Open();
                    }
                    string         query = string.Format("SELECT * FROM ROOMRESULT WHERE ROOMID = '{0}'", roomform.room_info.RoomID);
                    SqlCommand     com   = new SqlCommand(query, Mycnt);
                    SqlDataAdapter da    = new SqlDataAdapter(com);
                    DataTable      dt    = new DataTable();
                    da.Fill(dt);
                    if (dt.Rows.Count < 1)
                    {
                        return;
                    }
                    else
                    {
                        result.Clear();
                        for (int i = 0; i < 9; i++)
                        {
                            result.Add(dt.Rows[0][i].ToString());
                        }
                    }
                    Mycnt.Close();
                    gameForm.Invalidate();
                    ///////////////////////////
                    if (time > 150 && (result[7] == "0" || result[8] == "0" || result[7] != "0" && result[8] != "0"))
                    {
                        timer2.Enabled = false;
                        if (resultform != null)
                        {
                            return;
                        }
                        resultform = new ResultForm2(roomform.parent, result);
                        for (int i = 3; i < 9; i++)
                        {
                            if (result[i] == "")
                            {
                                result[i] = "0";
                            }
                        }
                        switch (check_result())
                        {
                        case 1:
                        {
                            resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                            resultform.guna2HtmlLabel2.Text      = "VICTORY";
                            resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.ForestGreen;
                            break;
                        }

                        case 2:
                        {
                            resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                            resultform.guna2HtmlLabel2.Text      = "DRAW";
                            resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.DarkOrange;

                            break;
                        }

                        case 0:
                        {
                            resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                            resultform.guna2HtmlLabel2.Text      = "DEFEAT";
                            resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.DarkOliveGreen;

                            break;
                        }
                        }
                        if (roomform.ishost == 1)
                        {
                            resultform.guna2HtmlLabel_Score.Text = result[3];
                        }
                        else
                        {
                            resultform.guna2HtmlLabel_Score.Text = result[4];
                        }
                        this.Close();
                        resultform.Show();
                        timer2.Enabled = false;
                        timer3.Enabled = false;
                    }
                }
                catch (Exception)
                {
                    timer2.Enabled = false;
                }
            }
        }
Esempio n. 2
0
        private void check()
        {
            if (result.Count > 0)
            {
                if ((result[7] != "0" && result[8] != "0") || (result[5] != "0" && result[6] != "0"))
                {
                    push_result_to_data();
                    timer.Enabled = false;
                    if (resultform != null)
                    {
                        return;
                    }
                    resultform = new ResultForm2(roomform.parent, result);
                    switch (check_result())
                    {
                    case 1:
                    {
                        resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                        resultform.guna2HtmlLabel2.Text      = "VICTORY";
                        resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.ForestGreen;
                        break;
                    }

                    case 2:
                    {
                        resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                        resultform.guna2HtmlLabel2.Text      = "DRAW";
                        resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.DarkOrange;

                        break;
                    }

                    case 0:
                    {
                        resultform.guna2HtmlLabel1.Text      = roomform.Playername;
                        resultform.guna2HtmlLabel2.Text      = "DEFEAT";
                        resultform.guna2HtmlLabel2.ForeColor = System.Drawing.Color.DarkOliveGreen;

                        break;
                    }
                    }
                    if (roomform.ishost == 1)
                    {
                        resultform.guna2HtmlLabel_Score.Text = result[3];
                    }
                    else
                    {
                        resultform.guna2HtmlLabel_Score.Text = result[4];
                    }
                    this.Close();
                    resultform.Show();
                    timer2.Enabled = false;
                }
            }
            for (int i = 0; i < 10; i++)
            {
                if (Math.Abs(X_yasuo - game_creep[i].X_creep) <= 50 && Math.Abs(Y_yasuo - game_creep[i].Y_creep) <= 50 && game_creep[i].isCorrect == 2)
                {
                    game_host.current_question = i;
                    string[] value = game_creep[i].question.GetQuestion();
                    switch (game_creep[i].type)
                    {
                    case 1:
                    {
                        questionForm.guna2Panel1.Visible = true;
                        questionForm.guna2Panel1.BringToFront();
                        questionForm.guna2Button_question1.Text = value[0];
                        questionForm.guna2Button_answerA.Text   = process_answer(value[1]);
                        questionForm.guna2Button_answerB.Text   = process_answer(value[2]);
                        questionForm.guna2Button_answerC.Text   = process_answer(value[3]);
                        questionForm.guna2Button_answerD.Text   = process_answer(value[4]);

                        break;
                    }

                    case 2:
                    {
                        questionForm.guna2Panel2.Visible = true;
                        questionForm.guna2TextBox_answer2.Focus();
                        questionForm.guna2TextBox_answer2.Clear();
                        questionForm.guna2Panel2.BringToFront();
                        questionForm.guna2Button_question2.Text = value[0];
                        break;
                    }
                    }
                    isdraw = 0;
                    return;
                }
            }
        }