void GetAround(int x, int y, Direction dirction = Direction.Null, int flag = 1)【一个void语句 括号里是定义 int的定义】
{
if (starsColor[x, y] == StarColor.White)
return;
if (dirction == Direction.Null)
{
list.Clear(); 【list调用clear()函数,(.代表调用)】
list.Add(new StarInfo(x, y, starsColor[x, y], 1));【 new表示创建一个starinfo】
starsFlag[x, y] = 1;【= 表示赋值】
if (x == 0 && y == 0)【== 表示判断是否相等】
{
GetAround(x, y, Direction.Right);
GetAround(x, y, Direction.Down);
}
else if (x == 0 && y == 9)
{
GetAround(x, y, Direction.Right);
GetAround(x, y, Direction.Up);
}
else if (x == 9 && y == 0)
{
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Down);
}
else if (x == 9 && y == 9)
{
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Up);
}
else if (x == 0)
{
GetAround(x, y, Direction.Up);
GetAround(x, y, Direction.Right);
GetAround(x, y, Direction.Down);
}
else if (x == 9)
{
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Down);
GetAround(x, y, Direction.Up);
}
else if (y == 0)
{
GetAround(x, y, Direction.Right);
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Down);
}
else if (y == 9)
{
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Up);
GetAround(x, y, Direction.Right);
}
else
{
GetAround(x, y, Direction.Up);
GetAround(x, y, Direction.Down);
GetAround(x, y, Direction.Left);
GetAround(x, y, Direction.Right);
}
}
else if (dirction == Direction.Up)
{
for (int i = 0; i < list.Count; i++)
{
if (x == list[i].X && y - 1 == list[i].Y && starsColor[x, y - 1] == list[i].Color)
{
return;
}
}
if (starsColor[x, y] == starsColor[x, y - 1])
{
list.Add(new StarInfo(x, y - 1, starsColor[x, y - 1], 1));
starsFlag[x, y - 1] = 1;
if (x == 0 && y == 0)
{
GetAround(x, y - 1, Direction.Right);
}
else if (x == 9 && y == 0)
{
GetAround(x, y - 1, Direction.Left);
}
else if (x == 0 && y == 9)
{
GetAround(x, y - 1, Direction.Right);
GetAround(x, y - 1, Direction.Up);
}
else if (x == 9 && y == 9)
{
GetAround(x, y - 1, Direction.Up);
GetAround(x, y - 1, Direction.Left);
}
else if (x == 0)
{
if (y - 1 > 0)
{
GetAround(x, y - 1, Direction.Up);
}
GetAround(x, y - 1, Direction.Right);
}
else if (x == 9)
{
GetAround(x, y - 1, Direction.Left);
if (y - 1 > 0)
{
GetAround(x, y - 1, Direction.Up);
}
}
else if (y == 0)
{
GetAround(x, y - 1, Direction.Left);
GetAround(x, y - 1, Direction.Right);
}
else if (y == 9)
{
GetAround(x, y - 1, Direction.Left);
GetAround(x, y - 1, Direction.Right);
if (y - 1 > 0)
{
GetAround(x, y - 1, Direction.Up);
}
}
else
{
GetAround(x, y - 1, Direction.Left);
GetAround(x, y - 1, Direction.Right);
if (y - 1 > 0)
{
GetAround(x, y - 1, Direction.Up);
}
}
return;
}
else return;
}
else if (dirction == Direction.Down)
{
for (int i = 0; i < list.Count; i++)
{
if (x == list[i].X && y + 1 == list[i].Y && starsColor[x, y + 1] == list[i].Color)
{
return;
}
}
if (starsColor[x, y] == starsColor[x, y + 1])
{
list.Add(new StarInfo(x, y + 1, starsColor[x, y + 1], 1));
starsFlag[x, y + 1] = 1;
if (x == 0 && y == 0)
{
GetAround(x, y + 1, Direction.Right);
GetAround(x, y + 1, Direction.Down);
}
else if (x == 9 && y == 0)
{
GetAround(x, y + 1, Direction.Left);
GetAround(x, y + 1, Direction.Down);
}
else if (x == 0 && y == 9)
{
GetAround(x, y + 1, Direction.Right);
}
else if (x == 9 && y == 9)
{
GetAround(x, y + 1, Direction.Left);
}
else if (x == 0)
{
GetAround(x, y + 1, Direction.Right);
if (y + 1 < 9)
{
GetAround(x, y + 1, Direction.Down);
}
}
else if (x == 9)
{
GetAround(x, y + 1, Direction.Left);
if (y + 1 < 9)
{
GetAround(x, y + 1, Direction.Down);
}
}
else if (y == 0)
{
GetAround(x, y + 1, Direction.Left);
GetAround(x, y + 1, Direction.Right);
GetAround(x, y + 1, Direction.Down);
}
else if (y == 9)
{
GetAround(x, y + 1, Direction.Left);
GetAround(x, y + 1, Direction.Right);
}
else
{
if (y + 1 <= 9)
{
GetAround(x, y + 1, Direction.Left);
GetAround(x, y + 1, Direction.Right);
}
if (y + 1 < 9)
{
GetAround(x, y + 1, Direction.Down);
}
} return;
}
else return;
}
else if (dirction == Direction.Left)
{
for (int i = 0; i < list.Count; i++)
{
if (x - 1 == list[i].X && y == list[i].Y && starsColor[x - 1, y] == list[i].Color)
{
return;
}
}
if (starsColor[x, y] == starsColor[x - 1, y])
{
list.Add(new StarInfo(x - 1, y, starsColor[x - 1, y], 1));
starsFlag[x - 1, y] = 1;
if (x == 0 && y == 0)
{
GetAround(x - 1, y, Direction.Down);
}
else if (x == 9 && y == 0)
{
GetAround(x - 1, y, Direction.Left);
GetAround(x - 1, y, Direction.Down);
}
else if (x == 0 && y == 9)
{
GetAround(x - 1, y, Direction.Up);
}
else if (x == 9 && y == 9)
{
GetAround(x - 1, y, Direction.Up);
GetAround(x - 1, y, Direction.Left);
}
else if (x == 0)
{
GetAround(x - 1, y, Direction.Up);
GetAround(x - 1, y, Direction.Down);
}
else if (x == 9)
{
GetAround(x - 1, y, Direction.Left);
GetAround(x - 1, y, Direction.Down);
GetAround(x - 1, y, Direction.Up);
}
else if (y == 0)
{
if (x - 1 > 0)
{
GetAround(x - 1, y, Direction.Left);
}
GetAround(x - 1, y, Direction.Down);
}
else if (y == 9)
{
if (x - 1 > 0)
{
GetAround(x - 1, y, Direction.Left);
}
GetAround(x - 1, y, Direction.Up);
}
else
{
if (x - 1 > 0)
{
GetAround(x - 1, y, Direction.Left);
}
GetAround(x - 1, y, Direction.Up);
GetAround(x - 1, y, Direction.Down);
} return;
}
else return;
}
else if (dirction == Direction.Right)
{
for (int i = 0; i < list.Count; i++)
{
if (x + 1 == list[i].X && y == list[i].Y && starsColor[x + 1, y] == list[i].Color)
{
return;
}
}
if (starsColor[x, y] == starsColor[x + 1, y])
{
list.Add(new StarInfo(x + 1, y, starsColor[x + 1, y], 1));
starsFlag[x + 1, y] = 1;
if (x == 0 && y == 0)
{
GetAround(x + 1, y, Direction.Right);
GetAround(x + 1, y, Direction.Down);
}
else if (x == 9 && y == 0)
{
GetAround(x + 1, y, Direction.Down);
}
else if (x == 0 && y == 9)
{
GetAround(x + 1, y, Direction.Right);
GetAround(x + 1, y, Direction.Up);
}
else if (x == 9 && y == 9)
{
GetAround(x + 1, y, Direction.Up);
}
else if (x == 0)
{
GetAround(x + 1, y, Direction.Up);
GetAround(x + 1, y, Direction.Right);
GetAround(x + 1, y, Direction.Down);
}
else if (x == 9)
{
GetAround(x + 1, y, Direction.Down);
GetAround(x + 1, y, Direction.Up);
}
else if (y == 0)
{
if (x + 1 < 9)
{
GetAround(x + 1, y, Direction.Right);
}
GetAround(x + 1, y, Direction.Down);
}
else if (y == 9)
{
if (x + 1 < 9)
{
GetAround(x + 1, y, Direction.Right);
}
GetAround(x + 1, y, Direction.Up);
}
else
{
GetAround(x + 1, y, Direction.Down);
GetAround(x + 1, y, Direction.Up);
if (x + 1 < 9)
{
GetAround(x + 1, y, Direction.Right);
}
} return;
}
else return;
}
if (flag == 1)
{
DrawBox(list);
}
}