import java.util.*; import java.awt.*; // Ape // // Gets object / you if he does not have a banana public class object73 extends object{ public Image img; public Sound sound; public Sound throwing; public Sound fall; public Sound splash; int o1=0; int state=0; boolean debug=false; String methods[]={ "hit", "action1", "event", "event1", "event2", "resetevent", "event40", "event41", "action72", "action4", "action3", ""}; public Image getImage(){return image;} public void init(Global glbl){ global=glbl; if(image==null){ image=global.loadImage(global.Server, global.Directory+"73"+global.Extention, global.show); sound=global.loadSound(global.Server, global.Directory+"73.au"); splash=global.loadSound(global.Server, global.Directory+"3.au"); } general=new General(global,getNr()); global.popbag(72); } 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("action72")==0) action72(); 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 "object73"; } public void action1(){ if(debug)System.out.println("Action1 ==> move stone!!!"); state=1; } // Action methods public void event1(){ if(general != null) state=general.push(state); } public void action72(){ // global.setObjectState(72, "1"); global.pushbag(72); 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 73 in grid int founder=global.grid.nextNr(0,0,73); 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+1)*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 73;} 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; } // draw image } public void event2(){ global.freeze=false; global.waitforme=false; global.aftermoves=true; global.State=global.NOTHING; state=3; } public void resetevent(){ // global.setObjectState(72,"0"); // global.popbag(72); if(global.object==getNr() && global.perform) if(global.STEPP==1) state=0; else state=1; } }