yes, NormalShot, HeroBasicShot and Protector
int moves = 10; int x = getX(); int y = getY(); for (int i=0; i<10; i++) { setLocation(x, y); move(i); Actor actor = getOneIntersectingObject(Enemy.class); if (actor != null && getAlphaAtHead(actor) > 200) { if (actor instanceof Enemy) { ((Enemy)actor).hit(shotStrength); getWorld().removeObject(this); return; } if (actor instanceof Boss) { ((Boss)actor).hit(shotStrength); getWorld().removeObject(this); return; } } }
if (WorldOption.menuDisplayed) return;
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Boss1 here. * * @author (your name) * @version (a version number or a date) */ public class Boss1Part1 extends Boss { /** * Act - do whatever the Boss1 wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public int lifeLeft; public int pointWin; public Boss1Part1 (int life, int pointEarned) { lifeLeft = life; pointWin = pointEarned; } public void act() { if (!WorldOption.menuDisplayed)randomBossMove(); if (!WorldOption.menuDisplayed) { if (WorldOption.gameDifficulty == 1) { if (Greenfoot.getRandomNumber(5300) <= 5) { getWorld().addObject(new Enemy("enemy2.png",2,4,10),getX(),getY()); } } if (WorldOption.gameDifficulty == 2) { if (Greenfoot.getRandomNumber(5300) <= 10) { getWorld().addObject(new Enemy("enemy2.png",2,4,10),getX(),getY()); } } if (WorldOption.gameDifficulty == 3) { if (Greenfoot.getRandomNumber(5300) <= 20) { getWorld().addObject(new Enemy("enemy2.png",2,4,10),getX(),getY()); } } } colisionCheck(); } public void hit(int damage) { lifeLeft = lifeLeft - damage; if (lifeLeft == 30) { setImage("boss1part12.png"); } if (lifeLeft == 20) { setImage("boss1part13.png"); } if (lifeLeft == 10) { setImage("boss1part14.png"); } if(lifeLeft <= 0) { int numberOfBosses = getWorld().getObjects( Boss.class ).size(); ((Counter)getWorld().getObjects(Counter.class).get(0)).add(pointWin); if (numberOfBosses == 1) { dropBonus(3); } getWorld().removeObject(this); } } }
public void hit(int damage) { lifeLeft = lifeLeft - damage; if (lifeLeft == 30) { setImage("boss1part"+part+"2.png"); } if (lifeLeft == 20) { setImage("boss1part"+part+"3.png"); } if (lifeLeft == 10) { setImage("boss1part"+part+"4.png"); } if(lifeLeft <= 0) { int numberOfBosses = getWorld().getObjects( Boss.class ).size(); ((Counter)getWorld().getObjects(Counter.class).get(0)).add(pointWin); if (numberOfBosses == 1) { dropBonus(3); } getWorld().removeObject(this); } }
public Boss1Part1(int life, int pointEarned) { lifeLeft = life; pointWin = pointEarned; part = 1; }
for (int i=0; i<10; i++) { setLocation(x, y); move(i); Actor actor = getOneIntersectingObject(Enemy.class); if (actor != null && getAlphaAtHead(actor) > 200) { ((Enemy)actor).hit(shotStrength); getWorld().removeObject(this); return; } actor = getOneIntersectingObject(Boss.class); if (actor != null && getAlphaAtHead(actor) > 200) { ((Boss)actor).hit(shotStrength); getWorld().removeObject(this); return; } }