private void LinkGamePanel_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && !timeOver) { int click; if (e.X < imageWidthL * 10 && e.Y < imageWidthL * 10 && iconArray[e.X / imageWidthL, e.Y / imageWidthL] != 0) { click = e.X / imageWidthL + e.Y / imageWidthL * 10; } else { return; } if (click == cur) { return; } // Invalidate(new Rectangle(new Point((cur % 10) * imageWidthL + offside, (cur / 10) * imageWidthL + offside), new Size(imageWidthS, imageWidthS))); if (cur == -1) { cur = click; } else { if (FindPath(click, cur, CheckMethod.Try)) { ScoringEventArgs sea = new ScoringEventArgs(); sea.LType = iconArray[click % 10, click / 10]; ScoringEvent(this, sea); iconArray[click % 10, click / 10] = 0; iconArray[cur % 10, cur / 10] = 0; // Invalidate(new Rectangle(new Point((cur % 10) * imageWidthL + offside, (cur / 10) * imageWidthL + offside), new Size(imageWidthS, imageWidthS))); // Invalidate(new Rectangle(new Point((click % 10) * imageWidthL + offside, (click / 10) * imageWidthL + offside), new Size(imageWidthS, imageWidthS))); Sounder s = new Sounder("ok"); Thread.Sleep(200); } else { Sounder s = new Sounder("err"); } cur = -1; } if (IsGameEnd()) { GameWinEvent(this, e); return; } while (!GameAvail()) { Resort(); } // Invalidate(new Rectangle(new Point((cur % 10) * imageWidthL + offside, (cur / 10) * imageWidthL + offside), new Size(imageWidthS, imageWidthS))); Invalidate(); } }
private void myTimer1_TimeOutEvent(object sender, EventArgs e) { linkGamePanel1.TimeOver = true; Record r = new Record(); r.name = "???"; r.level = level; r.score = mark.Mark; r.time = DateTime.Now.ToString(); CheckResult cr = new CheckResult(); cr.Rank = gameSaver.FindRecord(r); Sounder sounder = new Sounder("ding"); cr.ShowDialog(); if (cr.Save) { r.name = cr.Sname; gameSaver.AddRecord(r); } }