private void Moving(Point point) { PictureBox a = FirstSelect.Pop(); a.Location = point; SecondSelect.Push(a); move++; label5.Text = string.Format("Số bước đi : {0}", move); FirstSelect = SecondSelect = null; ABoxPic.BackColor = BBoxPic.BackColor = CBoxPic.BackColor = System.Drawing.Color.Gray; if (RodC.Count == Level.Value && Level.Value != 9) { GiveUpButton.PerformClick(); MessageBox.Show("Bạn đã qua màn này. Mời bạn chơi level tiếp theo ", "CHÚC MỪNG!!!", MessageBoxButtons.OK, MessageBoxIcon.Stop); Level.Value = Level.Value + 1; PlayButton.PerformClick(); } else if (RodC.Count == Level.Value && Level.Value == 9) { GiveUpButton.PerformClick(); MessageBox.Show("Bạn đã vượt qua 9 màn, trò chơi kết thúc ", "CHÚC MỪNG!!!", MessageBoxButtons.OK, MessageBoxIcon.Stop); } //if(Level.Value<8,) //throw new NotImplementedException(); }
private void ProcessMovingDisc(PictureBox ClickedBox) { if (SecondSelect.Count == 0) { PictureBox a = FirstSelect.Peek(); Moving(new Point(ClickedBox.Location.X + (9 - (int.Parse(a.Tag.ToString()))) * 10, FirstY)); } else { PictureBox a = FirstSelect.Peek(); PictureBox b = SecondSelect.Peek(); if (int.Parse(a.Tag.ToString()) < int.Parse(b.Tag.ToString())) { Moving(new Point(ClickedBox.Location.X + (9 - (int.Parse(a.Tag.ToString()))) * 10, b.Location.Y - DiscHeight)); } else { SecondSelect = null; } } }