Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public interface IBasicEvents
IBasicRobot
.
IBasicRobot
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
public void onBulletHit(BulletHitEvent event)
This method is called when one of your bullets hits another robot. You should override it in your robot if you want to be informed of this event. Example:public void onBulletHit(BulletHitEvent event) { out.println("I hit " + event.getName() + "!"); }
- Parameters:
event
- the bullet-hit event set by the game
- See Also:
BulletHitEvent
,Event
public void onBulletHitBullet(BulletHitBulletEvent event)
This method is called when one of your bullets hits another bullet. You should override it in your robot if you want to be informed of this event. Example:public void onBulletHitBullet(BulletHitBulletEvent event) { out.println("I hit a bullet fired by " + event.getBullet().getName() + "!"); }
- Parameters:
event
- the bullet-hit-bullet event set by the game
- See Also:
BulletHitBulletEvent
,Event
public void onBulletMissed(BulletMissedEvent event)
This method is called when one of your bullets misses, i.e. hits a wall. You should override it in your robot if you want to be informed of this event. Example:public void onBulletHit(BulletMissedEvent event) { out.println("Drat, I missed."); }
- Parameters:
event
- the bullet-missed event set by the game
- See Also:
BulletMissedEvent
,Event
public void onDeath(DeathEvent event)
This method is called if your robot dies. You should override it in your robot if you want to be informed of this event. Actions will have no effect if called from this section. The intent is to allow you to perform calculations or print something out when the robot is killed.
- Parameters:
event
- the death event set by the game
- See Also:
DeathEvent
,WinEvent
,BattleEndedEvent
,Event
public void onHitByBullet(HitByBulletEvent event)
This method is called when your robot is hit by a bullet. You should override it in your robot if you want to be informed of this event. Example:void onHitByBullet(HitByBulletEvent event) { out.println(event.getRobotName() + " hit me!"); }
- Parameters:
event
- the hit-by-bullet event set by the game
- See Also:
HitByBulletEvent
,Event
public void onHitRobot(HitRobotEvent event)
This method is called when your robot collides with another robot. You should override it in your robot if you want to be informed of this event. Example:void onHitRobot(HitRobotEvent event) { if (event.getBearing() > -90 && event.getBearing() <= 90) { back(100); } else { ahead(100); } } -- or perhaps, for a more advanced robot -- public void onHitRobot(HitRobotEvent event) { if (event.getBearing() > -90 && event.getBearing() <= 90) { setBack(100); } else { setAhead(100); } }The angle is relative to your robot's facing. So 0 is straight ahead of you. This event can be generated if another robot hits you, in which caseevent.isMyFault()
will returnfalse
. In this case, you will not be automatically stopped by the game -- but if you continue moving toward the robot you will hit it (and generate another event). If you are moving away, then you won't hit it.
- Parameters:
event
- the hit-robot event set by the game
- See Also:
HitRobotEvent
,Event
public void onHitWall(HitWallEvent event)
This method is called when your robot collides with a wall. You should override it in your robot if you want to be informed of this event. The wall at the top of the screen is 0 degrees, right is 90 degrees, bottom is 180 degrees, left is 270 degrees. But this event is relative to your heading, so: The bearing is such thatturnRight
(event.getBearing())
will point you perpendicular to the wall. Example:void onHitWall(HitWallEvent event) { out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees."); }
- Parameters:
event
- the hit-wall event set by the game
- See Also:
HitWallEvent
,Event
public void onRobotDeath(RobotDeathEvent event)
This method is called when another robot dies. You should override it in your robot if you want to be informed of this event.
- Parameters:
event
- The robot-death event set by the game
- See Also:
RobotDeathEvent
,Event
public void onScannedRobot(ScannedRobotEvent event)
This method is called when your robot sees another robot, i.e. when the robot's radar scan "hits" another robot. You should override it in your robot if you want to be informed of this event. (Almost all robots should override this!) This event is automatically called if there is a robot in range of your radar. Note that the robot's radar can only see robot within the range defined byRules.RADAR_SCAN_RADIUS
(1200 pixels). Also not that the bearing of the scanned robot is relative to your robot's heading. Example:void onScannedRobot(ScannedRobotEvent event) { // Assuming radar and gun are aligned... if (event.getDistance() <32100) { fire(3); } else { fire(1); } }Note:
The game assists Robots in firing, as follows:In essence, this means that if you can see a robot, and it doesn't move, then fire will hit it. AdvancedRobots will NOT be assisted in this manner, and are expected to examine the event to determine if
- If the gun and radar are aligned (and were aligned last turn),
- and the event is current,
- and you call fire() before taking any other actions,
fire()
will fire directly at the robot.fire()
would hit. (i.e. you are spinning your gun around, but by the time you get the event, your gun is 5 degrees past the robot).
- Parameters:
event
- the scanned-robot event set by the game
- See Also:
ScannedRobotEvent
,Event
,Rules.RADAR_SCAN_RADIUS
public void onStatus(StatusEvent event)
This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time. The main benefit of this method is that you'll automatically receive all current data values of the robot like e.g. the x and y coordinate, heading, gun heat etc., which are grouped into the exact same time/turn. This is the only way to map the robots data values to a specific time. For example, it is not possible to determine the exact time of the robot's heading by calling first callingRobot.getTime()
and thenRobot.getHeading()
afterwards, as the time might change after between theRobot.getTime()
andRobot.getHeading()
call.
- Parameters:
event
- the event containing the robot status at the time it occurred.
- Since:
- 1.5
- See Also:
StatusEvent
,Event
public void onWin(WinEvent event)
This method is called if your robot wins a battle. Your robot could perform a victory dance here! :-)
- Parameters:
event
- the win event set by the game
- See Also:
DeathEvent
,BattleEndedEvent
,Event