import java.util.*; import java.awt.*; // // ojbect94 - shuffle // // object93 = snow / object94 shuffle // // 94 push => make path.. public class object94 extends object{ public Image img; Image image1; Image image2; Image image3; Image image4; public Sound sound; public Sound throwing; public Sound fall; public Sound splash; int o1=0; int state=0; boolean debug=false; public object94(){ objnumber=94; methods[0]="hit"; methods[1]="action1"; methods[2]="event"; methods[3]="event1"; methods[4]="event2"; methods[5]="resetevent"; methods[6]="event40"; methods[7]="event41"; methods[8]="action93"; methods[9]="action4"; methods[10]="action3"; methods[11]=""; } // public Image getImage(){return image;} public void init(Global glbl){ global=glbl; if(image==null){ image=global.loadImage(global.Server, global.Directory+"94"+global.Extention, global.show); // image1=image; //image2=global.loadImage(global.Server, global.Directory+"94_2"+global.Extention, global.show); //image3=global.loadImage(global.Server, global.Directory+"94_3"+global.Extention, global.show); //image4=global.loadImage(global.Server, global.Directory+"94_4"+global.Extention, global.show); sound=global.loadSound(global.Server, global.Directory+"94.au"); throwing=global.loadSound(global.Server, global.Directory+"94_93.au"); } general=new General(global,getNr()); } public void execute(){ if(method.compareTo("action1")==0) action1(); if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("event1")==0) event1(); if(method.compareTo("event2")==0) event2(); if(method.compareTo("event40")==0) event40(); if(method.compareTo("action93")==0) action93(); if(method.compareTo("action3")==0) action3(); if(method.compareTo("action4")==0) action4(); if(method.compareTo("action205")==0) action205(); if(method.compareTo("action206")==0) action206(); if(method.compareTo("action207")==0) action207(); if(method.compareTo("action208")==0) action208(); if(method.compareTo("action209")==0) action209(); if(method.compareTo("action210")==0) action210(); if(method.compareTo("action211")==0) action211(); if(method.compareTo("action212")==0) action212(); if(method.compareTo("action213")==0) action213(); if(method.compareTo("action214")==0) action214(); if(method.compareTo("action215")==0) action215(); if(method.compareTo("action216")==0) action216(); if(method.compareTo("action217")==0) action217(); if(method.compareTo("action218")==0) action218(); if(method.compareTo("hit")==0){ hit(); return; } } /* public boolean is(String meth){ boolean retval=false; int m=methods.length; for(int i=0; i < m && !retval; i++){ if(methods[i].compareTo(meth) == 0) retval=true; } return retval; } */ public void hit(){ global.waitforme=true; if(sound!=null && global.playsound)sound.play(); o1=general.getBehind(); String l="action"+o1; if(is(l)){ setMethod(l); execute(); } } /* public String toString(){ return "object94"; } */ public void action1(){ if(debug)System.out.println("Action1 ==> move stone!!!"); /* if(global.dir == global.WIDTH*global.STEPP) image=image3; if(global.dir == -(global.WIDTH*global.STEPP)) image=image4; if(global.dir == global.STEPP) image=image2; if(global.dir == global.STEPP) image=image1; */ state=1; } // Action methods public void event1(){ if(general != null) state=general.push(state); } public void action93(){ state=93; } public void dummy(){ /* global.PLAYERSTATE=1; if(global.playsound) if(throwing!=null) throwing.play(); int x=global.player.getX(); int y=global.player.getY(); if(global.dir == -global.STEPP){ x-=global.STEPP; } // Right if(global.dir == global.STEPP){ x+=global.STEPP; } // down if(global.dir == global.STEPP*global.WIDTH){ y+=global.STEPP; } // up if(global.dir == -global.STEPP*global.WIDTH){ y-=global.STEPP; } global.grid.setxy(x, y,1); global.boardrow=-1; global.boardcol=-1; global.doboard=true; state=45; */ } public void event40(){ state=general.throwit(state); // state + 1 is returned -> event41 global.PLAYERSTATE=1; global.freeze=false; global.aftermoves=true; state=41; } public void event41(){ // Search for 93 in grid int founder=global.grid.nextNr(0,0,93); if(founder<0){ int x=global.player.getX(); int y=global.player.getY(); if(global.dir == -global.STEPP){ x-=global.STEPP; } // Right if(global.dir == global.STEPP){ x+=global.STEPP; } // down if(global.dir == global.STEPP*global.WIDTH){ y+=global.STEPP; } // up if(global.dir == -global.STEPP*global.WIDTH){ y-=global.STEPP; } global.grid.setxy(x, y,1); int s=((y+global.STEPP)*global.WIDTH)+x; global.show.changeBackground(img, s); }else { if(global.playsound) fall.play(); } global.waitforme=false; global.aftermoves=true; global.State=global.PUSH; global.boardrow=-1; global.boardcol=-1; global.doboard=true; state=43; } public void action3(){ // do nothing } public void action4(){ // Do nothing .. since if we drop the ball in a hole it disappears -> changes state of 930 } public void action205(){action3();} public void action206(){action3();} public void action207(){action3();} public void action208(){action3();} public void action209(){action3();} public void action210(){action3();} public void action211(){action3();} public void action212(){action3();} public void action213(){action3();} public void action214(){action3();} public void action215(){action3();} public void action216(){action3();} public void action217(){action3();} public void action218(){action3();} //public int getNr(){return 94;} public void event(){ // put everything here like a 'run' method switch(state){ case 1: event1(); break; case 2: event2(); break; case 40: event40();break; case 41: event41();break; case 93: if(global.playsound) if(throwing!=null) throwing.play(); if(general != null) state=general.push(state); break; case 94: global.PLAYERSTATE=1; global.State=global.NOTHING; global.freeze=false; global.aftermoves=true; break; } // draw image } public void event2(){ global.freeze=false; global.waitforme=false; global.aftermoves=true; global.State=global.NOTHING; state=3; } public void resetevent(){ if(global.object==getNr() && global.perform) if(global.STEPP==1) state=0; else state=1; global.State=global.NOTHING; } }