import java.util.*; import java.awt.*; // // Puzzle pushing .. // // 9 puzzle part // public class object50 extends object{ int state=0; int o1=0; int i1=0; public object50(){ objnumber=50; methods[0]="hit"; methods[1]="action1"; methods[2]="action3"; methods[3]="action4"; methods[4]="aftermove"; methods[5]="event"; methods[6]="resetevent"; } public void init(Global glbl){ global=glbl; super.init(global); general=new General(global,getNr()); } public void execute(){ if(method.compareTo("action1")==0) action1(); if(method.compareTo("action3")==0) action3(); if(method.compareTo("action4")==0) action4(); if(method.compareTo("event")==0) event(); if(method.compareTo("hit")==0){ hit(); return; } if(method.compareTo("aftermove")==0){ aftermove(); } } public void aftermove(){ int r=global.grid.next(0,0,50); // Check if the pieces are OK if(global.grid.get(r+(1*global.STEPP))==51) if(global.grid.get(r+(2*global.STEPP)) == 52) if( global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP))==53) if(global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP)+(1*global.STEPP))==54) if(global.grid.get(r+((global.WIDTH*global.STEPP)*global.STEPP)+(2*global.STEPP))==55) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP))==56) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP)+(1*global.STEPP))==57) if(global.grid.get(r+((2*global.WIDTH*global.STEPP)*global.STEPP)+(2*global.STEPP))==58){ global.grid.set(global.grid.next(0,0,91),1); global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; } } public void hit(){ global.waitforme=true; if(sound!=null && global.playsound)sound.play(); i1=general.getImageBehind(); o1=general.getBehind(); String l="action"+o1; if(is(l)){ setMethod(l); execute(); } } // Action methods public void action3(){ } public void action4(){ } public void action1(){ state=1; } // Action methods public void event1(){ if(general != null) state=general.push(state); } public void event2(){ global.freeze=false; global.resetevent=true; global.waitforme=false; global.aftermoves=true; global.State=global.NOTHING; state=3; } public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; case 2: event2();break; } } public void resetevent(){ if(global.perform) if(global.STEPP==1) state=0; else state=1; } }