2 of the towers i want to work with special attacks (one for slowing down units when they are hit, and the other to do splash damage).
for the splash damage one i figured if i get all the units in a range and damage them then that would work, but it won't let me cast an array, so should i make a loop in there that takes each non empty value of the array and damage it individually, or is there a way to attack them all at once? the way the units spawn now i have the range set to hit 2 of them, and i want it to do damage to them when the attack hits one of them and is removed.
here's the coding i have for the attack:
the commented out part is that original attack that only hits one.
as for the slowing one, since the units that spawn have a different move method then the regular move that you can add an int to, not sure how to slow them down for a few seconds.
public class splashDamage extends towerAttacks { /** * Act - do whatever the splashDamage wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ //damage 2/4 //att spd 1/.75 sec //aoe radius 2 units/3 units (space wise) int x, y; enemies e; int damage; public splashDamage(enemies E, int Damage) { e = E; damage = Damage; } public void act() { // Add your action code here. if(isNotThere()) { getWorld().removeObject(this); } else { x = e.getX(); y = e.getY(); moveTo(x, y); isHit(); } } private void moveTo(int x, int y) { double xX = x - getX(); double yY = y - getY(); double angle = Math.atan2(yY, xX)*180/Math.PI; setRotation( (int) angle); move(1); } public void isHit() { // if(getOneObjectAtOffset(0, 0, enemies.class) != null) // { // //do attack damage // enemies a = (enemies) getOneObjectAtOffset(0, 0, enemies.class); // a.decHealth(damage); // getWorld().removeObject(this); // } if(!getObjectsInRange(70, enemies.class).isEmpty()) { enemies a = (enemies) getObjectsInRange(70, enemies.class); a.decHealth(damage); getWorld().removeObject(this); } else if(getX() <=0 || getX() >= getWorld().getWidth() || getY() <= 0 || getY() >= getWorld().getHeight()) { getWorld().removeObject(this); } } public boolean isNotThere() { if(e.getWorld() == null) { return true; } return false; } }