private void CircleButton_Again_Click(object sender, EventArgs e) { startGameForm newgame = new startGameForm(this.grand_parent_parent); this.parent.Close(); this.grand_parent.Close(); this.grand_parent_parent.Hide(); this.Close(); newgame.Show(); }
public GameForm(int isChallenge, int whatCharacter, startGameForm parent) { InitializeComponent(); DoubleBuffered = true; this.parent = parent; user_lives = 3; alock = new Bitmap("lock1.png"); creep = new Bitmap("creep.png"); heart = new Bitmap("heart.png"); index = 0; // 0: chua tra loi, 1: dung, 2:sai gameManager = new GameManager(isChallenge, whatCharacter); LoadQuestion(); sprite = gameManager.userCharacter.char_sprite; timer_ = new Timer(); timer_.Interval = 500; timer_.Enabled = true; timer_.Tick += new EventHandler(timer_Tick); /// timer_countdown = new Timer(); timer_countdown.Interval = 1000; timer_countdown.Enabled = true; timer_countdown.Tick += new EventHandler(timer_countdown_Tick); // gameManager.username = this.parent.guna2TextBox3.Text; // avatar = new Bitmap(gameManager.userCharacter.avatar); //pictureBox_avatar.BackColor = Color.Transparent; //gameManager.userCharacter.avatar.MakeTransparent(); //pictureBox_avatar.Image = gameManager.userCharacter.avatar; //pictureBox_avatar.SizeMode = PictureBoxSizeMode.Zoom; //Bitmap heart = new Bitmap("heart.png"); //heart.MakeTransparent(); //pictureBox_heart1.BackColor = Color.Transparent; //pictureBox_heart2.BackColor = Color.Transparent; //pictureBox_heart3.BackColor = Color.Transparent; //pictureBox_heart1.Image = heart; //pictureBox_heart2.Image = heart; //pictureBox_heart3.Image = heart; //pictureBox_heart1.SizeMode = PictureBoxSizeMode.Zoom; //pictureBox_heart2.SizeMode = PictureBoxSizeMode.Zoom; //pictureBox_heart3.SizeMode = PictureBoxSizeMode.Zoom; //username.Text = this.parent.guna2TextBox3.Text; //pictureBox_avatar.Image = gameManager.userCharacter.avatar; //username.Text = parent.guna2TextBox3.Text; }
private int pnl_number; // luc khoi tao thi dung de tao panel con luc chay thi dung de xac dinh dang o panel nao //public ResultForm() //{ // InitializeComponent(); //} public ResultForm(GameForm parent, startGameForm grand_parent, mainForm grand_parent_parent) { InitializeComponent(); listbtn = new Guna.UI2.WinForms.Guna2Button[parent.gameManager.quesData.number_question]; this.grand_parent = grand_parent; this.grand_parent_parent = grand_parent_parent; this.parent = parent; string a = "Câu "; // Tao so luong panel; if (parent.gameManager.quesData.number_question % 8 == 0) { listpnl = new Guna.UI2.WinForms.Guna2Panel[parent.gameManager.quesData.number_question / 8]; } else { listpnl = new Guna.UI2.WinForms.Guna2Panel[parent.gameManager.quesData.number_question / 8 + 1]; } for (int j = 0; j < listpnl.Length; j++) { listpnl[j] = new Guna.UI2.WinForms.Guna2Panel() { Location = new System.Drawing.Point(27, 120), Size = new System.Drawing.Size(284, 428) }; this.listpnl[j].BackColor = System.Drawing.Color.Transparent; this.Controls.Add(listpnl[j]); } pnl_number = 0; // Tao btn //for (int i = 0; i < parent.gameManager.quesData.number_question; i++) //{ // a = "Câu "; // a = a + (i + 1).ToString(); // listbtn[i] = new Guna.UI2.WinForms.Guna2Button() { Text = a, Size = new System.Drawing.Size(30, 50) }; // listbtn[i].BorderRadius = 20; // listbtn[i].Font = new System.Drawing.Font("Segoe UI", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); // if (this.parent.gameManager.quesData.Result[i] == 1) // { // //listbtn[i].FillColor = System.Drawing.SystemColors.ActiveCaption; // listbtn[i].FillColor = System.Drawing.Color.MediumSeaGreen; // } // else // { // listbtn[i].FillColor = System.Drawing.Color.IndianRed; // } // listbtn[i].ForeColor = System.Drawing.Color.White; // listpnl[pnl_number].Controls.Add(listbtn[i]); // if (pnl_member == 8) // { // pnl_member = 1; // pnl_number++; // } // else // { // pnl_member++; // } // listbtn[i].Dock = DockStyle.Top; // listbtn[i].Click += (s, e) => // { // //listpnl[current_question/8].BringToFront(); // foreach (Guna.UI2.WinForms.Guna2Button x in listbtn) // { // if (s == x) // { // string temp = x.Text.Substring(4); // current_question = Convert.ToInt32(temp); // OpenQuestion(Convert.ToInt32(temp) - 1); // } // } // }; // //if (i > this.parent.gameManager.current_ques_index) // //{ // // listbtn[i].Enabled = false; // //} // //listbtn[i].CheckedChanged += (s, e) => // //{ // // string temp = listbtn[i].Text.Substring(listbtn[i].Text.Length - 1, 1); // // OpenQuestion(Convert.ToInt32(temp)); // //}; //} //pnl_number = 0; // khoi tao khi mo form thi se mo panel 0 //listpnl[0].BringToFront(); for (int i = 0; listbtn[parent.gameManager.quesData.number_question - 1] == null;) { if (pnl_member + 8 * pnl_number > parent.gameManager.quesData.number_question) { pnl_member--; continue; } a = "Câu "; a = a + (pnl_member + 8 * pnl_number).ToString(); listbtn[i] = new Guna.UI2.WinForms.Guna2Button() { Text = a, Size = new System.Drawing.Size(30, 50) }; listbtn[i].BorderRadius = 20; listbtn[i].Font = new System.Drawing.Font("Segoe UI", 13F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); if (this.parent.gameManager.quesData.Result[Convert.ToInt32(listbtn[i].Text.Substring(4)) - 1] == 1) { //listbtn[i].FillColor = System.Drawing.SystemColors.ActiveCaption; listbtn[i].FillColor = System.Drawing.Color.MediumSeaGreen; } else { listbtn[i].FillColor = System.Drawing.Color.IndianRed; } listbtn[i].ForeColor = System.Drawing.Color.White; listpnl[pnl_number].Controls.Add(listbtn[i]); if (pnl_member <= 1) { pnl_member = 8; pnl_number++; } else { pnl_member--; } listbtn[i].Dock = DockStyle.Top; listbtn[i].Click += (s, e) => { panel_Question.BringToFront(); foreach (Guna.UI2.WinForms.Guna2Button x in listbtn) { if (s == x) { string temp = x.Text.Substring(4); current_question = Convert.ToInt32(temp); OpenQuestion(Convert.ToInt32(temp) - 1); } } }; string k = listbtn[i].Text.Substring(4); if (Convert.ToInt32(k) - 1 > this.parent.gameManager.current_ques_index) { //listbtn[i].Enabled = false; listbtn[i].FillColor = System.Drawing.Color.LightSlateGray; } i++; //listbtn[i].CheckedChanged += (s, e) => //{ // string temp = listbtn[i].Text.Substring(listbtn[i].Text.Length - 1, 1); // OpenQuestion(Convert.ToInt32(temp)); //}; } pnl_number = 0; // khoi tao khi mo form thi se mo panel 0 listpnl[0].BringToFront(); OpenQuestion(0); // vua mo len la load cau so 1 len lien :3 }