import java.util.*; import java.awt.*; //public class object401 implements oo{ public class object401 extends object{ //public Global global; // public Image image; public Image img; public Sound sound; public Sound throwing; public Sound fall; public Sound splash; int o1=0; /* public String method=new String(""); public String retval=new String(""); public General general; */ // public String list[]=new String[1010]; int state=0; boolean debug=false; String methods[]={ "hit", "action1", "event", "event1", "event2", "resetevent", "event40", "event41", "action405", "action4", "action3", ""}; public Image getImage(){return image;} public void init(Global glbl){ global=glbl; if(image==null){ image=global.loadImage(global.Server, global.Directory+"401"+global.Extention, global.show); img=global.loadImage(global.Server, global.Directory+"401_405"+global.Extention, global.show); sound=global.loadSound(global.Server, global.Directory+"401.au"); splash=global.loadSound(global.Server, global.Directory+"3.au"); fall=global.loadSound(global.Server, global.Directory+"400_404.au"); throwing=global.loadSound(global.Server, global.Directory+"2_5.au"); } // for(int i=0; i<1000;i++) // list[i]=new String(""); 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("action405")==0) action405(); 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 void setMethod(String s){ method=s; } public String getRetval(){ return retval; } public void setArg(int i, String value){ list[i]=value; } */ 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 "object401"; } 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 action405(){ global.PLAYERSTATE=1; if(global.playsound) if(throwing!=null) throwing.play(); state=40; } public void event40(){ state=general.throwit(state); // state + 1 is returned -> event41 global.PLAYERSTATE=1; global.freeze=false; // global.dir=0; global.aftermoves=true; // global.State=global.NOTHING; // global.State=global.PUSH; state=41; } public void event41(){ // Search for 401 in grid int founder=global.grid.nextNr(0,0,401); 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=((global.STEPP > 1 ? (((y*global.STEPP))*global.WIDTH)+global.WIDTH: y*global.WIDTH))+x; int s=((y+global.STEPP)*global.WIDTH)+x; global.show.changeBackground(img, s); }else { if(global.playsound) fall.play(); } // global.dir=0; 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 /* // when stone is pushed into water int s=(global.player.get()+global.dir); global.grid.set(s,1); global.player.set(global.dir); */ } public void action4(){ // Do nothing .. since if we drop the ball in a hole it disappears -> changes state of 405 /* // when stone is pushed into water System.out.println("Object401 in action4"); int s=(global.player.get()+global.dir); global.grid.set(s,1); global.grid.set(s+global.dir, 1); global.player.set(global.dir); */ } /* public void action4(){ global.PLAYERSTATE=1; if(global.playsound) throwing.play(); state=40; } public void action3(){ if(global.playsound) splash.play(); global.PLAYERSTATE=1; state=general.throwit(state); global.freeze=false; global.aftermoves=true; global.State=global.NOTHING; global.resetevent=true; global.waitforme=false; state=33; } */ 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 401;} 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.dir=0; 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; } }