|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrobocode.Event
robocode.CustomEvent
public class CustomEvent
This event is sent to onCustomEvent() when a custom condition is met. Be sure to reset or remove
the custom condition to avoid having it recurring repeatedly (see the
example for the getCondition() method.
getCondition(),
Serialized Form| Constructor Summary | |
|---|---|
CustomEvent(Condition condition)
Called by the game to create a new CustomEvent when a condition is met. |
|
CustomEvent(Condition condition,
int priority)
Called by the game to create a new CustomEvent when a condition is met. |
|
| Method Summary | |
|---|---|
int |
compareTo(Event event)
Compares this event to another event regarding precedence. |
Condition |
getCondition()
Returns the condition that fired, causing this event to be generated. |
int |
getPriority()
Returns the priority of this event. |
| Methods inherited from class robocode.Event |
|---|
getTime, setPriority, setTime |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CustomEvent(Condition condition)
condition - the condition that must be met
public CustomEvent(Condition condition,
int priority)
Condition.setPriority(int) on the
Condition.
condition - the condition that must be metpriority - the priority of the condition| Method Detail |
|---|
public Condition getCondition()
public void onCustomEvent(CustomEvent event) {
if (event.getCondition().getName().equals("mycondition")) {
removeCustomEvent(event.getCondition());
// do something else
}
}
public final int compareTo(Event event)
compareTo in interface Comparable<Event>compareTo in class Eventevent - the event to compare to this event.
public final int getPriority()
An event priority is a value from 0 - 99. The higher value, the higher priority.
The default priority is 80, but varies depending on the type of event.
getPriority in class Event
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||