public interface ITeamRobotPeer extends IAdvancedRobotPeer
TeamRobot.
A robot peer is the object that deals with game mechanics and rules, and makes sure your robot abides by them.
IBasicRobotPeer,
IStandardRobotPeer,
IAdvancedRobotPeer,
IJuniorRobotPeer| Modifier and Type | Method and Description |
|---|---|
void |
broadcastMessage(Serializable message)
Broadcasts a message to all teammates.
|
List<MessageEvent> |
getMessageEvents()
Returns a vector containing all MessageEvents currently in the robot's
queue.
|
String[] |
getTeammates()
Returns the names of all teammates, or
null there is no
teammates. |
boolean |
isTeammate(String name)
Checks if a given robot name is the name of one of your teammates.
|
void |
sendMessage(String name,
Serializable message)
Sends a message to one (or more) teammates.
|
addCustomEvent, clearAllEvents, getAllEvents, getBulletHitBulletEvents, getBulletHitEvents, getBulletMissedEvents, getDataDirectory, getDataFile, getDataQuotaAvailable, getEventPriority, getHitByBulletEvents, getHitRobotEvents, getHitWallEvents, getRobotDeathEvents, getScannedRobotEvents, getStatusEvents, isAdjustGunForBodyTurn, isAdjustRadarForBodyTurn, isAdjustRadarForGunTurn, removeCustomEvent, setEventPriority, setInterruptible, setMaxTurnRate, setMaxVelocity, setMove, setResume, setStop, setTurnBody, setTurnGun, setTurnRadar, waitForresume, setAdjustGunForBodyTurn, setAdjustRadarForBodyTurn, setAdjustRadarForGunTurn, stop, turnRadarexecute, fire, getBattleFieldHeight, getBattleFieldWidth, getBodyHeading, getBodyTurnRemaining, getCall, getDistanceRemaining, getEnergy, getGraphics, getGunCoolingRate, getGunHeading, getGunHeat, getGunTurnRemaining, getName, getNumRounds, getNumSentries, getOthers, getRadarHeading, getRadarTurnRemaining, getRoundNum, getSentryBorderSize, getTime, getVelocity, getX, getY, move, rescan, setBodyColor, setBulletColor, setCall, setDebugProperty, setFire, setGunColor, setRadarColor, setScanColor, turnBody, turnGunString[] getTeammates()
null there is no
teammates.
Example:
public void run() {
// Prints out all teammates
String[] teammates = getTeammates();
if (teammates != null) {
for (String member : teammates) {
out.println(member);
}
}
}
null if there is no teammates. The length of the String array
is equal to the number of teammates.isTeammate(String),
broadcastMessage(Serializable),
sendMessage(String, Serializable)boolean isTeammate(String name)
Example:
public void onScannedRobot(ScannedRobotEvent e) {
if (isTeammate(e.getName()) {
return;
}
fire(1);
}
name - the robot name to checktrue if the specified name belongs to one of your
teammates; false otherwise.getTeammates(),
broadcastMessage(Serializable),
sendMessage(String, Serializable)void broadcastMessage(Serializable message) throws IOException
Example:
public void run() {
broadcastMessage("I'm here!");
}
message - the message to broadcast to all teammatesIOException - if the message could not be broadcasted to the
teammatesisTeammate(String),
getTeammates(),
sendMessage(String, Serializable)void sendMessage(String name, Serializable message) throws IOException
Example:
public void run() {
sendMessage("sample.DroidBot", "I'm here!");
}
name - the name of the intended recipient of the messagemessage - the message to sendIOException - if the message could not be sentisTeammate(String),
getTeammates(),
broadcastMessage(Serializable)List<MessageEvent> getMessageEvents()
Example:
for (MessageEvent e : getMessageEvents()) {
// do something with e
}
onMessageReceived(MessageEvent),
MessageEventCopyright © 2021 Robocode. All Rights Reserved.