import java.util.*; import java.awt.*; // // Bucket // // When pushed to water -> Fill bucket // When filled and pushed to fire -> kill fire // When NOT filled and pushed to fire -> Nothing happens // // public class object175 extends object{ int state=0; boolean debug=false; Image image1; Image image2; Image img; int o1=0; // behind int i1=0; // imagebehind int x; int y; public Sound splash; public General general; public Sound throwing; boolean filled=false; public object175(){ objnumber=175; 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"; // is this needed? methods[20]="resetevent"; methods[21]="event"; methods[22]="action177"; // fire } public void init(Global glbl){ global=glbl; if(image == null){ image1=global.loadImage(global.Server, global.Directory+"175"+global.Extention, global.show); image2=global.loadImage(global.Server, global.Directory+"176"+global.Extention, global.show); img=global.loadImage(global.Server, global.Directory+"175_1"+global.Extention, global.show); image=image1; } splash=global.loadSound(global.Server, global.Directory+"3.au"); throwing=global.loadSound(global.Server, global.Directory+"4.au"); general=new General(global,getNr()); filled=false; image=image1; } 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("event")==0) event(); if(method.compareTo("resetevent")==0) resetevent(); if(method.compareTo("hit")==0){ hit(); return; } if(method.compareTo("action177")==0) action177(); } // Hit the crate/wood public void hit(){ System.out.println("hit 175"); 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; } // Fire push public void action177(){ if(filled){ if(global.playsound) throwing.play(); x=global.player.getX(); y=global.player.getY(); if(global.dir == -global.STEPP){ x-=global.STEPP*2; } // Right if(global.dir == global.STEPP){ x+=global.STEPP*2; } // down if(global.dir == global.STEPP*global.WIDTH){ y+=global.STEPP*2; } // up if(global.dir == -global.STEPP*global.WIDTH){ y-=global.STEPP*2; } global.grid.setxy(x, y,1); // in Slow mode the background probably was changed .. so change it once more int s=((y+global.STEPP)*global.WIDTH)+x; global.show.changeBackground(img, s); image=image1; filled=false; global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; }else{ global.setInfo("There is nothing in it"); } } public void action300(){ action3(); } // Push the bucket to the water public void action3(){ System.out.println("action 3 on 175 Filled: "+filled); if(!filled){ if(global.playsound) throwing.play(); x=global.player.getX(); y=global.player.getY(); if(global.dir == -global.STEPP){ x-=global.STEPP*2; } // Right if(global.dir == global.STEPP){ x+=global.STEPP*2; } // down if(global.dir == global.STEPP*global.WIDTH){ y+=global.STEPP*2; } // up if(global.dir == -global.STEPP*global.WIDTH){ y-=global.STEPP*2; } global.grid.setxy(x, y,1); // in Slow mode the background probably was changed .. so change it once more int s=((y+global.STEPP)*global.WIDTH)+x; try{ global.show.changeBackground(img, s); }catch(Exception gg){} image=image2; global.boardrow=-1; global.boardcol=-1; global.boardwidth=-1; global.boardheight=-1; global.doboard=true; filled=true; }else System.out.println("Filled is true .. but why??"); // state=40; } // Push the bucket in 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: break; case 30: break; case 31: 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(); 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.freeze=false; state=43; // do nothing global.doboard=true; global.resetevent=true; // Reset the event global.waitforme=false; // Ready with pushing global.aftermoves=true; // We can execute the aftermoves } // public void resetevent(){ if(global.object==getNr() && global.perform) if(global.STEPP==1) state=0; else state=1; } }