public class ScannedRobotEvent extends Event
onScannedRobot()
when you scan a robot.
You can use the information contained in this event to determine what to do.
Note: You should not inherit from this class in your own event class! The internal logic of this event class might change. Hence, your robot might not work in future Robocode versions, if you choose to inherit from this class.
Constructor and Description |
---|
ScannedRobotEvent()
Deprecated.
|
ScannedRobotEvent(String name,
double energy,
double bearing,
double distance,
double heading,
double velocity)
Deprecated.
|
ScannedRobotEvent(String name,
double energy,
double bearing,
double distance,
double heading,
double velocity,
boolean isSentryRobot)
Called by the game to create a new ScannedRobotEvent.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Event event)
Compares this event to another event regarding precedence.
|
double |
getBearing()
Returns the bearing to the robot you scanned, relative to your robot's
heading, in degrees (-180 <= getBearing() < 180)
|
double |
getBearingRadians()
Returns the bearing to the robot you scanned, relative to your robot's
heading, in radians (-PI <= getBearingRadians() < PI)
|
double |
getDistance()
Returns the distance to the robot (your center to his center).
|
double |
getEnergy()
Returns the energy of the robot.
|
double |
getHeading()
Returns the heading of the robot, in degrees (0 <= getHeading() < 360)
|
double |
getHeadingRadians()
Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI)
|
double |
getLife()
Deprecated.
Use
getEnergy() instead. |
String |
getName()
Returns the name of the robot.
|
double |
getRobotBearing()
Deprecated.
Use
getBearing() instead. |
double |
getRobotBearingDegrees()
Deprecated.
Use
getBearing() instead. |
double |
getRobotBearingRadians()
Deprecated.
Use
getBearingRadians() instead. |
double |
getRobotDistance()
Deprecated.
Use
getDistance() instead. |
double |
getRobotHeading()
Deprecated.
Use
getHeading() instead. |
double |
getRobotHeadingDegrees()
Deprecated.
Use
getHeading() instead. |
double |
getRobotHeadingRadians()
Deprecated.
Use
getHeadingRadians() instead. |
double |
getRobotLife()
Deprecated.
Use
getEnergy() instead. |
String |
getRobotName()
Deprecated.
Use
getName() instead. |
double |
getRobotVelocity()
Deprecated.
Use
getVelocity() instead. |
double |
getVelocity()
Returns the velocity of the robot.
|
boolean |
isSentryRobot()
Checks if the scanned robot is a sentry robot.
|
getPriority, getTime, setPriority, setTime
public ScannedRobotEvent()
ScannedRobotEvent(String, double, double, double, double, double, boolean)
instead.Note: You should not inherit from this class in your own event class! The internal logic of this event class might change. Hence, your robot might not work in future Robocode versions, if you choose to inherit from this class.
public ScannedRobotEvent(String name, double energy, double bearing, double distance, double heading, double velocity)
ScannedRobotEvent(String, double, double, double, double, double, boolean)
instead.name
- the name of the scanned robotenergy
- the energy of the scanned robotbearing
- the bearing of the scanned robot, in radiansdistance
- the distance from your robot to the scanned robotheading
- the heading of the scanned robotvelocity
- the velocity of the scanned robotpublic ScannedRobotEvent(String name, double energy, double bearing, double distance, double heading, double velocity, boolean isSentryRobot)
name
- the name of the scanned robotenergy
- the energy of the scanned robotbearing
- the bearing of the scanned robot, in radiansdistance
- the distance from your robot to the scanned robotheading
- the heading of the scanned robotvelocity
- the velocity of the scanned robotisSentryRobot
- flag specifying if the scanned robot is a sentry robotpublic double getBearing()
public double getBearingRadians()
public double getDistance()
public double getEnergy()
public double getHeading()
public double getHeadingRadians()
@Deprecated public double getLife()
getEnergy()
instead.public String getName()
@Deprecated public double getRobotBearing()
getBearing()
instead.@Deprecated public double getRobotBearingDegrees()
getBearing()
instead.@Deprecated public double getRobotBearingRadians()
getBearingRadians()
instead.@Deprecated public double getRobotDistance()
getDistance()
instead.@Deprecated public double getRobotHeading()
getHeading()
instead.@Deprecated public double getRobotHeadingDegrees()
getHeading()
instead.@Deprecated public double getRobotHeadingRadians()
getHeadingRadians()
instead.@Deprecated public double getRobotLife()
getEnergy()
instead.@Deprecated public String getRobotName()
getName()
instead.@Deprecated public double getRobotVelocity()
getVelocity()
instead.public double getVelocity()
public boolean isSentryRobot()
true
if the scanned robot is a sentry robot; false
otherwise.public final int compareTo(Event event)
This method will first compare the time of each event. If the event time is the same for both events, then this method compared the priority of each event. If the event priorities are equals, then this method will compare the two event based on specific event information.
This method is called by the game in order to sort the event queue of a robot to make sure the events are listed in chronological order.
compareTo
in interface Comparable<Event>
compareTo
in class Event
event
- the event to compare to this event.Copyright © 2021 Robocode. All Rights Reserved.