Class ScannedRobotEvent
- java.lang.Object
-
- robocode.Event
-
- robocode.ScannedRobotEvent
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Event>
public class ScannedRobotEvent extends Event
A ScannedRobotEvent is sent toonScannedRobot()
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.
- Author:
- Mathew A. Nelson (original), Flemming N. Larsen (contributor)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ScannedRobotEvent()
Deprecated.ScannedRobotEvent(java.lang.String name, double energy, double bearing, double distance, double heading, double velocity)
Deprecated.ScannedRobotEvent(java.lang.String name, double energy, double bearing, double distance, double heading, double velocity, boolean isSentryRobot)
Called by the game to create a new ScannedRobotEvent.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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.UsegetEnergy()
instead.java.lang.String
getName()
Returns the name of the robot.double
getRobotBearing()
Deprecated.UsegetBearing()
instead.double
getRobotBearingDegrees()
Deprecated.UsegetBearing()
instead.double
getRobotBearingRadians()
Deprecated.UsegetBearingRadians()
instead.double
getRobotDistance()
Deprecated.UsegetDistance()
instead.double
getRobotHeading()
Deprecated.UsegetHeading()
instead.double
getRobotHeadingDegrees()
Deprecated.UsegetHeading()
instead.double
getRobotHeadingRadians()
Deprecated.UsegetHeadingRadians()
instead.double
getRobotLife()
Deprecated.UsegetEnergy()
instead.java.lang.String
getRobotName()
Deprecated.UsegetName()
instead.double
getRobotVelocity()
Deprecated.UsegetVelocity()
instead.double
getVelocity()
Returns the velocity of the robot.boolean
isSentryRobot()
Checks if the scanned robot is a sentry robot.-
Methods inherited from class robocode.Event
getPriority, getTime, setPriority, setTime
-
-
-
-
Constructor Detail
-
ScannedRobotEvent
public ScannedRobotEvent()
Deprecated.This constructor is only provided in order to preserve backwards compatibility with old robots that inherits from this Event class.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.
-
ScannedRobotEvent
public ScannedRobotEvent(java.lang.String name, double energy, double bearing, double distance, double heading, double velocity)
Deprecated.Called by the game to create a new ScannedRobotEvent.- Parameters:
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 robot
-
ScannedRobotEvent
public ScannedRobotEvent(java.lang.String name, double energy, double bearing, double distance, double heading, double velocity, boolean isSentryRobot)
Called by the game to create a new ScannedRobotEvent.- Parameters:
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 robot- Since:
- 1.9.0.0
-
-
Method Detail
-
getBearing
public double getBearing()
Returns the bearing to the robot you scanned, relative to your robot's heading, in degrees (-180 <= getBearing() < 180)- Returns:
- the bearing to the robot you scanned, in degrees
-
getBearingRadians
public double getBearingRadians()
Returns the bearing to the robot you scanned, relative to your robot's heading, in radians (-PI <= getBearingRadians() < PI)- Returns:
- the bearing to the robot you scanned, in radians
-
getDistance
public double getDistance()
Returns the distance to the robot (your center to his center).- Returns:
- the distance to the robot.
-
getEnergy
public double getEnergy()
Returns the energy of the robot.- Returns:
- the energy of the robot
-
getHeading
public double getHeading()
Returns the heading of the robot, in degrees (0 <= getHeading() < 360)- Returns:
- the heading of the robot, in degrees
-
getHeadingRadians
public double getHeadingRadians()
Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI)- Returns:
- the heading of the robot, in radians
-
getLife
@Deprecated public double getLife()
Deprecated.UsegetEnergy()
instead.- Returns:
- the energy of the robot
-
getName
public java.lang.String getName()
Returns the name of the robot.- Returns:
- the name of the robot
-
getRobotBearing
@Deprecated public double getRobotBearing()
Deprecated.UsegetBearing()
instead.- Returns:
- the bearing to the robot you scanned, in degrees
-
getRobotBearingDegrees
@Deprecated public double getRobotBearingDegrees()
Deprecated.UsegetBearing()
instead.- Returns:
- the robot bearing in degrees
-
getRobotBearingRadians
@Deprecated public double getRobotBearingRadians()
Deprecated.UsegetBearingRadians()
instead.- Returns:
- the bearing to the robot you scanned, in radians
-
getRobotDistance
@Deprecated public double getRobotDistance()
Deprecated.UsegetDistance()
instead.- Returns:
- the distance to the robot.
-
getRobotHeading
@Deprecated public double getRobotHeading()
Deprecated.UsegetHeading()
instead.- Returns:
- the heading of the robot, in degrees
-
getRobotHeadingDegrees
@Deprecated public double getRobotHeadingDegrees()
Deprecated.UsegetHeading()
instead.- Returns:
- the heading of the robot, in degrees
-
getRobotHeadingRadians
@Deprecated public double getRobotHeadingRadians()
Deprecated.UsegetHeadingRadians()
instead.- Returns:
- the heading of the robot, in radians
-
getRobotLife
@Deprecated public double getRobotLife()
Deprecated.UsegetEnergy()
instead.- Returns:
- the energy of the robot
-
getRobotName
@Deprecated public java.lang.String getRobotName()
Deprecated.UsegetName()
instead.- Returns:
- the name of the robot
-
getRobotVelocity
@Deprecated public double getRobotVelocity()
Deprecated.UsegetVelocity()
instead.- Returns:
- the velocity of the robot
-
getVelocity
public double getVelocity()
Returns the velocity of the robot.- Returns:
- the velocity of the robot
-
isSentryRobot
public boolean isSentryRobot()
Checks if the scanned robot is a sentry robot.- Returns:
true
if the scanned robot is a sentry robot;false
otherwise.- Since:
- 1.9.0.0
-
compareTo
public final int compareTo(Event event)
Compares this event to another event regarding precedence. The event precedence is first and foremost determined by the event time, secondly the event priority, and lastly specific event information.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.
- Specified by:
compareTo
in interfacejava.lang.Comparable<Event>
- Overrides:
compareTo
in classEvent
- Parameters:
event
- the event to compare to this event.- Returns:
- a negative value if this event has higher precedence, i.e. must be listed before the specified event. A positive value if this event has a lower precedence, i.e. must be listed after the specified event. 0 means that the precedence of the two events are equal.
-
-