public void KhoiTaoOChua(Label[] labelOchua) { for (int i = 0; i < labelOchua.Length; i++) { if (i == 5 || i == 11 || i == 12 || i == 13) { MangOChua[i] = new OChua(0, i, GetLabel(labelOchua, i)); } else { MangOChua[i] = new OChua(5, i, GetLabel(labelOchua, i)); } } }
public int ThongBao(OChua ochua) { return(ochua.GetSoLuongDa()); }
//public void ThongBao(Button btn,OChua[] ochua) //{ // int dem = ochua[OHienTai].GetSoLuongDa(); // btn.Text = dem.ToString(); //} public void RaiQuan(OChua ochua, bool nguoichoi, bool huongdi, PictureBox[] mangbantay, Form a, Button btn) { OHienTai = ochua.GetViTriO(); int solgda = ochua.GetSoLuongDa(); btn.Text = solgda.ToString(); MangOChua[OHienTai].SetLabel(0); MangOChua[OHienTai].lbl_SucChua.Refresh(); mangbantay[OHienTai].Visible = true; if (OHienTai == 0) { mangbantay[11].Visible = false; } else { mangbantay[OHienTai - 1].Visible = false; } a.Refresh(); if (nguoichoi == true) { if (huongdi) // di qua ben phai { while (solgda != 0) { mangbantay[OHienTai].Visible = true; OHienTai++; if (OHienTai == 12) { OHienTai = 0; } mangbantay[OHienTai].Visible = true; if (OHienTai == 0) { mangbantay[11].Visible = false; } else { mangbantay[OHienTai - 1].Visible = false; } a.Refresh(); MangOChua[OHienTai].ThemDa(ochua.ThongTinVienDa(solgda - 1)); solgda--; btn.Text = solgda.ToString(); btn.Refresh(); Thread.Sleep(300); MangOChua[OHienTai].lbl_SucChua.Refresh(); } } else if (huongdi == false) // di sang ben trai { while (solgda != 0) { mangbantay[OHienTai].Visible = true; OHienTai--; if (OHienTai == -1) { OHienTai = 11; } mangbantay[OHienTai].Visible = true; if (OHienTai == 11) { mangbantay[0].Visible = false; } else { mangbantay[OHienTai + 1].Visible = false; } a.Refresh(); MangOChua[OHienTai].ThemDa(ochua.ThongTinVienDa(solgda - 1)); solgda--; btn.Text = solgda.ToString(); btn.Refresh(); Thread.Sleep(300); MangOChua[OHienTai].lbl_SucChua.Refresh(); } } } else // neu luot di la cua nguoi choi 2 { while (solgda != 0) { if (huongdi == false) // huong di qua ben trai { mangbantay[OHienTai].Visible = true; OHienTai++; if (OHienTai == 12) { OHienTai = 0; } mangbantay[OHienTai].Visible = true; if (OHienTai == 0) { mangbantay[11].Visible = false; } else { mangbantay[OHienTai - 1].Visible = false; } a.Refresh(); //if (OHienTai == 5) // OHienTai = 6; MangOChua[OHienTai].ThemDa(ochua.ThongTinVienDa(solgda - 1)); //mangbantay[OHienTai].Visible = true; solgda--; btn.Text = solgda.ToString(); btn.Refresh(); Thread.Sleep(500); MangOChua[OHienTai].lbl_SucChua.Refresh(); //mangbantay[OHienTai].Visible = false; } else if (huongdi == true) // huong di qua ben phai { mangbantay[OHienTai].Visible = true; OHienTai--; if (OHienTai == -1) { OHienTai = 11; } mangbantay[OHienTai].Visible = true; if (OHienTai == 11) { mangbantay[0].Visible = false; } else { mangbantay[OHienTai + 1].Visible = false; } a.Refresh(); //if (OHienTai == 5) // OHienTai = 4; MangOChua[OHienTai].ThemDa(ochua.ThongTinVienDa(solgda - 1)); solgda--; btn.Text = solgda.ToString(); btn.Refresh(); Thread.Sleep(500); MangOChua[OHienTai].lbl_SucChua.Refresh(); } } } ochua.XoaDa(); Thread.Sleep(1000); mangbantay[OHienTai].Visible = false; }