import java.util.*; import java.awt.*; // // Wood // // floats on water // walkable on hole // public class object5 extends object{ int state=0; boolean debug=false; int o1=0; // behind int i1=0; // imagebehind int x; int y; public Sound splash; public General general; public Sound throwing; private Image img_4_5; // when object gets pushed over hole private Image img_3_5; // when object gets pushed over water public object5(){ objnumber=5; methods[0]="hit"; methods[1]="action1"; methods[2]="action3"; // water methods[3]="action4"; // hole // all forms of water methods[4]="action205"; methods[5]="action206"; methods[6]="action207"; methods[7]="action208"; methods[8]="action209"; methods[9]="action210"; methods[10]="action211"; methods[11]="action212"; methods[12]="action213"; methods[13]="action214"; methods[14]="action214"; methods[15]="action215"; methods[16]="action216"; methods[17]="action217"; methods[18]="action218"; methods[19]="action300"; methods[20]="resetevent"; methods[21]="event"; methods[22]="action74"; //Ice methods[23]="action177"; // fire } public void init(Global glbl){ global=glbl; if(image == null){ image=global.loadImage(global.Server, global.Directory+"5"+global.Extention, global.show); } splash=global.loadSound(global.Server, global.Directory+"3.au"); throwing=global.loadSound(global.Server, global.Directory+"5_4.au"); img_4_5=global.loadImage(global.Server, "/maze/4_5"+global.Extention,global.show); img_3_5=global.loadImage(global.Server, "/maze/3_5"+global.Extention,global.show); general=new General(global,getNr()); } public void execute(){ if(method.compareTo("action1")==0) action1(); if(method.compareTo("action300")==0) action300(); 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("action74")==0) action74(); if(method.compareTo("action177")==0) action177(); if(method.compareTo("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("hit")==0){ hit(); return; } } // Hit the crate/wood public void hit(){ global.waitforme=true; global.resetevent=false; o1=general.getBehind(); i1=general.getImageBehind(); String l="action"+o1; if(is(l)){ setMethod(l); execute(); } } // Action 1 -> background behind the crate/wood public void action1(){ state=1; } public void action300(){ action3(); } // Push the crate in the water -> make walkable water public void action3(){ if(global.playsound) splash.play(); state=40; } // Push the crate/wood in the hole -> Make walkable hole public void action4(){ if(global.playsound) throwing.play(); state=40; } // All forms of water 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 void event(){ switch(state){ case 1: event1(); break; case 2: event2();break; case 3: break; case 40: event40(); break; case 41: event41(); break; case 43: //System.out.println("Object5 . event=43.."); global.boardrow=-1; global.boardcol=-1; global.doboard=true; state=44; break; case 30: break; case 31: break; // ice case 74:event74();break; } // draw image } // Action methods public void event1(){ if(general != null) state=general.push(state); else System.out.println("General is null"); } public void event2(){ global.freeze=false; global.aftermoves=true; global.resetevent=true; global.waitforme=false; state=3; } public void event40(){ state=general.push(state); // state + 1 is returned -> event41 } // After hole -> Leave empty! public void event41(){ x=global.player.getX(); y=global.player.getY(); System.out.println( "Player.getx : "+x); 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; } int s=((y+global.STEPP)*global.WIDTH)+x; oo o; try{ o=(oo)global.loader.getObject(i1); }catch(Exception egw){ o=(oo)global.loader.getObject(1); } if(o1==4){ if(o!=null){ if(o.getImage()!=null){ global.show.changeBackground(img_4_5, o.getImage(), s); } // if image else{ // object = 300 probably global.show.changeBackground(img_4_5, s); } } } if(o1==3){ if(o!=null){ if(o.getImage()!=null){ global.show.changeBackground(img_3_5, o.getImage(), s); } // if image else{ // object = 300 probably global.show.changeBackground(img_3_5, s); } } } global.grid.setxy(x, y,1); global.freeze=false; state=43; // do nothing global.resetevent=true; // Reset the event global.waitforme=false; // Ready with pushing global.aftermoves=true; // We can execute the aftermoves } public void action74(){ if(general!=null)general.resetice(); state=74; } public void event74(){ if(general!=null) state=general.ice(state); } // Action methods public void action177(){ if(general != null) state=general.throwit(state); } // public void resetevent(){ if(global.object==getNr() && global.perform) if(global.STEPP==1) state=0; else state=1; } }