想起以前高三的时候写过一个很无脑的程序,那个时候.net5.0都还没影儿呢,,现在分享一下。一个平面展开的魔方游戏。
这个是1.0版本,有些许bug。
比如左边的格子操作不了。
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
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;
}
}
}
}