private PairPics gerPairPics()//提示功能中,获得两个相同图像的按钮 { bool hinted = false; PairPics pairpics = new PairPics(); for (int i = 0; i < MAX_PIC; i++) { if (butArry[i].Visible) { for (int j = i + 1; j < MAX_PIC; j++) { int picType1 = myLogic.GetPicType(i); int picType2 = myLogic.GetPicType(j); if (picType1 == picType2 && butArry[j].Visible) { pairpics.PicNO1 = i; pairpics.PicNO2 = j; hinted = true; break; } } } if (hinted) { break; } else if (MAX_PIC - 1 == i) { return(null); } } return(pairpics); }
private void hintclicked(object sender, EventArgs e) { //bool hinted = false; //for (int i = 0; i < MAX_PIC; i++) //{ // if (butArry[i].Visible) // { // for (int j = i + 1; j < MAX_PIC; j++) // { // if ((int)btnVal[butArry[i]] == (int)btnVal[butArry[j]] && butArry[j].Visible) // { // for (int k = 0; k < 3; k++) // { // butArry[i].Visible = false; // butArry[j].Visible = false; // Thread.Sleep(200); // butArry[i].Visible = true; // butArry[j].Visible = true; // this.Refresh(); // Thread.Sleep(200); // } // hinted = true; // break; // } // } // } // if (hinted) // break; // else if (MAX_PIC - 1 == i) // MessageBox.Show("no Hint!!!"); //} PairPics pairpics = gerPairPics(); if (pairpics != null) { hintbtn.Enabled = false; for (int k = 0; k < 3; k++)//相同图像的按钮闪烁 { butArry[pairpics.PicNO1].Visible = false; butArry[pairpics.PicNO2].Visible = false; Thread.Sleep(100); butArry[pairpics.PicNO1].Visible = true; butArry[pairpics.PicNO2].Visible = true; this.Refresh(); Thread.Sleep(100); } hintbtn.Enabled = true; } else { MessageBox.Show("NO hint!!!"); } }
// // 提示功能移到logic中来 // public void hintclicked() { PairPics pairpics = gerPairPics(); if (pairpics != null) { gameArea.HintBlick(pairpics.PicNO1, pairpics.PicNO2, 3); } else { MessageBox.Show("NO hint!!!"); } }
private PairPics gerPairPics()//提示功能中,获得两个相同图像的按钮 { PairPics pairpics = new PairPics(); for (int i = 0; i < MAX_PIC; i++) { if (btnArry[i] != -1) { for (int j = i + 1; j < MAX_PIC; j++) { if (btnArry[j] != -1 && btnArry[i] == btnArry[j]) { pairpics.PicNO1 = i; pairpics.PicNO2 = j; return(pairpics); } } } } return(null); }