this.pane.setComponentZOrder(cards[c + i], 1);
Point point = new Point(lastPoint);
if (cards[c + i].getCardValue() == 1){
int n = cards[c + i].whichColumnAvailable(point); point.y -= 240;
PKCard card = (PKCard) this.table.get(point); if (card != null && card.isCardCanMove()){
this.haveFinish(n);\\\\ÅжÏֽůÊÇ·ñ¿ÉÒÔ»ØÊÕÒÔ¼°»ØÊÕµÄ×Ü´ÎÊý
} }
x += 101; }
c += 10; }
4.3.4ֽůµÄÒÆ¶¯ÒÔ¼°·ÅÖÃ
´úÂëʵÏÖÈçÏ£º ÓÃÊó±êÍ϶¯Ö½ÅÆ
public void mouseDragged(MouseEvent arg0){ if (canMove){
21
int x = 0; int y = 0;
Point p = arg0.getPoint(); x = p.x - point.x; y = p.y - point.y; this.moving(x, y); } }
·½·¨£º·ÅÖÃֽů
public void setNextCardLocation(Point point){ PKCard card = main.getNextCard(this); if (card != null){
if (point == null){
card.setNextCardLocation(null);
main.table.remove(card.getLocation()); card.setLocation(card.initPoint); main.table.put(card.initPoint, card); } else{
point = new Point(point); point.y += 20;
card.setNextCardLocation(point); point.y -= 20;
main.table.remove(card.getLocation()); card.setLocation(point);
main.table.put(card.getLocation(), card); card.initPoint = card.getLocation(); } } }
4.3.5ÏÔʾµ±Ç°Ö½ÅÆ¿ÉÐеIJÙ×÷£º ´úÂëʵÏÖÈçÏ£º ·µ»ØÖµ£ºvoid
·½·¨£ºÏÔʾ¿ÉÒÆ¶¯µÄ²Ù×÷
public void showEnableOperator(){ int x = 0;
out: while (true){
Point point = null; PKCard card = null; do{
if (point != null){ n++;
22
}
point = this.getLastCardLocation(n); while (point == null){
point = this.getLastCardLocation(++n); if (n == 10) n = 0; x++;
if (x == 10) break out; }
card = (PKCard) this.table.get(point); }
while (!card.isCardCanMove());
while (this.getPreviousCard(card) != null
&& this.getPreviousCard(card).isCardCanMove()){ card = this.getPreviousCard(card); }
if (a == 10){ a = 0; }
for (; a < 10; a++){ if (a != n){
Point p = null; PKCard c = null; do{
if (p != null){ a++; }
p = this.getLastCardLocation(a); int z = 0;
while (p == null){
p = this.getLastCardLocation(++a); if (a == 10) a = 0; if (a == n) a++; z++;
if (z == 10) break out; }
c = (PKCard) this.table.get(p); }
while (!c.isCardCanMove());
if (c.getCardValue() == card.getCardValue() + 1){ card.flashCard(card); try{
Thread.sleep(800); }
catch (InterruptedException e){
23
e.printStackTrace(); }
c.flashCard(c); a++;
if (a == 10){ n++; }
break out; } } } n++;
if (n == 10){ n = 0; }
x++;
if (x == 10){ break out; } } }
4.3.6»ØÊÕֽů£º
´úÂëʵÏÖÈçÏ£º ·µ»ØÖµ£ºvoid
·½·¨£ºÅжÏֽůµÄ°Ú·ÅÊÇ·ñÍê³É
public void haveFinish(int column){
Point point = this.getLastCardLocation(column); PKCard card = (PKCard) this.table.get(point); do{
this.table.remove(point);
card.moveto(new Point(20 + finish * 10, 580)); //½«×é¼þÒÆ¶¯µ½ÈÝÆ÷ÖÐÖ¸¶¨µÄ˳ÐòË÷Òý¡£ pane.setComponentZOrder(card, 1); //½«Ö½ÅÆÐµÄÏà¹ØÐÅÏ¢´æÈëHashtable
this.table.put(card.getLocation(), card);
24
Ïà¹ØÍÆ¼ö£º