public void act() { if (HP < 0) { die(Effects[6], 0); return; } movement(); equipment(); Shot(); Special(); // trail(); if (HP != hpUI.value && hpUI.targValue == 0) hpUI.addPoints(HP - hpUI.value); }
private void Special() { if (Greenfoot.isKeyDown("r") && specialShotInt > 120 && Spammo > 0) { addObjectAtOffset(new ChargeBeam(this), getX(), getY(), 80, getRotation()); w.addObject(new CoolDown(ACT2SEC(120)), 845, 640); Greenfoot.playSound("Laser_Cannon.mp3"); // !--------------!\\ specialShotInt = 0; shotInterval = -78; Spammo--; SpammoUI.addPoints(-1); } specialShotInt++; }
private void Shot() { int index = playerAmmunition.indexOf(playerAmmo); if (Greenfoot.isKeyDown("space") && shotInterval > playerAmmo.interval && ammo[index] > 0) { int f = getRotation(); Shot p = Shot.create(playerAmmo, Inimigo.class); addObjectAtOffset(p, getX(), getY(), 70, f); p.setRotation(f); // !--------------!\\ shotInterval = 0; ammo[index]--; ammoUI.addPoints(-1); } shotInterval++; }