Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
Robot
or
AdvancedRobot
first.
JuniorRobot
, Robot
, AdvancedRobot
, Droid
Field Summary |
Fields inherited from class robocode._RobotBase | |
out |
Method Summary | |
void |
|
Vector |
|
ITeamEvents |
|
String[] |
|
boolean |
|
void |
|
void |
|
Methods inherited from class robocode._Robot | |
String getGunImageName , String getRadarImageName , String getRobotImageName , double getGunCharge , double getLife , int getBattleNum , int getNumBattles , setInterruptible , void setGunImageName , void setRadarImageName , void setRobotImageName |
Methods inherited from class robocode._RobotBase | |
setOut , setPeer |
public void broadcastMessage(Serializable message) throws IOException
Broadcasts a message to all teammates. Example:public void run() { broadcastMessage("I'm here!"); }
- Parameters:
message
- the message to broadcast to all teammates
public VectorgetMessageEvents()
Returns a vector containing all MessageEvents currently in the robot's queue. You might, for example, call this while processing another event. Example:for (MessageEvent e : getMessageEvents()) { // do something with e }
- Returns:
- a vector containing all MessageEvents currently in the robot's queue
- Since:
- 1.2.6
- See Also:
onMessageReceived(MessageEvent)
,MessageEvent
public final ITeamEvents getTeamEventListener()
Do not call this method!
- Specified by:
- getTeamEventListener in interface ITeamRobot
public String[] getTeammates()
Returns the names of all teammates, ornull
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); } } }
- Returns:
- a String array containing the names of all your teammates, or
null
if there is no teammates. The length of the String array is equal to the number of teammates.
public boolean isTeammate(String name)
Checks if a given robot name is the name of one of your teammates. Example:public void onScannedRobot(ScannedRobotEvent e) { if (isTeammate(e.getName()) { return; } fire(1); }
- Parameters:
name
- the robot name to check
- Returns:
true
if the specified name belongs to one of your teammates;false
otherwise.
public void onMessageReceived(MessageEvent event)
- Specified by:
- onMessageReceived in interface ITeamEvents
public void sendMessage(String name, Serializable message) throws IOException
Sends a message to one (or more) teammates. Example:public void run() { sendMessage("sample.DroidBot", "I'm here!"); }
- Parameters:
name
- the name of the intended recipient of the messagemessage
- the message to send