public BigNukeCharge( BigNukeLauncher parent, Color color, double x, double y, double dx, double dy, double angle, int explosionAge) { super( color, x, y, dx + Util.getGameplayRandomGenerator().nextDouble() * 14 * Math.cos(angle), dy - Util.getGameplayRandomGenerator().nextDouble() * 14 * Math.sin(angle)); this.parent = parent; ax = Util.getGameplayRandomGenerator().nextDouble() * 0.1 - 0.05; ay = Util.getGameplayRandomGenerator().nextDouble() * 0.1 - 0.05; this.explosionAge = explosionAge; contractionAge = (int) (explosionAge * (1.2 + Util.getGameplayRandomGenerator().nextDouble() * 0.3)); numChainReactionCharges = (int) (0.114 * (parent.getBonusValue(parent.BONUS_CHAINREACTIONCHANCE).getValue() + Util.getGameplayRandomGenerator().nextInt(10))); }
@Override public void act() { super.act(); /* // Emit a few particles. if ( Util.getGameplayRandomGenerator().nextInt( 3 ) == 0 ) ParticleManager.addParticle( new Particle( getX() + Util.getGameplayRandomGenerator().nextInt( 8 ) - 4, getY() + Util.getGameplayRandomGenerator().nextInt( 8 ) - 4, Util.getGameplayRandomGenerator().nextInt( 4 ), color, Util.getGameplayRandomGenerator().nextDouble(), Util.getGameplayRandomGenerator().nextAngle(), 20, 1 ) );*/ // Waning. if (isReducing) { explosionSize -= 8; // Chain reaction. if (numChainReactionCharges > 0) { numChainReactionCharges--; parent.addUnit( new BigNukeCharge( parent, color, getX(), getY(), getDx(), getDy(), Util.getGameplayRandomGenerator().nextAngle(), (int) (explosionAge * 0.7))); } } // Waxing. else if (age > explosionAge) { if (age > contractionAge) isReducing = true; explosionSize += 5; } // Gone. if (explosionSize < 0) explode(); }
@Override public void explode() { if (explosionSize < 0) parent.remove(this); }
@Override public void remove() { parent.remove(this); }