//判斷甜品是否相鄰居
public
bool
isfriend
(gamesweet sweet1,
gamesweet sweet2)
//交換兩個甜品
public
void
exchangesweets
(gamesweet sweet1,
gamesweet sweet2)
}public
void
presssweet
(gamesweet sweet)
public
void
entersweet
(gamesweet sweet)
public
void
releasesweet()
}
//匹配方法
public list
matchsweets
(gamesweet sweet,
int newx,
int newy)
else
//右加
//排除邊界值
if(x<
0||x>=xcolumn)
//判斷滿足條件
if(sweets[x,newy]
.cancolor()
&& sweets[x, newy]
.coloredcomponent.color==color)
else}}
//行匹配完畢
if(matchrowsweets.count>=3)
}if(finishedmatchingsweets.count>=3)
//列匹配
matchlinesweets.
add(sweet)
;//i為0 的時候 往左遍歷 為1的時候往右邊遍歷
for(
int i =
0; i <=
1; i++
)else
//右加
//排除邊界值
if(y <
0|| y >= yrow)
//判斷滿足條件
if(sweets[newx, y]
.cancolor()
&& sweets[newx, y]
.coloredcomponent.color == color)
else}}
//行匹配完畢
if(matchlinesweets.count >=3)
}if(finishedmatchingsweets.count >=3)
}return
null
;}