Class Actor

java.lang.Object
  |
  +--Actor

public class Actor
extends java.lang.Object

The Actor class is used to get an abstraction of the plain text commands so that the can be used via methods. The methods compose the commands and send them via the communicationChannel link.

Version:
1.1
Author:
Gerald Kuehne, Markus Beier

Field Summary
private  CommunicationChannel communicationChannel
          reference to the communicationChannel
 
Constructor Summary
Actor(CommunicationChannel communicationChannel)
          Creates a new Actor instance.
 
Method Summary
 void dash(double power)
          Gives a running impulse
 Event event()
          Receives incoming messages from the server.
 void init(java.lang.String teamName)
          Registers itself to to the server specifying protocol version 7.0.
NOTE: If you don't use version 7.0, it may occur that you will not receive a sense_body event and that the names of the objects will be written in a different way like "flag" instead of "f".
 void kick(double power, double direction)
          Kicks into a given direction with given power
 void move(double x, double y)
          Places the player to a given position on the field.
 void turn(double moment)
          Turns the body of the client on the field.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

communicationChannel

private CommunicationChannel communicationChannel
reference to the communicationChannel
Constructor Detail

Actor

public Actor(CommunicationChannel communicationChannel)
Creates a new Actor instance.
Parameters:
communicationChannel - a CommunicationChannel value defining the communicationChannel link to the server via which the commands can be sent
See Also:
CommunicationChannel
Method Detail

init

public void init(java.lang.String teamName)
Registers itself to to the server specifying protocol version 7.0.
NOTE: If you don't use version 7.0, it may occur that you will not receive a sense_body event and that the names of the objects will be written in a different way like "flag" instead of "f". This may cause problems if you assume a special format for parsing.
Parameters:
teamName - The name of the team the player should join or create if it does not already exist and there less than two teams already present on the field

event

public Event event()
Receives incoming messages from the server. They are automatically classified and passed on to the correct parsing/representation classes.
NOTE: The receive() method is blocking because is uses the blocking receive() method of the CommunicationChannel class. Therefor the thread will be interrupted until a new message arrives.
Returns:
an Event object containing the parsed information of the read message
See Also:
CommunicationChannel

dash

public void dash(double power)
Gives a running impulse
Parameters:
power - a double value containing the power of the impulse

kick

public void kick(double power,
                 double direction)
Kicks into a given direction with given power
Parameters:
power - a double value specifying the power of the kick
direction - a double value giving the direction of the kick

move

public void move(double x,
                 double y)
Places the player to a given position on the field. Only possible:
Parameters:
x - gives the position in x direction. The position can vary from -52.5 to 52.5. The unit is meter. Negative values stand for the own half of the field, positive values stand for the opponent's half. The value itself gives the distance from the mid-line.
y - gives the position in y direction. The position can vary from -34.0 to 34.0. The unit is meter. Negative values stand for the left side of the field when looked in direction of the opponent's goal.Positive value stand for the right side. The value itself gives the distance from the line going through the center of both goal and the middle point of the field.

turn

public void turn(double moment)
Turns the body of the client on the field.
Parameters:
moment - is the angle in degree you want to turn. The orientation is clockwise so that positive angles mean right turns. The absolute value of the angle must be smaller than 180 degrees. Otherwise the the server will take the turn as a 180 degree turn. So it should be assured that the angle are normalized before usage