//========================== class NextBoardButton extends Button{ NextBoardButton(int x, int y){ super(x,y,'!',loadImage("icons/next.gif"),game.mediabank.highlightIcon, new Description()); sticky = true; showInfowindow = false; } //--------------- void click(){ // cancel any actions from previous map for(int i=0;i=cycleCost && game.memory>=memoryCost) ) image( game.mediabank.unavailibleButton, x, y); if(selected) image( highlight, x, y ); if( mouseX>x && mouseXy && mouseY0) cooldown--; } void click(){ super.click(); game.toolCategoryButton.click(); } //--------------- void boardClick(int mx, int my, float planex, float planey, int gridx, int gridy){ if(cooldown==0) if(game.cycles >= cycleCost && game.memory >= memoryCost) if( game.terrain.isCellInsideMap( gridx,gridy ) ){ game.objs.add( new PartialFormat(gridx,gridy) ); game.cycles -= cycleCost; game.memory -= memoryCost; cooldown = cooldownTime; deselect(); } } } //========================== class UpgradeAttackButton extends Button{ UpgradeAttackButton(int x, int y){ super(x,y,'j',loadImage("icons/upgrade_attack.gif"),game.mediabank.highlightIcon, new Description() ); description.heading = "Upgrade damage"; description.about = "+20% damage"; description.cycleCost = 20; description.memoryCost = 20; description.showPrice = true; description.showAbout = true; } void click(){ super.click(); game.researchCategoryButton.click(); } void boardClick(int mx, int my, float planex, float planey, int gridx, int gridy){ if(game.terrain.isCellInsideMap(gridx,gridy)) if( game.terrain.groundEntity[gridx][gridy] != null ) if( game.terrain.groundEntity[gridx][gridy].isDefense ) if( ((Defense)game.terrain.groundEntity[gridx][gridy]).attemptUpgradeAttack() ) game.objs.add( new UpgradeFlash(planex,planey) ); else game.postMessage("upgrade is not possible"); else game.postMessage("upgrade failure at designated coordinates"); else game.postMessage("upgrade failure at designated coordinates"); } } //========================== class UpgradeRangeButton extends Button{ UpgradeRangeButton(int x, int y){ super(x,y,'k',loadImage("icons/upgrade_range.gif"),game.mediabank.highlightIcon, new Description() ); description.heading = "Upgrade \nrange/cover"; description.about = ""; description.cycleCost = 20; description.memoryCost = 20; description.showPrice = true; description.showAbout = true; } void click(){ super.click(); game.researchCategoryButton.click(); } void boardClick(int mx, int my, float planex, float planey, int gridx, int gridy){ if(game.terrain.isCellInsideMap(gridx,gridy)) if( game.terrain.groundEntity[gridx][gridy] != null ) if( game.terrain.groundEntity[gridx][gridy].isDefense ) if( ((Defense)game.terrain.groundEntity[gridx][gridy]).attemptUpgradeRange() ) game.objs.add( new UpgradeFlash(planex,planey) ); else game.postMessage("upgrade is not possible"); else game.postMessage("upgrade failure at designated coordinates"); else game.postMessage("upgrade failure at designated coordinates"); } } //========================== class UpgradeFirerateButton extends Button{ UpgradeFirerateButton(int x, int y){ super(x,y,'l',loadImage("icons/upgrade_firerate.gif"),game.mediabank.highlightIcon, new Description() ); description.heading = "Upgrade \nrate of fire"; description.about = "-20% cool down"; description.cycleCost = 20; description.memoryCost = 20; description.showPrice = true; description.showAbout = true; } void click(){ super.click(); game.researchCategoryButton.click(); } void boardClick(int mx, int my, float planex, float planey, int gridx, int gridy){ if(game.terrain.isCellInsideMap(gridx,gridy)) if( game.terrain.groundEntity[gridx][gridy] != null ) if( game.terrain.groundEntity[gridx][gridy].isDefense ) if( ((Defense)game.terrain.groundEntity[gridx][gridy]).attemptUpgradeFirerate() ) game.objs.add( new UpgradeFlash(planex,planey) ); else game.postMessage("upgrade is not possible"); else game.postMessage("upgrade failure at designated coordinates"); else game.postMessage("upgrade failure at designated coordinates"); } } //========================== class Button{ PImage icon; PImage highlight; int x,y,w,h,radius; boolean visible, selected, sticky, showInfowindow; char hotkey; Description description; Button(int x, int y, char hotkey, PImage icon, PImage highlight, Description description){ this.highlight = highlight; this.description = description; description.hotkey = hotkey; this.x = x; this.y = y; this.hotkey = hotkey; this.icon = icon; w = icon.width; h = icon.height; if(w==16 && h==16) this.icon.mask(game.mediabank.buttonMask); radius = icon.width/2; visible = true; showInfowindow = true; } //--------------- void update(){ } //--------------- void visualize(){ if(visible){ image( icon, x, y); if(selected) image( highlight, x, y ); if( mouseX>x && mouseXy && mouseYx && mxy && my