110,534
社区成员
发帖
与我相关
我的任务
分享
private void 检查可消()
{
跟踪记录("检查可消");
int 行 = 0, 列 = 0, 查 = 1, 隔 = 2, 值1 = 0, 值2 = 0, 值3 = 0;
while (列 < 玩无限消乐.ColumnCount)
{/*不空之12同23同13同*/
值1 = (int)玩无限消乐.Rows[行].Cells[列].Tag;
值2 = (int)玩无限消乐.Rows[查].Cells[列].Tag;
值3 = (int)玩无限消乐.Rows[隔].Cells[列].Tag;
if (值1 != 0 && 值2 != 0 && 值3 != 0) if ((值1 == 值2) || (值2 == 值3) || (值1 == 值3))
{
if (值1 == 值2) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[行].Cells[列]; }));
if (值2 == 值3) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[查].Cells[列]; }));
if (值1 == 值3) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[隔].Cells[列]; }));
this.BeginInvoke(new Action(() => { 玩无限消乐.DefaultCellStyle.SelectionBackColor = Color.Red; }));
跟踪记录("检查定列结束\r\n"); return;
}
else
{
++行; ++查;
if (++隔 >= 玩无限消乐.RowCount)
{ 行 = 0; 查 = 1; 隔 = 2; ++列; }
}
}
行 = 列 = 0; 查 = 1; 隔 = 2;
while (行 < 玩无限消乐.RowCount)
{
值1 = (int)玩无限消乐.Rows[行].Cells[列].Tag;
值2 = (int)玩无限消乐.Rows[行].Cells[查].Tag;
值3 = (int)玩无限消乐.Rows[行].Cells[隔].Tag;
if (值1 != 0 && 值2 != 0 && 值3 != 0) if ((值1 == 值2) || (值2 == 值3) || (值1 == 值3))
{
if (值1 == 值2) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[行].Cells[列]; }));
if (值2 == 值3) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[行].Cells[查]; }));
if (值1 == 值3) this.BeginInvoke(new Action(() => { 玩无限消乐.CurrentCell = 玩无限消乐.Rows[行].Cells[隔]; }));
this.BeginInvoke(new Action(() => { 玩无限消乐.DefaultCellStyle.SelectionBackColor = Color.Red; }));
跟踪记录("检查定行结束\r\n"); return;
}
else
{
++列; ++查;
if (++隔 >= 玩无限消乐.ColumnCount)
{ 列 = 0; 查 = 1; 隔 = 2; ++行; }
}
}
MessageBox.Show("已无可换,游戏结束!");
}
private void 填充检测(int 行数, int 列数)
{
int 选定 = 行数;
while (--选定 >= 0)/*按行移动*/
{
DataGridViewCell 填充单元 = 玩无限消乐.Rows[行数].Cells[列数];
DataGridViewCell 选定单元 = 玩无限消乐.Rows[选定].Cells[列数];
if ((int)选定单元.Tag != 0)
{
填充单元.Value = 选定单元.Value;
填充单元.Tag = 选定单元.Tag;
--行数;
}
}
修正如下:
private void 填充检测(int 行数, int 列数)
{
int 选定 = 行数;
while (--选定 >= 0)/*按行移动*/
{
DataGridViewCell 填充单元 = 玩无限消乐.Rows[行数].Cells[列数];
DataGridViewCell 选定单元 = 玩无限消乐.Rows[选定].Cells[列数];
object 交换图像, 交换数据;
if ((int)选定单元.Tag != 0)
{
交换图像 = 填充单元.Value;
交换数据 = 填充单元.Tag;
填充单元.Value = 选定单元.Value;
填充单元.Tag = 选定单元.Tag;
选定单元.Value = 交换图像;
选定单元.Tag = 交换数据;
--行数;
}
}
继续测试中看是否卡住
protected override void OnPaint(PaintEventArgs e)
{
try
{
IntPtr 动画 = e.Graphics.GetHdc();
if (!目前动画)
{
ImageAnimator.StopAnimate((Bitmap)玩无限消乐.CurrentCell.Value, new EventHandler(this.OnFrameChanged));
System.Threading.Thread.Sleep(200);
ImageAnimator.Animate((Bitmap)玩无限消乐.CurrentCell.Value, new EventHandler(this.OnFrameChanged));
目前动画 = true;
}
e.Graphics.ReleaseHdc(动画);
}
catch (Exception 捕获信息)
{
throw 捕获信息;
}
//catch { unchecked { } }
}