public double getPaintY() { return (state == BulletState.HIT_VICTIM && victim != null) ? victim.getY() + deltaY : y; }
private void checkRobotCollision(List<RobotPeer> robots) { for (RobotPeer otherRobot : robots) { if (!(otherRobot == null || otherRobot == owner || otherRobot.isDead()) && otherRobot.getBoundingBox().intersectsLine(boundingLine)) { state = BulletState.HIT_VICTIM; frame = 0; victim = otherRobot; double damage = Rules.getBulletDamage(power); double score = damage; if (score > otherRobot.getEnergy()) { score = otherRobot.getEnergy(); } otherRobot.updateEnergy(-damage); boolean teamFire = (owner.getTeamPeer() != null && owner.getTeamPeer() == otherRobot.getTeamPeer()); if (!teamFire) { owner.getRobotStatistics().scoreBulletDamage(otherRobot.getName(), score); } if (otherRobot.getEnergy() <= 0) { if (otherRobot.isAlive()) { otherRobot.kill(); if (!teamFire) { final double bonus = owner.getRobotStatistics().scoreBulletKill(otherRobot.getName()); if (bonus > 0) { owner.println( "SYSTEM: Bonus for killing " + (owner.getNameForEvent(otherRobot) + ": " + (int) (bonus + .5))); } } } } owner.updateEnergy(Rules.getBulletHitBonus(power)); Bullet bullet = createBullet(false); otherRobot.addEvent( new HitByBulletEvent( robocode.util.Utils.normalRelativeAngle( heading + Math.PI - otherRobot.getBodyHeading()), bullet)); owner.addEvent( new BulletHitEvent(owner.getNameForEvent(otherRobot), otherRobot.getEnergy(), bullet)); double newX, newY; if (otherRobot.getBoundingBox().contains(lastX, lastY)) { newX = lastX; newY = lastY; setX(newX); setY(newY); } else { newX = x; newY = y; } deltaX = newX - otherRobot.getX(); deltaY = newY - otherRobot.getY(); break; } } }