public class SServerPlayer extends AbstractUDPClient implements ActionsPlayer
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
SServerPlayer(String teamName,
ControllerPlayer c)
A part constructor for SServerPlayer (assumes localhost:6000)
|
SServerPlayer(String teamName,
ControllerPlayer c,
int port,
String hostname)
The full constructor for SServerPlayer.
|
Modifier and Type | Method and Description |
---|---|
void |
bye()
This is used to disconnect a player from the server.
|
void |
catchBall(double direction)
Goalie special command.
|
void |
changeViewMode(ViewQuality quality,
ViewAngle angle)
Changes the view parameters of the player.
|
void |
connect(boolean isGoalie)
Connects to the server via AbstractUDPClient.
|
void |
dash(int power)
This command accelerates the player in the direction of its body.
|
protected String |
getDescription()
Returns a description of this class.
|
String |
getInitMessage()
Returns the init message for this client.
|
int |
getNumber()
Gets the players number.
|
String |
getTeamName()
Requests the name of the team the player features in.
|
void |
handleError(String error)
The method used to show errors.
|
boolean |
isTeamEast()
Checks if the team is east or west.
|
void |
kick(int power,
double direction)
This command accelerates the ball with the given power in the given direction.
|
void |
move(int x,
int y)
This command can only be executed before kick off or after a goal.
|
void |
received(String msg)
Received a message.
|
void |
say(String message)
This command broadcasts the message throughout the field.
|
void |
setNumber(int num)
Sets the players number.
|
void |
setTeamEast(boolean is)
Sets the team as east or west.
|
void |
start()
Start the thread.
|
String |
toListString()
Create a list string.
|
String |
toStateString()
Returns a string containing the connection details.
|
void |
turn(double angle)
This command will turn the players body in degrees relative to their
current direction.
|
void |
turnNeck(double angle)
This command can be sent (and will be executed) each cycle independently,
along with other action commands.
|
isRunning, pauseMilliseconds, run, send, stopRunning
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
public SServerPlayer(String teamName, ControllerPlayer c)
teamName
- The team name.c
- The controller for the player.public SServerPlayer(String teamName, ControllerPlayer c, int port, String hostname)
teamName
- The teams name.c
- The controller for the player.port
- The port to connect to.hostname
- The host address.public String getInitMessage()
getInitMessage
in class AbstractUDPClient
public void connect(boolean isGoalie)
isGoalie
- a boolean.public void start()
start
in class AbstractUDPClient
public void received(String msg) throws IOException
received
in class AbstractUDPClient
msg
- The message received.IOException
- if any.public void setTeamEast(boolean is)
setTeamEast
in interface ActionsPlayer
is
- true if east.public void dash(int power)
dash
in interface ActionsPlayer
power
- Power is between minpower (-100) and maxpower (+100).public void kick(int power, double direction)
kick
in interface ActionsPlayer
power
- Power is between minpower (-100) and maxpower (+100).direction
- Direction is relative to the body of the player.public void move(int x, int y)
move
in interface ActionsPlayer
x
- X location (between -54 and +54).y
- Y location (between -32 and +32).public void say(String message)
say
in interface ActionsPlayer
message
- A valid String to say.public void turn(double angle)
turn
in interface ActionsPlayer
angle
- Angle to turn (between -180 and +180).public void turnNeck(double angle)
turnNeck
in interface ActionsPlayer
angle
- Angle to turn the neck (between minneckang and maxneckang) (-90 to +90)public void catchBall(double direction)
catchBall
in interface ActionsPlayer
direction
- The direction in which to catch, relative to its body.public void changeViewMode(ViewQuality quality, ViewAngle angle)
changeViewMode
in interface ActionsPlayer
quality
- Between HIGH or LOW.angle
- Between NARROW, NORMAL or WIDE.public void bye()
bye
in interface ActionsPlayer
public String getTeamName()
getTeamName
in interface ActionsPlayer
public void setNumber(int num)
setNumber
in interface ActionsPlayer
num
- The players number (from 1 to 11).public int getNumber()
getNumber
in interface ActionsPlayer
public boolean isTeamEast()
isTeamEast
in interface ActionsPlayer
public String toListString()
public String toStateString()
toStateString
in class AbstractUDPClient
public void handleError(String error)
handleError
in interface ActionsPlayer
error
- The error to show.protected String getDescription()
getDescription
in class AbstractUDPClient
Copyright © 2003–2015 Atan. All rights reserved.