想起以前高三的时候写过一个很无脑的程序,那个时候.net5.0都还没影儿呢,,现在分享一下。一个平面展开的魔方游戏。


这个是1.0版本,有些许bug。

  比如左边的格子操作不了。

「2d cube.exe」https://www.aliyundrive.com/s/4SMDcL8f8XK 点击链接保存,或者复制本段内容,打开「阿里云盘」APP ,无需下载极速在线查看,视频原画倍速播放。

exe程序:下载

源代码:下载


这个是2.0版本源码的下载链接 基本没有bug了,但是性能略微差,代码非常不整洁。

添加了一个面的置换功能,为缩减代码量铺路的功能。

最近一次优化也是两年前了,优化了映射关系,但是那个源代码找不到了。。


最终的版本晚一点再发出来吧,老文件太多找不到了。

另外大家有更好的设计思路吗?如何减少一一映射的次数等等。

1.0 主体代码


using System;
using System.Drawing;
using System.Windows.Forms; namespace _2d_cube
{
public partial class Form1 : Form
{ //////------0----参数初始化-----0------
const int N = 3; //按钮的行、列数
readonly Button[,,] buttons = new Button[6, N, N]; //按钮的数组
bool IsActive = false;
int formerN, formerX, formerY, latterN, latterX, latterY, temp;
string temp1, temp2;//用于储存第一,二个按钮的文本 ///------画面参数调节------
//方块位置大小参数
const int x0 = 300, y0 = 0, w = 50, d = 50; //字体参数
const Single single1 = 18F;
const string font1 = "微软雅黑"; ///------着色器参数------
// 1 区
readonly Color Color1 = Color.FromArgb(240, 248, 255);// 爱丽丝蓝(白)
// 2 区
readonly Color Color2 = Color.FromArgb(255, 140, 0);// 深橙色
// 3 区
readonly Color Color3 = Color.FromArgb(50, 205, 50);// 酸橙绿
// 4 区
readonly Color Color4 = Color.FromArgb(178, 34, 34);// 耐火砖
// 5 区
readonly Color Color5 = Color.FromArgb(30, 144, 255);// 道奇蓝
// 6 区
readonly Color Color6 = Color.FromArgb(240, 230, 140);// 卡其布(黄)
//不可用样式
readonly Color Color7 = Color.FromArgb(47, 79, 79);// 深石板灰
//待选样式
readonly Color Color8 = Color.FromArgb(219, 112, 147);//苍白的紫罗兰红色 //////------0-----画面调节参数完毕-----0------ //窗口初始化
public Form1()
{
InitializeComponent();
} //窗口加载
private void Form1_Load(object sender, EventArgs e)
{
Startgame();//生成棋盘
Shader(0);//启用着色器
this.BackColor = System.Drawing.SystemColors.MenuHighlight;//窗口上色
this.Name = "Form1";
this.Text = "2D cube Demo By Re";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.ClientSize = new System.Drawing.Size(601, 453);
} //关于About按钮事件
private void button_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi,im re", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
} //画面参数应用
Button SetStytle(Button btn)
{
btn.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
btn.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
return btn;
} //生成棋盘
void Startgame()
{ //组件生成开始
{
for (int r = 0; r < N; r++)//第一块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1).ToString();
btn.Top = y0 + r * d;
btn.Left = x0 + c * d;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[0, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
} for (int r = 0; r < N; r++)//第二块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 9 + 1).ToString();
btn.Top = y0 + r * d + 150;
btn.Left = x0 + c * d - 300;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c + 9; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[1, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
} for (int r = 0; r < N; r++)//第三块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 9 + 9 + 2).ToString();
btn.Top = y0 + r * d + 150;
btn.Left = x0 + c * d - 150;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c + 9 + 9; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[2, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
} for (int r = 0; r < N; r++)//第四块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 9 + 9 + 9 + 3).ToString();
btn.Top = y0 + r * d + 150;
btn.Left = x0 + c * d;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c + 9 + 9 + 9; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[3, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
} for (int r = 0; r < N; r++)//第五块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 9 + 9 + 9 + 9 + 4).ToString();
btn.Top = y0 + r * d + 150;
btn.Left = x0 + c * d + 150;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c + 9 + 9 + 9 + 9; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[4, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
} for (int r = 0; r < N; r++)//第六块区域生成
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 9 + 9 + 9 + 9 + 9 + 5).ToString();
btn.Top = y0 + r * d + 300;
btn.Left = x0 + c * d;
btn.Width = w;
btn.Height = w;
btn.Visible = true;
btn.Tag = r * N + c + 9 + 9 + 9 + 9 + 9; //这个数据用来表示它所在行列位置 //注册事件
btn.Click += new EventHandler(Btn_Click);
btn = SetStytle(btn);
buttons[5, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
}
}//生成按钮 {
Button button = new Button();
button.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
button.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
button.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
button.ForeColor = System.Drawing.Color.Black;
button.Location = new System.Drawing.Point(12, 12);
button.Name = "button1";
button.Size = new System.Drawing.Size(66, 66);
button.TabIndex = 0;
button.Text = "@";
button.UseVisualStyleBackColor = false;
button.Click += new EventHandler(button_Click);
this.Controls.Add(button); //加到界面上 Button buttonReset = new Button();
buttonReset.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
buttonReset.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
buttonReset.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
buttonReset.ForeColor = System.Drawing.Color.Black;
buttonReset.Location = new System.Drawing.Point(88, 12);
buttonReset.Name = "buttonReset";
buttonReset.Size = new System.Drawing.Size(66, 66);
buttonReset.TabIndex = 0;
buttonReset.Text = "Re";
buttonReset.UseVisualStyleBackColor = false;
buttonReset.Click += new EventHandler(BtnReset_Click1);
this.Controls.Add(buttonReset); //加到界面上
} //组件生成结束
} //重开重开
void BtnReset_Click1(object sender, EventArgs e)
{
this.Controls.Clear();
Refresh();
Startgame();
Shader(0);
IsActive = false;
} //按钮事件,也就是棋盘事件
void Btn_Click(object sender, EventArgs e)
{
Button btn = sender as Button; //当前点中的按钮 //处理第一个
if (!IsActive)
{
temp = int.Parse(btn.Text);
temp1 = btn.Text;
btn.Text = "";//将一选按钮清空
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = false;
buttons[p, r, c].BackColor = Color7;
if (buttons[p, r, c].Text == "")
{
formerN = p; formerX = r; formerY = c;
} }
//MessageBox.Show(formerN.ToString() + " " + formerX.ToString() + " " + formerY.ToString() + " " + temp1);
}//存储前者信息 Tick(btn);//选取三维的临块
IsActive = true;//激活二选状态 return;
} //现在处理第二个(二选状态)
temp2 = btn.Text;
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
//buttons[p, r, c].Enabled = false;
if (buttons[p, r, c].Text == temp2)
{
latterN = p; latterX = r; latterY = c;
//MessageBox.Show(formerN.ToString() + " " + formerX.ToString() + " " + formerY.ToString());
} }
//存储后者信息 buttons[formerN, formerX, formerY].Text = temp1;
Niumofang();
Clear();
Shader(0); } //选取三维中的临块
#pragma warning disable IDE0060 // 删除未使用的参数
void Tick(Button btn)
#pragma warning restore IDE0060 // 删除未使用的参数
{
int n, x, y;
n = 0;
x = 0;
y = 0; for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = false;
if (buttons[p, r, c].Text == "")
{
n = p; x = r; y = c; buttons[p, r, c].Enabled = true;
}
} if (x < 2) buttons[n, x + 1, y].Enabled = true;//单格子下方点亮
if (y < 2) buttons[n, x, y + 1].Enabled = true;//单格子右方点亮
if (y > 0) buttons[n, x, y - 1].Enabled = true;//单格子左方点亮
if (x > 0) buttons[n, x - 1, y].Enabled = true;//单格子左方点亮 //-----处理跨区域------
//白区域处理
if (n == 0 && x == 2) buttons[3, 0, y].Enabled = true;
if (n == 0 && x == 0) buttons[5, 2, y].Enabled = true;
if (n == 0 && y == 2) buttons[4, 0, 2 - x].Enabled = true;
if (n == 0 && y == 0) buttons[2, 0, x].Enabled = true;
//黄区域处理
if (n == 5 && x == 0) buttons[3, 2, y].Enabled = true;
if (n == 5 && x == 2) buttons[1, 2, 2 - y].Enabled = true;
if (n == 5 && y == 2) buttons[4, 2, x].Enabled = true;//黄到蓝
if (n == 5 && y == 0) buttons[2, 2, 2 - x].Enabled = true;
//橙区域处理
if (n == 1 && x == 0) buttons[0, 0, 2 - y].Enabled = true;//橙到白
if (n == 1 && y == 2) buttons[2, x, 0].Enabled = true;//橙到绿
if (n == 1 && y == 0) buttons[4, x, 2].Enabled = true;//橙到蓝
if (n == 1 && x == 2) buttons[5, 2, 2 - y].Enabled = true;//橙到黄
//绿区域处理
if (n == 2 && x == 0) buttons[0, y, 0].Enabled = true;//绿到白
if (n == 2 && y == 2) buttons[3, x, 0].Enabled = true;//绿到红
if (n == 2 && y == 0) buttons[1, x, 2].Enabled = true;//绿到橙
if (n == 2 && x == 2) buttons[5, 2 - y, 0].Enabled = true;//绿到黄
//红区域处理
if (n == 3 && x == 2) buttons[5, 0, y].Enabled = true;//红到黄
if (n == 3 && y == 2) buttons[4, x, 0].Enabled = true;//红到蓝
if (n == 3 && x == 0) buttons[0, 2, y].Enabled = true;//红到白
if (n == 3 && y == 0) buttons[2, x, 2].Enabled = true;//红到绿
//蓝区域处理
if (n == 4 && x == 2) buttons[5, y, 2].Enabled = true;//蓝到黄
if (n == 4 && y == 0) buttons[3, x, 2].Enabled = true;//蓝到红
if (n == 4 && x == 0) buttons[0, 2 - y, 2].Enabled = true;//蓝到白
if (n == 4 && y == 2) buttons[1, x, 0].Enabled = true;//蓝到橙
//-----处理跨区域结束------ //点亮
Shader(1); } //着色器
void Shader(int a)
{
if (a == 0)
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{ if (int.Parse(buttons[p, r, c].Text) < 10)
{
buttons[p, r, c].BackColor = Color1;
}
if (int.Parse(buttons[p, r, c].Text) > 10 && int.Parse(buttons[p, r, c].Text) < 20)
{
buttons[p, r, c].BackColor = Color2;
}
if (int.Parse(buttons[p, r, c].Text) > 20 && int.Parse(buttons[p, r, c].Text) < 30)
{
buttons[p, r, c].BackColor = Color3;
}
if (int.Parse(buttons[p, r, c].Text) > 30 && int.Parse(buttons[p, r, c].Text) < 40)
{
buttons[p, r, c].BackColor = Color4;
}
if (int.Parse(buttons[p, r, c].Text) > 40 && int.Parse(buttons[p, r, c].Text) < 50)
{
buttons[p, r, c].BackColor = Color5;
}
if (int.Parse(buttons[p, r, c].Text) > 50 && int.Parse(buttons[p, r, c].Text) < 60)
{
buttons[p, r, c].BackColor = Color6;
}
}
}
if (a == 1)
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{ if (buttons[p, r, c].Enabled == true)
{
buttons[p, r, c].BackColor = Color8;
}
}
}
} //扭动计算
void Niumofang()
{ //在区域1234----同一行----
if (latterN > 0 && latterN < 5 && formerN > 0 && formerN < 5 && latterX == formerX)
{
bool Key = false, TisLFisR = false;
/////判断左右
if (formerN == latterN && formerY > latterY) { TisLFisR = true; Key = true; }
else if (formerN == latterN && formerY < latterY) { TisLFisR = false; Key = true; }
if (formerN > latterN) { TisLFisR = true; Key = true; }
else if (formerN < latterN) { TisLFisR = false; Key = true; } ////处理上路---左右
if (latterX == 0 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 0, 0].Text;
a2 = buttons[1, 0, 1].Text;
a3 = buttons[1, 0, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{
buttons[1, 0, 0].Text = buttons[2, 0, 0].Text;
buttons[1, 0, 1].Text = buttons[2, 0, 1].Text;
buttons[1, 0, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[2, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[2, 0, 2].Text = buttons[3, 0, 2].Text; buttons[3, 0, 0].Text = buttons[4, 0, 0].Text;
buttons[3, 0, 1].Text = buttons[4, 0, 1].Text;
buttons[3, 0, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 0].Text = a1;
buttons[4, 0, 1].Text = a2;
buttons[4, 0, 2].Text = a3; a1 = buttons[0, 0, 0].Text;//此处重置了a1,处理白区域,对角 buttons[0, 0, 0].Text = buttons[0, 2, 0].Text;
buttons[0, 2, 0].Text = buttons[0, 2, 2].Text;
buttons[0, 2, 2].Text = buttons[0, 0, 2].Text;
buttons[0, 0, 2].Text = a1; a1 = buttons[0, 0, 1].Text;//此处重置了a1,处理白区域,
buttons[0, 0, 1].Text = buttons[0, 1, 0].Text;
buttons[0, 1, 0].Text = buttons[0, 2, 1].Text;
buttons[0, 2, 1].Text = buttons[0, 1, 2].Text;
buttons[0, 1, 2].Text = a1;
}
else
{
buttons[1, 0, 0].Text = buttons[4, 0, 0].Text;
buttons[1, 0, 1].Text = buttons[4, 0, 1].Text;
buttons[1, 0, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[4, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[4, 0, 2].Text = buttons[3, 0, 2].Text; buttons[3, 0, 0].Text = buttons[2, 0, 0].Text;
buttons[3, 0, 1].Text = buttons[2, 0, 1].Text;
buttons[3, 0, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 0].Text = a1;
buttons[2, 0, 1].Text = a2;
buttons[2, 0, 2].Text = a3; a1 = buttons[0, 0, 0].Text;//此处重置了a1,处理白区域,对角
buttons[0, 0, 0].Text = buttons[0, 0, 2].Text;
buttons[0, 0, 2].Text = buttons[0, 2, 2].Text;
buttons[0, 2, 2].Text = buttons[0, 2, 0].Text;
buttons[0, 2, 0].Text = a1; a1 = buttons[0, 0, 1].Text;//此处重置了a1,处理白区域,对边
buttons[0, 0, 1].Text = buttons[0, 1, 2].Text;
buttons[0, 1, 2].Text = buttons[0, 2, 1].Text;
buttons[0, 2, 1].Text = buttons[0, 1, 0].Text;
buttons[0, 1, 0].Text = a1; } } ////处理中路---左右
if (latterX == 1 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 1, 0].Text;
a2 = buttons[1, 1, 1].Text;
a3 = buttons[1, 1, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{ buttons[1, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[2, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[2, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = a1;
buttons[4, 1, 1].Text = a2;
buttons[4, 1, 2].Text = a3;
}
else
{
buttons[1, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[4, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[4, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = a1;
buttons[2, 1, 1].Text = a2;
buttons[2, 1, 2].Text = a3;
} } ////处理下路---左右
if (latterX == 2 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 2, 0].Text;
a2 = buttons[1, 2, 1].Text;
a3 = buttons[1, 2, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{
buttons[1, 2, 0].Text = buttons[2, 2, 0].Text;
buttons[1, 2, 1].Text = buttons[2, 2, 1].Text;
buttons[1, 2, 2].Text = buttons[2, 2, 2].Text; buttons[2, 2, 0].Text = buttons[3, 2, 0].Text;
buttons[2, 2, 1].Text = buttons[3, 2, 1].Text;
buttons[2, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 2, 0].Text = buttons[4, 2, 0].Text;
buttons[3, 2, 1].Text = buttons[4, 2, 1].Text;
buttons[3, 2, 2].Text = buttons[4, 2, 2].Text; buttons[4, 2, 0].Text = a1;
buttons[4, 2, 1].Text = a2;
buttons[4, 2, 2].Text = a3; a1 = buttons[5, 0, 0].Text;//此处重置了a1,处理黄区域,对角
buttons[5, 0, 0].Text = buttons[5, 0, 2].Text;
buttons[5, 0, 2].Text = buttons[5, 2, 2].Text;
buttons[5, 2, 2].Text = buttons[5, 2, 0].Text;
buttons[5, 2, 0].Text = a1; a1 = buttons[5, 0, 1].Text;//此处重置了a1,处理黄区域,对边
buttons[5, 0, 1].Text = buttons[5, 1, 2].Text;
buttons[5, 1, 2].Text = buttons[5, 2, 1].Text;
buttons[5, 2, 1].Text = buttons[5, 1, 0].Text;
buttons[5, 1, 0].Text = a1; }
else
{ buttons[1, 2, 0].Text = buttons[4, 2, 0].Text;
buttons[1, 2, 1].Text = buttons[4, 2, 1].Text;
buttons[1, 2, 2].Text = buttons[4, 2, 2].Text; buttons[4, 2, 0].Text = buttons[3, 2, 0].Text;
buttons[4, 2, 1].Text = buttons[3, 2, 1].Text;
buttons[4, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 2, 0].Text = buttons[2, 2, 0].Text;
buttons[3, 2, 1].Text = buttons[2, 2, 1].Text;
buttons[3, 2, 2].Text = buttons[2, 2, 2].Text; buttons[2, 2, 0].Text = a1;
buttons[2, 2, 1].Text = a2;
buttons[2, 2, 2].Text = a3; a1 = buttons[5, 0, 0].Text;//此处重置了a1,处理白区域,对角 buttons[5, 0, 0].Text = buttons[5, 2, 0].Text;
buttons[5, 2, 0].Text = buttons[5, 2, 2].Text;
buttons[5, 2, 2].Text = buttons[5, 0, 2].Text;
buttons[5, 0, 2].Text = a1; a1 = buttons[5, 0, 1].Text;//此处重置了a1,处理白区域,
buttons[5, 0, 1].Text = buttons[5, 1, 0].Text;
buttons[5, 1, 0].Text = buttons[5, 2, 1].Text;
buttons[5, 2, 1].Text = buttons[5, 1, 2].Text;
buttons[5, 1, 2].Text = a1; } }
return;
} /////处理白红黄---上下--y=0
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 0 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}//特殊情况 if (latterN > formerN)//向下
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}
else if (latterN < formerN)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else if (latterN == formerN) if (latterX > formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else Clear();
} /////处理白红黄---上下--y=1
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 1 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}//特殊情况 if (latterN > formerN)//向下
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}
else if (latterN < formerN)//Up
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else if (latterN == formerN) if (latterX > formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else Clear();
} /////处理白红黄---上下--y=2
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 2 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
} if (latterN > formerN)//down
{ string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
}
else if (latterN < formerN)//Up
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else if (latterN == formerN) if (latterX > formerX)//Down
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else Clear(); }
//////二环临时变量
bool tem0, tem1, tem2, tem3, tem4, tem5, tem6, tem7, tem8;
tem0 = false;
/////处理二环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 1;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 1;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 1;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 1;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 1;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 1;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 1;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 1;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 1, 0].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 1, 2].Text; buttons[0, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[0, 1, 2].Text = buttons[2, 0, 1].Text; buttons[2, 0, 1].Text = buttons[5, 1, 0].Text;
buttons[2, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[2, 2, 1].Text = buttons[5, 1, 2].Text; buttons[5, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[5, 1, 2].Text = buttons[4, 0, 1].Text; buttons[4, 0, 1].Text = a1;
buttons[4, 1, 1].Text = a2;
buttons[4, 2, 1].Text = a3;
return;
}
/////处理二环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 1;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 1;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 1;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 1;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 1;
tem6 = latterN == 0 && formerN == 4 && formerY == 1;
tem7 = latterN == 4 && formerN == 5 && formerX == 1;
tem8 = latterN == 5 && formerN == 2 && formerY == 1;
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 1, 0].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 1, 2].Text; buttons[0, 1, 0].Text = buttons[4, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[0, 1, 2].Text = buttons[4, 2, 1].Text; buttons[4, 0, 1].Text = buttons[5, 1, 2].Text;
buttons[4, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[4, 2, 1].Text = buttons[5, 1, 0].Text; buttons[5, 1, 0].Text = buttons[2, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[5, 1, 2].Text = buttons[2, 2, 1].Text; buttons[2, 0, 1].Text = a3;
buttons[2, 1, 1].Text = a2;
buttons[2, 2, 1].Text = a1;
return;
} /////处理一环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 2;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 2;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 0;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 0;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 2;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 2;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 0;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 0;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 2, 0].Text;
a2 = buttons[0, 2, 1].Text;
a3 = buttons[0, 2, 2].Text; buttons[0, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[0, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 2].Text = buttons[5, 0, 0].Text;
buttons[2, 1, 2].Text = buttons[5, 0, 1].Text;
buttons[2, 2, 2].Text = buttons[5, 0, 2].Text; buttons[5, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[5, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[5, 0, 2].Text = buttons[4, 0, 0].Text; buttons[4, 0, 0].Text = a1;
buttons[4, 1, 0].Text = a2;
buttons[4, 2, 0].Text = a3; a1 = buttons[3, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[3, 0, 0].Text = buttons[3, 2, 0].Text;
buttons[3, 2, 0].Text = buttons[3, 2, 2].Text;
buttons[3, 2, 2].Text = buttons[3, 0, 2].Text;
buttons[3, 0, 2].Text = a1; a1 = buttons[3, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[3, 0, 1].Text = buttons[3, 1, 0].Text;
buttons[3, 1, 0].Text = buttons[3, 2, 1].Text;
buttons[3, 2, 1].Text = buttons[3, 1, 2].Text;
buttons[3, 1, 2].Text = a1;
return;
} /////处理一环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 2;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 2;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 0;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 0;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 2;//
tem6 = latterN == 0 && formerN == 4 && formerY == 0;//
tem7 = latterN == 4 && formerN == 5 && formerX == 0;//
tem8 = latterN == 5 && formerN == 2 && formerY == 2;//
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 2, 0].Text;
a2 = buttons[0, 2, 1].Text;
a3 = buttons[0, 2, 2].Text; buttons[0, 2, 0].Text = buttons[4, 0, 0].Text;
buttons[0, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[4, 2, 0].Text; buttons[4, 0, 0].Text = buttons[5, 0, 2].Text;
buttons[4, 1, 0].Text = buttons[5, 0, 1].Text;
buttons[4, 2, 0].Text = buttons[5, 0, 0].Text; buttons[5, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[5, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[5, 0, 2].Text = buttons[2, 2, 2].Text; buttons[2, 0, 2].Text = a3;
buttons[2, 1, 2].Text = a2;
buttons[2, 2, 2].Text = a1; a1 = buttons[3, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[3, 0, 0].Text = buttons[3, 0, 2].Text;
buttons[3, 0, 2].Text = buttons[3, 2, 2].Text;
buttons[3, 2, 2].Text = buttons[3, 2, 0].Text;
buttons[3, 2, 0].Text = a1; a1 = buttons[3, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[3, 0, 1].Text = buttons[3, 1, 2].Text;
buttons[3, 1, 2].Text = buttons[3, 2, 1].Text;
buttons[3, 2, 1].Text = buttons[3, 1, 0].Text;
buttons[3, 1, 0].Text = a1;
return;
} /////处理三环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 0;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 0;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 2;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 2;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 0;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 0;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 2;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 2;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 0, 1].Text;
a3 = buttons[0, 0, 2].Text; buttons[0, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[0, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[0, 0, 2].Text = buttons[2, 0, 0].Text; buttons[2, 0, 0].Text = buttons[5, 2, 0].Text;
buttons[2, 1, 0].Text = buttons[5, 2, 1].Text;
buttons[2, 2, 0].Text = buttons[5, 2, 2].Text; buttons[5, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[5, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 2].Text = a1;
buttons[4, 1, 2].Text = a2;
buttons[4, 2, 2].Text = a3; a1 = buttons[1, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[1, 0, 0].Text = buttons[1, 0, 2].Text;
buttons[1, 0, 2].Text = buttons[1, 2, 2].Text;
buttons[1, 2, 2].Text = buttons[1, 2, 0].Text;
buttons[1, 2, 0].Text = a1; a1 = buttons[1, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[1, 0, 1].Text = buttons[1, 1, 2].Text;
buttons[1, 1, 2].Text = buttons[1, 2, 1].Text;
buttons[1, 2, 1].Text = buttons[1, 1, 0].Text;
buttons[1, 1, 0].Text = a1;
return;
}
/////处理三环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 0;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 0;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 2;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 2;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 0;//
tem6 = latterN == 0 && formerN == 4 && formerY == 2;//
tem7 = latterN == 4 && formerN == 5 && formerX == 2;//
tem8 = latterN == 5 && formerN == 2 && formerY == 0;//
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 0, 1].Text;
a3 = buttons[0, 0, 2].Text; buttons[0, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[0, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[0, 0, 2].Text = buttons[4, 2, 2].Text; buttons[4, 0, 2].Text = buttons[5, 2, 2].Text;
buttons[4, 1, 2].Text = buttons[5, 2, 1].Text;
buttons[4, 2, 2].Text = buttons[5, 2, 0].Text; buttons[5, 2, 0].Text = buttons[2, 0, 0].Text;
buttons[5, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[2, 2, 0].Text; buttons[2, 0, 0].Text = a3;
buttons[2, 1, 0].Text = a2;
buttons[2, 2, 0].Text = a1; a1 = buttons[1, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[1, 0, 0].Text = buttons[1, 2, 0].Text;
buttons[1, 2, 0].Text = buttons[1, 2, 2].Text;
buttons[1, 2, 2].Text = buttons[1, 0, 2].Text;
buttons[1, 0, 2].Text = a1; a1 = buttons[1, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[1, 0, 1].Text = buttons[1, 1, 0].Text;
buttons[1, 1, 0].Text = buttons[1, 2, 1].Text;
buttons[1, 2, 1].Text = buttons[1, 1, 2].Text;
buttons[1, 1, 2].Text = a1;
}
} //可用
void Clear()
{
IsActive = false;
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = true; }
} }
}


using System;
using System.Drawing;
using System.Windows.Forms; namespace _2d_cube
{
public partial class Form1 : Form
{ //////------0----参数初始化-----0------
const int N = 3; //按钮的行、列数
readonly Button[,,] buttons = new Button[6, N, N]; //按钮的数组
bool IsActive = false;
int formerN, formerX, formerY, latterN, latterX, latterY, temp;
string temp1, temp2;//用于储存第一,二个按钮的文本 ///------画面参数调节------
//方块位置大小参数
const int x0 = 300, y0 = 0, w = 50, d = 50; //字体参数
const Single single1 = 18F;
const string font1 = "微软雅黑"; ///------着色器参数------
// 1 区
readonly Color Color1 = Color.FromArgb(240, 248, 255);// 爱丽丝蓝(白)
// 2 区
readonly Color Color2 = Color.FromArgb(255, 140, 0);// 深橙色
// 3 区
readonly Color Color3 = Color.FromArgb(50, 205, 50);// 酸橙绿
// 4 区
readonly Color Color4 = Color.FromArgb(178, 34, 34);// 耐火砖
// 5 区
readonly Color Color5 = Color.FromArgb(30, 144, 255);// 道奇蓝
// 6 区
readonly Color Color6 = Color.FromArgb(240, 230, 140);// 卡其布(黄)
//不可用样式
readonly Color Color7 = Color.FromArgb(47, 79, 79);// 深石板灰
//待选样式
readonly Color Color8 = Color.FromArgb(219, 112, 147);//苍白的紫罗兰红色 //////------0-----画面调节参数完毕-----0------ //窗口初始化
public Form1()
{
InitializeComponent();
} //窗口加载
private void Form1_Load(object sender, EventArgs e)
{
Startgame();//生成棋盘
Shader(0);//启用着色器
this.BackColor = System.Drawing.SystemColors.MenuHighlight;//窗口上色
this.Name = "Form1";
this.Text = "2D cube Demo By Re";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.ClientSize = new System.Drawing.Size(601, 453);
} //关于About按钮事件
private void button_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi,im re\n你好,我是Re", "About", MessageBoxButtons.OK, MessageBoxIcon.Information);
} //画面参数应用
Button SetStytle(Button btn)
{
btn.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
btn.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
return btn;
} //生成棋盘
void Startgame()
{ //组件生成开始
{
for (int k = 0; k < 6; k++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
int num = r * N + c;
Button btn = new Button();
btn.Text = (num + 1 + 10 * k).ToString();//k=0 output = 1
if (k == 0) { btn.Top = y0 + r * d; btn.Left = x0 + c * d; }
else if (k == 5) { btn.Top = y0 + r * d + 300; btn.Left = x0 + c * d; }
else if (k != 0 && k != 5) { btn.Top = y0 + r * d + 150; btn.Left = x0 + c * d - 150 * (3 - k); }
btn.Size = new Size(w, w);
btn.Visible = true;
btn.Click += new EventHandler(Btn_Click);//注册事件
btn = SetStytle(btn);
buttons[k, r, c] = btn; //放到数组中
this.Controls.Add(btn); //加到界面上
}
}//生成按钮
{
Button button = new Button();
button.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
button.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
button.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
button.Location = new System.Drawing.Point(12, 12);
button.Name = "button1";
button.Size = new System.Drawing.Size(66, 66);
button.Text = "@";
button.Click += new EventHandler(button_Click);
this.Controls.Add(button); //加到界面上
Button buttonReset = new Button();
buttonReset.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
button.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
buttonReset.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
buttonReset.Location = new System.Drawing.Point(88, 12);
buttonReset.Name = "buttonReset";
buttonReset.Size = new System.Drawing.Size(66, 66);
buttonReset.Text = "Re";
buttonReset.Click += new EventHandler(BtnReset_Click1);
this.Controls.Add(buttonReset); //加到界面上
Button buttonChangeFace = new Button();
buttonChangeFace.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
buttonChangeFace.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
buttonChangeFace.Font = new System.Drawing.Font(font1, single1, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
buttonChangeFace.Location = new System.Drawing.Point(168, 12);
buttonChangeFace.Name = "buttonChangeface";
buttonChangeFace.Size = new System.Drawing.Size(66, 66);
buttonChangeFace.Text = "buttonChangeFace";
buttonChangeFace.Click += new EventHandler(buttonChangeFace_Click);
this.Controls.Add(buttonChangeFace); //加到界面上
}
//组件生成结束
} void buttonChangeFace_Click(object sender, EventArgs e)
{
ChangeFaceInput(0);
}
//重开重开
void BtnReset_Click1(object sender, EventArgs e)
{
this.Controls.Clear(); Startgame();
Shader(0);
IsActive = false;
} //按钮事件,也就是棋盘事件
void Btn_Click(object sender, EventArgs e)
{
Button btn = sender as Button; //当前点中的按钮
//处理第一个
if (!IsActive)
{
temp = int.Parse(btn.Text);
temp1 = btn.Text;
btn.Text = "";//将一选按钮清空
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = false;
buttons[p, r, c].BackColor = Color7;
if (buttons[p, r, c].Text == "")
{
formerN = p; formerX = r; formerY = c;
}
}
}//存储前者信息
Tick(btn);//选取三维的临块
IsActive = true;//激活二选状态
return;
}
//现在处理第二个(二选状态)
temp2 = btn.Text;
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
if (buttons[p, r, c].Text == temp2)
{
latterN = p; latterX = r; latterY = c;
}
}
//存储后者信息
buttons[formerN, formerX, formerY].Text = temp1;
Niumofang();
Clear();
Shader(0);
} //选取三维中的临块
#pragma warning disable IDE0060 // 删除未使用的参数
void Tick(Button btn)
#pragma warning restore IDE0060 // 删除未使用的参数
{
int n, x, y; n = 0; x = 0; y = 0; for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = false;
if (buttons[p, r, c].Text == "")
{
n = p; x = r; y = c; buttons[p, r, c].Enabled = true;
}
} if (x < 2) buttons[n, x + 1, y].Enabled = true;//单格子下方点亮
if (y < 2) buttons[n, x, y + 1].Enabled = true;//单格子右方点亮
if (y > 0) buttons[n, x, y - 1].Enabled = true;//单格子左方点亮
if (x > 0) buttons[n, x - 1, y].Enabled = true;//单格子左方点亮 //-----处理跨区域------
//白区域处理
if (n == 0 && x == 2) buttons[3, 0, y].Enabled = true;
if (n == 0 && x == 0) buttons[5, 2, y].Enabled = true;
if (n == 0 && y == 2) buttons[4, 0, 2 - x].Enabled = true;
if (n == 0 && y == 0) buttons[2, 0, x].Enabled = true;
//黄区域处理
if (n == 5 && x == 0) buttons[3, 2, y].Enabled = true;
if (n == 5 && x == 2) buttons[1, 2, 2 - y].Enabled = true;
if (n == 5 && y == 2) buttons[4, 2, x].Enabled = true;//黄到蓝
if (n == 5 && y == 0) buttons[2, 2, 2 - x].Enabled = true;
//橙区域处理
if (n == 1 && x == 0) buttons[0, 0, 2 - y].Enabled = true;//橙到白
if (n == 1 && y == 2) buttons[2, x, 0].Enabled = true;//橙到绿
if (n == 1 && y == 0) buttons[4, x, 2].Enabled = true;//橙到蓝
if (n == 1 && x == 2) buttons[5, 2, 2 - y].Enabled = true;//橙到黄
//绿区域处理
if (n == 2 && x == 0) buttons[0, y, 0].Enabled = true;//绿到白
if (n == 2 && y == 2) buttons[3, x, 0].Enabled = true;//绿到红
if (n == 2 && y == 0) buttons[1, x, 2].Enabled = true;//绿到橙
if (n == 2 && x == 2) buttons[5, 2 - y, 0].Enabled = true;//绿到黄
//红区域处理
if (n == 3 && x == 2) buttons[5, 0, y].Enabled = true;//红到黄
if (n == 3 && y == 2) buttons[4, x, 0].Enabled = true;//红到蓝
if (n == 3 && x == 0) buttons[0, 2, y].Enabled = true;//红到白
if (n == 3 && y == 0) buttons[2, x, 2].Enabled = true;//红到绿
//蓝区域处理
if (n == 4 && x == 2) buttons[5, y, 2].Enabled = true;//蓝到黄
if (n == 4 && y == 0) buttons[3, x, 2].Enabled = true;//蓝到红
if (n == 4 && x == 0) buttons[0, 2 - y, 2].Enabled = true;//蓝到白
if (n == 4 && y == 2) buttons[1, x, 0].Enabled = true;//蓝到橙
//-----处理跨区域结束------ //点亮
Shader(1);
} //着色器
void Shader(int a)
{
if (a == 0)
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{ if (int.Parse(buttons[p, r, c].Text) < 10)
{
buttons[p, r, c].BackColor = Color1;
}
if (int.Parse(buttons[p, r, c].Text) > 10 && int.Parse(buttons[p, r, c].Text) < 20)
{
buttons[p, r, c].BackColor = Color2;
}
if (int.Parse(buttons[p, r, c].Text) > 20 && int.Parse(buttons[p, r, c].Text) < 30)
{
buttons[p, r, c].BackColor = Color3;
}
if (int.Parse(buttons[p, r, c].Text) > 30 && int.Parse(buttons[p, r, c].Text) < 40)
{
buttons[p, r, c].BackColor = Color4;
}
if (int.Parse(buttons[p, r, c].Text) > 40 && int.Parse(buttons[p, r, c].Text) < 50)
{
buttons[p, r, c].BackColor = Color5;
}
if (int.Parse(buttons[p, r, c].Text) > 50 && int.Parse(buttons[p, r, c].Text) < 60)
{
buttons[p, r, c].BackColor = Color6;
}
}
}
if (a == 1)
{
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
if (buttons[p, r, c].Enabled == true)
{
buttons[p, r, c].BackColor = Color8;
}
}
}
} //扭动计算
void Niumofang()
{ //在区域1234----同一行----
if (latterN > 0 && latterN < 5 && formerN > 0 && formerN < 5 && latterX == formerX)
{
bool Key = false, TisLFisR = false;
/////判断左右
if (formerN == latterN && formerY > latterY) { TisLFisR = true; Key = true; }
else if (formerN == latterN && formerY < latterY) { TisLFisR = false; Key = true; }
if (formerN > latterN) { TisLFisR = true; Key = true; }
else if (formerN < latterN) { TisLFisR = false; Key = true; } ////处理上路---左右
if (latterX == 0 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 0, 0].Text;
a2 = buttons[1, 0, 1].Text;
a3 = buttons[1, 0, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{
buttons[1, 0, 0].Text = buttons[2, 0, 0].Text;
buttons[1, 0, 1].Text = buttons[2, 0, 1].Text;
buttons[1, 0, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[2, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[2, 0, 2].Text = buttons[3, 0, 2].Text; buttons[3, 0, 0].Text = buttons[4, 0, 0].Text;
buttons[3, 0, 1].Text = buttons[4, 0, 1].Text;
buttons[3, 0, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 0].Text = a1;
buttons[4, 0, 1].Text = a2;
buttons[4, 0, 2].Text = a3; a1 = buttons[0, 0, 0].Text;//此处重置了a1,处理白区域,对角 buttons[0, 0, 0].Text = buttons[0, 2, 0].Text;
buttons[0, 2, 0].Text = buttons[0, 2, 2].Text;
buttons[0, 2, 2].Text = buttons[0, 0, 2].Text;
buttons[0, 0, 2].Text = a1; a1 = buttons[0, 0, 1].Text;//此处重置了a1,处理白区域,
buttons[0, 0, 1].Text = buttons[0, 1, 0].Text;
buttons[0, 1, 0].Text = buttons[0, 2, 1].Text;
buttons[0, 2, 1].Text = buttons[0, 1, 2].Text;
buttons[0, 1, 2].Text = a1;
}
else
{
buttons[1, 0, 0].Text = buttons[4, 0, 0].Text;
buttons[1, 0, 1].Text = buttons[4, 0, 1].Text;
buttons[1, 0, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[4, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[4, 0, 2].Text = buttons[3, 0, 2].Text; buttons[3, 0, 0].Text = buttons[2, 0, 0].Text;
buttons[3, 0, 1].Text = buttons[2, 0, 1].Text;
buttons[3, 0, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 0].Text = a1;
buttons[2, 0, 1].Text = a2;
buttons[2, 0, 2].Text = a3; a1 = buttons[0, 0, 0].Text;//此处重置了a1,处理白区域,对角
buttons[0, 0, 0].Text = buttons[0, 0, 2].Text;
buttons[0, 0, 2].Text = buttons[0, 2, 2].Text;
buttons[0, 2, 2].Text = buttons[0, 2, 0].Text;
buttons[0, 2, 0].Text = a1; a1 = buttons[0, 0, 1].Text;//此处重置了a1,处理白区域,对边
buttons[0, 0, 1].Text = buttons[0, 1, 2].Text;
buttons[0, 1, 2].Text = buttons[0, 2, 1].Text;
buttons[0, 2, 1].Text = buttons[0, 1, 0].Text;
buttons[0, 1, 0].Text = a1; } } ////处理中路---左右
if (latterX == 1 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 1, 0].Text;
a2 = buttons[1, 1, 1].Text;
a3 = buttons[1, 1, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{ buttons[1, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[2, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[2, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = a1;
buttons[4, 1, 1].Text = a2;
buttons[4, 1, 2].Text = a3;
}
else
{
buttons[1, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[4, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[4, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = a1;
buttons[2, 1, 1].Text = a2;
buttons[2, 1, 2].Text = a3;
} } ////处理下路---左右
if (latterX == 2 && Key)
{
string a1, a2, a3;
a1 = buttons[1, 2, 0].Text;
a2 = buttons[1, 2, 1].Text;
a3 = buttons[1, 2, 2].Text;
if (formerY == 0 && latterY == 2 && formerN == 1) TisLFisR = true;
else if (formerY == 2 && latterY == 0 && formerN == 4) TisLFisR = false;
if (TisLFisR)//向左
{
buttons[1, 2, 0].Text = buttons[2, 2, 0].Text;
buttons[1, 2, 1].Text = buttons[2, 2, 1].Text;
buttons[1, 2, 2].Text = buttons[2, 2, 2].Text; buttons[2, 2, 0].Text = buttons[3, 2, 0].Text;
buttons[2, 2, 1].Text = buttons[3, 2, 1].Text;
buttons[2, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 2, 0].Text = buttons[4, 2, 0].Text;
buttons[3, 2, 1].Text = buttons[4, 2, 1].Text;
buttons[3, 2, 2].Text = buttons[4, 2, 2].Text; buttons[4, 2, 0].Text = a1;
buttons[4, 2, 1].Text = a2;
buttons[4, 2, 2].Text = a3; a1 = buttons[5, 0, 0].Text;//此处重置了a1,处理黄区域,对角
buttons[5, 0, 0].Text = buttons[5, 0, 2].Text;
buttons[5, 0, 2].Text = buttons[5, 2, 2].Text;
buttons[5, 2, 2].Text = buttons[5, 2, 0].Text;
buttons[5, 2, 0].Text = a1; a1 = buttons[5, 0, 1].Text;//此处重置了a1,处理黄区域,对边
buttons[5, 0, 1].Text = buttons[5, 1, 2].Text;
buttons[5, 1, 2].Text = buttons[5, 2, 1].Text;
buttons[5, 2, 1].Text = buttons[5, 1, 0].Text;
buttons[5, 1, 0].Text = a1; }
else
{ buttons[1, 2, 0].Text = buttons[4, 2, 0].Text;
buttons[1, 2, 1].Text = buttons[4, 2, 1].Text;
buttons[1, 2, 2].Text = buttons[4, 2, 2].Text; buttons[4, 2, 0].Text = buttons[3, 2, 0].Text;
buttons[4, 2, 1].Text = buttons[3, 2, 1].Text;
buttons[4, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 2, 0].Text = buttons[2, 2, 0].Text;
buttons[3, 2, 1].Text = buttons[2, 2, 1].Text;
buttons[3, 2, 2].Text = buttons[2, 2, 2].Text; buttons[2, 2, 0].Text = a1;
buttons[2, 2, 1].Text = a2;
buttons[2, 2, 2].Text = a3; a1 = buttons[5, 0, 0].Text;//此处重置了a1,处理白区域,对角 buttons[5, 0, 0].Text = buttons[5, 2, 0].Text;
buttons[5, 2, 0].Text = buttons[5, 2, 2].Text;
buttons[5, 2, 2].Text = buttons[5, 0, 2].Text;
buttons[5, 0, 2].Text = a1; a1 = buttons[5, 0, 1].Text;//此处重置了a1,处理白区域,
buttons[5, 0, 1].Text = buttons[5, 1, 0].Text;
buttons[5, 1, 0].Text = buttons[5, 2, 1].Text;
buttons[5, 2, 1].Text = buttons[5, 1, 2].Text;
buttons[5, 1, 2].Text = a1; } }
return;
} /////处理白红黄---上下--y=0
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 0 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}//特殊情况 if (latterN > formerN)//向下
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}
else if (latterN < formerN)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else if (latterN == formerN) if (latterX > formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[0, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[0, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = buttons[5, 0, 0].Text;
buttons[1, 1, 2].Text = buttons[5, 1, 0].Text;
buttons[1, 0, 2].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[5, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[5, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = a1;
buttons[3, 1, 0].Text = a2;
buttons[3, 2, 0].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = a1;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 1, 0].Text;
a3 = buttons[0, 2, 0].Text;//记录白色的(1 4 7) buttons[0, 0, 0].Text = buttons[3, 0, 0].Text;
buttons[0, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[0, 2, 0].Text = buttons[3, 2, 0].Text; buttons[3, 0, 0].Text = buttons[5, 0, 0].Text;
buttons[3, 1, 0].Text = buttons[5, 1, 0].Text;
buttons[3, 2, 0].Text = buttons[5, 2, 0].Text; buttons[5, 0, 0].Text = buttons[1, 2, 2].Text;
buttons[5, 1, 0].Text = buttons[1, 1, 2].Text;
buttons[5, 2, 0].Text = buttons[1, 0, 2].Text; buttons[1, 2, 2].Text = a1;
buttons[1, 1, 2].Text = a2;
buttons[1, 0, 2].Text = a3; a1 = buttons[2, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[2, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[2, 0, 2].Text = buttons[2, 2, 2].Text;
buttons[2, 2, 2].Text = buttons[2, 2, 0].Text;
buttons[2, 2, 0].Text = a1; a1 = buttons[2, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[2, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[2, 1, 2].Text = buttons[2, 2, 1].Text;
buttons[2, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[2, 1, 0].Text = a1;
return;
}
else Clear();
} /////处理白红黄---上下--y=1
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 1 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}//特殊情况 if (latterN > formerN)//向下
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}
else if (latterN < formerN)//Up
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else if (latterN == formerN) if (latterX > formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = buttons[5, 0, 1].Text;
buttons[1, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[1, 0, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = a1;
buttons[3, 1, 1].Text = a2;
buttons[3, 2, 1].Text = a3;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 1].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 2, 1].Text;//记录白色的(2 5 8) buttons[0, 0, 1].Text = buttons[3, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[0, 2, 1].Text = buttons[3, 2, 1].Text; buttons[3, 0, 1].Text = buttons[5, 0, 1].Text;
buttons[3, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[3, 2, 1].Text = buttons[5, 2, 1].Text; buttons[5, 0, 1].Text = buttons[1, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[1, 1, 1].Text;
buttons[5, 2, 1].Text = buttons[1, 0, 1].Text; buttons[1, 2, 1].Text = a1;
buttons[1, 1, 1].Text = a2;
buttons[1, 0, 1].Text = a3;
return;
}
else Clear();
} /////处理白红黄---上下--y=2
if (latterN == 0 || latterN == 3 || latterN == 5) if (latterY == formerY && formerY == 2 && formerN != 1 && formerN != 2 && formerN != 4)
{
if (formerN == 0 && latterN == 5)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else if (formerN == 5 && latterN == 0)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
} if (latterN > formerN)//down
{ string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
}
else if (latterN < formerN)//Up
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else if (latterN == formerN) if (latterX > formerX)//Down
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[0, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 0, 0].Text = buttons[5, 2, 2].Text;
buttons[1, 1, 0].Text = buttons[5, 1, 2].Text;
buttons[1, 2, 0].Text = buttons[5, 0, 2].Text; buttons[5, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[5, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = a1;
buttons[3, 1, 2].Text = a2;
buttons[3, 2, 2].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = a1;
return;
}
else if (latterX < formerX)
{
string a1, a2, a3;
a1 = buttons[0, 0, 2].Text;
a2 = buttons[0, 1, 2].Text;
a3 = buttons[0, 2, 2].Text;//记录白色的(3 6 9) buttons[0, 0, 2].Text = buttons[3, 0, 2].Text;
buttons[0, 1, 2].Text = buttons[3, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[3, 2, 2].Text; buttons[3, 0, 2].Text = buttons[5, 0, 2].Text;
buttons[3, 1, 2].Text = buttons[5, 1, 2].Text;
buttons[3, 2, 2].Text = buttons[5, 2, 2].Text; buttons[5, 0, 2].Text = buttons[1, 2, 0].Text;
buttons[5, 1, 2].Text = buttons[1, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[1, 0, 0].Text; buttons[1, 2, 0].Text = a1;
buttons[1, 1, 0].Text = a2;
buttons[1, 0, 0].Text = a3; a1 = buttons[4, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[4, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[4, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[4, 2, 2].Text = buttons[4, 0, 2].Text;
buttons[4, 0, 2].Text = a1; a1 = buttons[4, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[4, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[4, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[4, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[4, 1, 2].Text = a1;
return;
}
else Clear(); }
//////二环临时变量
bool tem0, tem1, tem2, tem3, tem4, tem5, tem6, tem7, tem8;
tem0 = false;
/////处理二环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 1;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 1;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 1;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 1;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 1;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 1;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 1;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 1;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 1, 0].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 1, 2].Text; buttons[0, 1, 0].Text = buttons[2, 2, 1].Text;
buttons[0, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[0, 1, 2].Text = buttons[2, 0, 1].Text; buttons[2, 0, 1].Text = buttons[5, 1, 0].Text;
buttons[2, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[2, 2, 1].Text = buttons[5, 1, 2].Text; buttons[5, 1, 0].Text = buttons[4, 2, 1].Text;
buttons[5, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[5, 1, 2].Text = buttons[4, 0, 1].Text; buttons[4, 0, 1].Text = a1;
buttons[4, 1, 1].Text = a2;
buttons[4, 2, 1].Text = a3;
return;
}
/////处理二环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 1;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 1;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 1;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 1;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 1;
tem6 = latterN == 0 && formerN == 4 && formerY == 1;
tem7 = latterN == 4 && formerN == 5 && formerX == 1;
tem8 = latterN == 5 && formerN == 2 && formerY == 1;
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 1, 0].Text;
a2 = buttons[0, 1, 1].Text;
a3 = buttons[0, 1, 2].Text; buttons[0, 1, 0].Text = buttons[4, 0, 1].Text;
buttons[0, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[0, 1, 2].Text = buttons[4, 2, 1].Text; buttons[4, 0, 1].Text = buttons[5, 1, 2].Text;
buttons[4, 1, 1].Text = buttons[5, 1, 1].Text;
buttons[4, 2, 1].Text = buttons[5, 1, 0].Text; buttons[5, 1, 0].Text = buttons[2, 0, 1].Text;
buttons[5, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[5, 1, 2].Text = buttons[2, 2, 1].Text; buttons[2, 0, 1].Text = a3;
buttons[2, 1, 1].Text = a2;
buttons[2, 2, 1].Text = a1;
return;
} /////处理一环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 2;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 2;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 0;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 0;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 2;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 2;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 0;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 0;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 2, 0].Text;
a2 = buttons[0, 2, 1].Text;
a3 = buttons[0, 2, 2].Text; buttons[0, 2, 0].Text = buttons[2, 2, 2].Text;
buttons[0, 2, 1].Text = buttons[2, 1, 2].Text;
buttons[0, 2, 2].Text = buttons[2, 0, 2].Text; buttons[2, 0, 2].Text = buttons[5, 0, 0].Text;
buttons[2, 1, 2].Text = buttons[5, 0, 1].Text;
buttons[2, 2, 2].Text = buttons[5, 0, 2].Text; buttons[5, 0, 0].Text = buttons[4, 2, 0].Text;
buttons[5, 0, 1].Text = buttons[4, 1, 0].Text;
buttons[5, 0, 2].Text = buttons[4, 0, 0].Text; buttons[4, 0, 0].Text = a1;
buttons[4, 1, 0].Text = a2;
buttons[4, 2, 0].Text = a3; a1 = buttons[3, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[3, 0, 0].Text = buttons[3, 2, 0].Text;
buttons[3, 2, 0].Text = buttons[3, 2, 2].Text;
buttons[3, 2, 2].Text = buttons[3, 0, 2].Text;
buttons[3, 0, 2].Text = a1; a1 = buttons[3, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[3, 0, 1].Text = buttons[3, 1, 0].Text;
buttons[3, 1, 0].Text = buttons[3, 2, 1].Text;
buttons[3, 2, 1].Text = buttons[3, 1, 2].Text;
buttons[3, 1, 2].Text = a1;
return;
} /////处理一环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 2;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 2;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 0;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 0;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 2;//
tem6 = latterN == 0 && formerN == 4 && formerY == 0;//
tem7 = latterN == 4 && formerN == 5 && formerX == 0;//
tem8 = latterN == 5 && formerN == 2 && formerY == 2;//
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 2, 0].Text;
a2 = buttons[0, 2, 1].Text;
a3 = buttons[0, 2, 2].Text; buttons[0, 2, 0].Text = buttons[4, 0, 0].Text;
buttons[0, 2, 1].Text = buttons[4, 1, 0].Text;
buttons[0, 2, 2].Text = buttons[4, 2, 0].Text; buttons[4, 0, 0].Text = buttons[5, 0, 2].Text;
buttons[4, 1, 0].Text = buttons[5, 0, 1].Text;
buttons[4, 2, 0].Text = buttons[5, 0, 0].Text; buttons[5, 0, 0].Text = buttons[2, 0, 2].Text;
buttons[5, 0, 1].Text = buttons[2, 1, 2].Text;
buttons[5, 0, 2].Text = buttons[2, 2, 2].Text; buttons[2, 0, 2].Text = a3;
buttons[2, 1, 2].Text = a2;
buttons[2, 2, 2].Text = a1; a1 = buttons[3, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[3, 0, 0].Text = buttons[3, 0, 2].Text;
buttons[3, 0, 2].Text = buttons[3, 2, 2].Text;
buttons[3, 2, 2].Text = buttons[3, 2, 0].Text;
buttons[3, 2, 0].Text = a1; a1 = buttons[3, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[3, 0, 1].Text = buttons[3, 1, 2].Text;
buttons[3, 1, 2].Text = buttons[3, 2, 1].Text;
buttons[3, 2, 1].Text = buttons[3, 1, 0].Text;
buttons[3, 1, 0].Text = a1;
return;
} /////处理三环--顺时针
tem1 = latterX != 2 && formerX != 0 && formerN == 2 && formerY == 0;//Green
tem2 = latterY != 0 && formerY != 2 && formerN == 0 && formerX == 0;//White
tem3 = latterX != 0 && formerX != 2 && formerN == 4 && formerY == 2;//Blue
tem4 = latterY != 2 && formerY != 0 && formerN == 5 && formerX == 2;//Yellow
tem5 = latterN == 0 && formerN == 2 && formerY == 0;//2-0
tem6 = latterN == 4 && formerN == 0 && formerX == 0;//0-4
tem7 = latterN == 5 && formerN == 4 && formerY == 2;//4-5
tem8 = latterN == 2 && formerN == 5 && formerX == 2;//5-2
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 0, 1].Text;
a3 = buttons[0, 0, 2].Text; buttons[0, 0, 0].Text = buttons[2, 2, 0].Text;
buttons[0, 0, 1].Text = buttons[2, 1, 0].Text;
buttons[0, 0, 2].Text = buttons[2, 0, 0].Text; buttons[2, 0, 0].Text = buttons[5, 2, 0].Text;
buttons[2, 1, 0].Text = buttons[5, 2, 1].Text;
buttons[2, 2, 0].Text = buttons[5, 2, 2].Text; buttons[5, 2, 0].Text = buttons[4, 2, 2].Text;
buttons[5, 2, 1].Text = buttons[4, 1, 2].Text;
buttons[5, 2, 2].Text = buttons[4, 0, 2].Text; buttons[4, 0, 2].Text = a1;
buttons[4, 1, 2].Text = a2;
buttons[4, 2, 2].Text = a3; a1 = buttons[1, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[1, 0, 0].Text = buttons[1, 0, 2].Text;
buttons[1, 0, 2].Text = buttons[1, 2, 2].Text;
buttons[1, 2, 2].Text = buttons[1, 2, 0].Text;
buttons[1, 2, 0].Text = a1; a1 = buttons[1, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[1, 0, 1].Text = buttons[1, 1, 2].Text;
buttons[1, 1, 2].Text = buttons[1, 2, 1].Text;
buttons[1, 2, 1].Text = buttons[1, 1, 0].Text;
buttons[1, 1, 0].Text = a1;
return;
}
/////处理三环--逆时针
tem1 = latterX != 0 && formerX != 2 && formerN == 2 && formerY == 0;//Green
tem2 = latterY != 2 && formerY != 0 && formerN == 0 && formerX == 0;//White
tem3 = latterX != 2 && formerX != 0 && formerN == 4 && formerY == 2;//Blue
tem4 = latterY != 0 && formerY != 2 && formerN == 5 && formerX == 2;//Yellow
tem5 = latterN == 2 && formerN == 0 && formerX == 0;//
tem6 = latterN == 0 && formerN == 4 && formerY == 2;//
tem7 = latterN == 4 && formerN == 5 && formerX == 2;//
tem8 = latterN == 5 && formerN == 2 && formerY == 0;//
if (latterN == formerN) if (tem1 || tem2 || tem3 || tem4) tem0 = true;
if (tem0 || tem5 || tem6 || tem7 || tem8) if (temp2 != "")
{
string a1, a2, a3;
a1 = buttons[0, 0, 0].Text;
a2 = buttons[0, 0, 1].Text;
a3 = buttons[0, 0, 2].Text; buttons[0, 0, 0].Text = buttons[4, 0, 2].Text;
buttons[0, 0, 1].Text = buttons[4, 1, 2].Text;
buttons[0, 0, 2].Text = buttons[4, 2, 2].Text; buttons[4, 0, 2].Text = buttons[5, 2, 2].Text;
buttons[4, 1, 2].Text = buttons[5, 2, 1].Text;
buttons[4, 2, 2].Text = buttons[5, 2, 0].Text; buttons[5, 2, 0].Text = buttons[2, 0, 0].Text;
buttons[5, 2, 1].Text = buttons[2, 1, 0].Text;
buttons[5, 2, 2].Text = buttons[2, 2, 0].Text; buttons[2, 0, 0].Text = a3;
buttons[2, 1, 0].Text = a2;
buttons[2, 2, 0].Text = a1; a1 = buttons[1, 0, 0].Text;//此处重置了a1,处理绿区域,对角
buttons[1, 0, 0].Text = buttons[1, 2, 0].Text;
buttons[1, 2, 0].Text = buttons[1, 2, 2].Text;
buttons[1, 2, 2].Text = buttons[1, 0, 2].Text;
buttons[1, 0, 2].Text = a1; a1 = buttons[1, 0, 1].Text;//此处重置了a1,处理绿区域,对边
buttons[1, 0, 1].Text = buttons[1, 1, 0].Text;
buttons[1, 1, 0].Text = buttons[1, 2, 1].Text;
buttons[1, 2, 1].Text = buttons[1, 1, 2].Text;
buttons[1, 1, 2].Text = a1;
}
} //可用
void Clear()
{
IsActive = false;
for (int p = 0; p < 6; p++)
for (int r = 0; r < N; r++)
for (int c = 0; c < N; c++)
{
buttons[p, r, c].Enabled = true; }
} //扭动计算2.0
void MoveCube()
{ } //换面算法
void ChangeFaceInput(byte cmd)
{
if (cmd == 0) { CFI(false); }
if (cmd == 1) { CFI(true); CFI(true); }
if (cmd == 2) { CFI(true); }
if (cmd == 4) { CFI(true); CFI(true); CFI(true); }
if (cmd == 5) { CFI(false); CFI(false); } } //ChangeFaceInside
void CFI(bool XisTorYisF)
//Just Down or Left,True is Left And False is Up.
//Down :white to red ,yellow to origin ..
//Left
{
byte a = 0;
string[] str = new string[19]; if (XisTorYisF)//left
{
for (int r = 0; r < N; r++) for (int c = 0; c < N; c++, a++)
{
str[a + 1] = buttons[4, r, c].Text;
buttons[4, r, c].Text = buttons[3, r, c].Text;
buttons[3, r, c].Text = buttons[2, r, c].Text;
buttons[2, r, c].Text = buttons[1, r, c].Text;
buttons[1, r, c].Text = str[a + 1];
str[a] = buttons[0, r, c].Text;
str[a + 10] = buttons[5, r, c].Text;
}
a = 0; for (int r = 0; r < N; r++) for (int c = 0; c < N; c++, a++)
{
buttons[0, 2 - c, r].Text = str[a];
buttons[5, c, 2 - r].Text = str[a + 10];
}
}
else
{
for (int r = 0; r < N; r++) for (int c = 0; c < N; c++, a++)
{
//MessageBox.Show("" + r + " " + c);
str[a + 1] = buttons[3, r, c].Text;
buttons[3, r, c].Text = buttons[0, r, c].Text;//把红色区域变成现在的白
buttons[0, r, c].Text = buttons[1, 2 - r, 2 - c].Text;
buttons[1, 2 - r, 2 - c].Text = buttons[5, r, c].Text;
buttons[5, r, c].Text = str[a + 1];
str[a] = buttons[4, r, c].Text;
str[a + 10] = buttons[2, r, c].Text;
}
a = 0;
for (int r = 0; r < N; r++) for (int c = 0; c < N; c++, a++)
{
buttons[4, 2 - c, r].Text = str[a];//ni
buttons[2, c, 2 - r].Text = str[a + 10];
} }
Shader(0);
} //两种映射
void Mapping(bool Bool)//true 不扭面 水平扭动
{
if (Bool)
{//
string a1, a2, a3;
a1 = buttons[1, 1, 0].Text;
a2 = buttons[1, 1, 1].Text;
a3 = buttons[1, 1, 2].Text; buttons[1, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[2, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[2, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = a1;
buttons[4, 1, 1].Text = a2;
buttons[4, 1, 2].Text = a3; }
else
{
string a1, a2, a3;
a1 = buttons[1, 1, 0].Text;
a2 = buttons[1, 1, 1].Text;
a3 = buttons[1, 1, 2].Text; buttons[1, 1, 0].Text = buttons[4, 1, 0].Text;
buttons[1, 1, 1].Text = buttons[4, 1, 1].Text;
buttons[1, 1, 2].Text = buttons[4, 1, 2].Text; buttons[4, 1, 0].Text = buttons[3, 1, 0].Text;
buttons[4, 1, 1].Text = buttons[3, 1, 1].Text;
buttons[4, 1, 2].Text = buttons[3, 1, 2].Text; buttons[3, 1, 0].Text = buttons[2, 1, 0].Text;
buttons[3, 1, 1].Text = buttons[2, 1, 1].Text;
buttons[3, 1, 2].Text = buttons[2, 1, 2].Text; buttons[2, 1, 0].Text = a1;
buttons[2, 1, 1].Text = a2;
buttons[2, 1, 2].Text = a3;
} }
}
}

【c#】仅1600行代码 2D魔方游戏源码-纯WinForm的更多相关文章

  1. 网狐6603棋牌游戏源码.rar

    网狐6603棋牌游戏源码.rar http://pan.baidu.com/s/1dFgGNq5 网络收集仅供学习,下载后请务必在24小时内删除! 以上是原vc6.0源码,下载后使用vs2015编译, ...

  2. HTML5小游戏源码收藏

    html5魅族创意的贪食蛇游戏源码下载 html5网页版打砖块小游戏源码下载 html5 3D立体魔方小游戏源码下载 html5网页版飞机躲避游戏源码下载 html5三国人物连连看游戏源码下载 js ...

  3. 15款Cocos2d-x游戏源码

    (1)用cocos2d-x开发的中国象棋游戏源码 使用Cocos2d-X2.2.3开发的一款中国象棋游戏,游戏中可以实现.新局面.悔棋.游戏音乐.胜利后会显示游戏结果. 源码下载:http://www ...

  4. html5 canvas简易版捕鱼达人游戏源码

    插件描述:html5利用canvas写的一个js版本的捕鱼,有积分统计,鱼可以全方位移动,炮会跟着鼠标移动,第一次打开需要鼠标移出背景图,再移入的时候就可以控制炮的转动,因为是用的mouseover触 ...

  5. 网狐6603手机棋牌游戏源码.rar

    网狐6603手机棋牌游戏源码.rar   文件大小: 333 MB 发布一款手机棋牌游戏源码带教程文档! 仅供学习,下载后请务必在24小时内删除! 网狐6603手机棋牌游戏源码 链接:http://p ...

  6. android版猜拳游戏源码分享

    android版猜拳游戏源码分享安卓版猜拳游戏源码,该文件中带有安装测试包的,这个游戏源码比较简单的,现在有两个代码,一个自定义VIEW的,一个就是普通的imageView图片,游戏非常适合一些新手的 ...

  7. ios水果风暴游戏源码下载

    游戏源码是从那个IOS教程网IOS.662p.com分享给大家的. 这是一款ios水果风暴游戏源码下载,介绍给大家一下,喜欢的朋友可以下载学习一下吧.应用介绍:这是一个以获得高分和挑战更高难度为目的的 ...

  8. 射击的乐趣:WIN32诠释打飞机游戏源码补充

    打飞机游戏源码补充 从指定位置加载bmp并显示到对话框. , TRUE);, , LR_LOADFROMFILE);          {         BITMAP bmpinfo;        ...

  9. [置顶] ios 水果连连看游戏源码

    原创文章,转载请注明出处:http://blog.csdn.net/donny_zhang/article/details/9251917 demo功能:水果连连看游戏源码.iphone6.1 测试通 ...

随机推荐

  1. C++ 炼气期之算术运算符

    1. 前言 编写程序时,数据确定后,就需要为数据提供相应的处理逻辑(方案或算法).所谓逻辑有 2 种存在形态: 抽象形态:存在于意识形态,强调思考过程,与具体的编程语言无关. 具体形态:通过代码来实现 ...

  2. 【机器学习】数据准备--python爬虫

    前言 我们在学习机器学习相关内容时,一般是不需要我们自己去爬取数据的,因为很多的算法学习很友好的帮助我们打包好了相关数据,但是这并不代表我们不需要进行学习和了解相关知识.在这里我们了解三种数据的爬取: ...

  3. Vue几行代码实现搜索功能

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 【Java面试】Kafka 怎么避免重复消费

    Hi,大家好,我是Mic 一个工作5年的粉丝找到我. 他说: "Mic老师,你要是能回答出这个问题,我就佩服你" 我当场就懵了,现在打赌都这么随意了吗? 我问他问题是什么,他说&q ...

  5. 分布式机器学习:同步并行SGD算法的实现与复杂度分析(PySpark)

    1 分布式机器学习概述 大规模机器学习训练常面临计算量大.训练数据大(单机存不下).模型规模大的问题,对此分布式机器学习是一个很好的解决方案. 1)对于计算量大的问题,分布式多机并行运算可以基本解决. ...

  6. MOEAD实现、基于分解的多目标进化、 切比雪夫方法-(python完整代码)

    确定某点附近的点 答:每个解对应的是一组权重,即子问题,红点附近的四个点,也就是它的邻居怎么确定呢?由权重来确定,算法初始化阶段就确定了每个权重对应的邻居,也就是每个子问题的邻居子问题.权重的邻居通过 ...

  7. C++ 练气期之一文看懂字符串

    C++ 练气期之细聊字符串 1. 概念 程序不仅仅用于数字计算,现代企业级项目中更多流转着充满了烟火气的人间话语.这些话语,在计算机语言称为字符串. 从字面上理解字符串,类似于用一根竹签串起了很多字符 ...

  8. Linux for CentOS 下的 keepalived 安装与卸载以及相关命令操作之详细教程

    百度百科解释: keepalived 是一个类似于 layer3, 4 & 7 交换机制的软件,也就是我们平时说的第 3 层.第 4 层和第 7 层交换.Keepalived 的作用是检测 w ...

  9. CF487E Tourists 题解

    题目链接 思路分析 看到这道题首先想到的此题的树上版本.(不就是树链剖分的板子题么?) 但是此题是图上的两点间的走法,自然要想到是圆方树. 我们先无脑构建出圆方树. 我们先猜测:设后加入的节点权值为 ...

  10. Tapdata 肖贝贝:实时数据引擎系列(四)-关于 Oracle 与 Oracle CDC

      摘要:想实现 Oracle 的 CDC,排除掉一些通用的比如全量比对, 标记字段获取之外, 真正的增量形式获取变更, 有三种办法: Logminer .XStream .裸日志解析,但不管哪种方法 ...