|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.farafin.snEADy.world.C_GameObject
de.farafin.snEADy.world.C_Snake
public final class C_Snake
this is the snake.. the body of the player controlled objects
Field Summary | |
---|---|
protected int |
length
the length of the snake |
protected float |
lengthRateStatus
Every LENGTH_RATE's killed segment, the snake gets one segment longer, so here is the status stored.. |
protected long |
nextAutoGrow
reallize the autoGrow |
protected long |
nextAutoSlow
for realizing autoslow.. |
protected D_PlayerData |
pilot
the "pilot" of the snake. the controlling element. |
private long |
pilotDelay
for checking if something changed |
private int |
pilotLength
for checking if something changed |
protected int |
status
status of the snake |
protected int |
survivalBonus
the survival bonus a snake gets if it reaches the exit |
Fields inherited from class de.farafin.snEADy.world.C_GameObject |
---|
faceDirection, headPosition, nextUpdateTime, objPositions, ownChar, parameter, waitCycles |
Fields inherited from interface de.farafin.snEADy.communication.I_PlayFieldConstants |
---|
EXIT, FIELD_B, FIELD_C, FIELD_D, FIELD_E, FIELD_F, FIELD_G, FIELD_H, FIELD_I, FIELD_J, FIELD_K, FIELD_L, FIELD_M, FIELD_N, FIELD_O, FIELD_P, FIELD_Q, FIELD_R, FIELD_S, FIELD_T, FIELD_U, FIELD_V, FIELD_W, FIELD_X, FIELD_Y, FIELD_Z, FREE, GOODY_f, GOODY_g, GOODY_h, GOODY_i, GOODY_j, GOODY_k, GOODY_l, GOODY_LAST, GOODY_m, GOODY_n, GOODY_o, GOODY_p, GOODY_q, GOODY_r, GOODY_s, GOODY_START, GOODY_t, GOODY_u, GOODY_v, GOODY_w, GOODY_x, GOODY_y, GOODY_z, LENGTH, PLAYER_0, PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4, PLAYER_5, PLAYER_6, PLAYER_7, PLAYER_8, PLAYER_9, POINTS, SHORT, SLOW, SPEED, WALL |
Constructor Summary | |
---|---|
protected |
C_Snake()
default constructor |
protected |
C_Snake(D_PlayerData playerData,
GameParameter parameter)
|
protected |
C_Snake(D_Vec2D headPosition,
int faceDirection,
char ownChar,
D_PlayerData pilot,
long waitCycles,
GameParameter parameter)
constructor |
protected |
C_Snake(D_Vec2D headPosition,
int faceDirection,
char ownChar,
int length,
D_PlayerData pilot,
long waitCycles,
GameParameter parameter)
constructor |
protected |
C_Snake(D_Vec2D headPosition,
int faceDirection,
RingVector objPositions,
char ownChar,
int length,
D_PlayerData pilot,
long waitCycles,
GameParameter parameter)
smart Constructor |
protected |
C_Snake(D_Vec2D headPosition,
int faceDirection,
RingVector objPositions,
char ownChar,
int status,
int length,
D_PlayerData pilot,
long waitCycles,
GameParameter parameter)
create Constructor |
Method Summary | |
---|---|
private void |
actualizateSnakeLength(C_Arena arena)
|
protected java.lang.Object |
clone()
|
private void |
computeKillPoints(C_Arena arena,
C_Snake snake,
boolean died)
computes the kill points for other snakes if this one looses a segment or is killed |
private void |
die(C_Arena arena,
C_Snake killer)
kills the snake |
protected D_Vec2D[] |
getAllPosSorted(int sort)
|
private char |
getCharDirHead(C_Arena arena,
int direction)
checs which char is in direction of direction<\code>. |
protected D_PlayerData |
getPilot()
|
private boolean |
isBlocked(char c)
|
protected void |
jumpTo(D_Vec2D pos,
C_Arena arena)
moves the object with all its positions to the specific position. |
protected void |
moveToFace(C_Arena arena)
let the object move one field to the direction of its head it is necessary, that there it is computed here what happands if the object runns into a wall.. |
private void |
paintSnake(C_Arena arena)
paints all elements of the snake to the arena. doesnt remove fragments of old segments. |
private D_Vec2D |
removeLastSegments(C_Arena arena,
int n)
|
java.lang.String |
toString()
|
private void |
turnHead(C_Arena arena)
turns the head to the direction pilot |
private void |
turnHeadBack()
turns the head to the opposide direction of what pilot sais pilot |
protected void |
update(C_Arena arena)
the update call meens that the object should do what ever it does usually |
private void |
updateLengthState()
if the length state is bigger than one, the snake gets longer.. |
protected void |
updatePilot()
updates the own informations with the snake infos |
private void |
updateSpeedState()
if speed State is more than one, the snake gets slower |
Methods inherited from class de.farafin.snEADy.world.C_GameObject |
---|
getAllPosArray, getAllPosList, getFaceDirection, getHeadPosition, getNextPosInFaceDirection, getNextUpdateTime, getOwnChar, jumpHeadPos, setFaceDirection, setHeadPosition |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int status
I_Constants.IN_ACTION
,
I_Constants.IN_HEAVEN
,
I_Constants.IN_EXIT
,
I_Constants.IN_ERROR_TIME
,
I_Constants.IN_ERROR_SPACE
,
I_Constants.IN_ERROR_INIT
,
I_Constants.IN_ERROR_EXC
protected int length
protected float lengthRateStatus
protected long nextAutoGrow
protected long nextAutoSlow
protected D_PlayerData pilot
private int pilotLength
private long pilotDelay
protected int survivalBonus
Constructor Detail |
---|
protected C_Snake()
protected C_Snake(D_Vec2D headPosition, int faceDirection, RingVector objPositions, char ownChar, int status, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)
headPosition
- faceDirection
- objPositions
- ownChar
- status
- length
- pilot
- waitCycles
- parameter
- protected C_Snake(D_Vec2D headPosition, int faceDirection, char ownChar, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)
headPosition
- faceDirection
- ownChar
- length
- pilot
- waitCycles
- parameter
- protected C_Snake(D_Vec2D headPosition, int faceDirection, char ownChar, D_PlayerData pilot, long waitCycles, GameParameter parameter)
headPosition
- faceDirection
- ownChar
- pilot
- waitCycles
- parameter
- protected C_Snake(D_Vec2D headPosition, int faceDirection, RingVector objPositions, char ownChar, int length, D_PlayerData pilot, long waitCycles, GameParameter parameter)
headPosition
- faceDirection
- objPositions
- ownChar
- length
- pilot
- waitCycles
- parameter
- protected C_Snake(D_PlayerData playerData, GameParameter parameter)
playerData
- parameter
- Method Detail |
---|
private void computeKillPoints(C_Arena arena, C_Snake snake, boolean died)
arena
- snake
- died
- private D_Vec2D removeLastSegments(C_Arena arena, int n)
arena
- n
- the number of segmnets that should removed
private void actualizateSnakeLength(C_Arena arena)
arena
- private void die(C_Arena arena, C_Snake killer)
arena
- the arena the snake is living inkiller
- if the snake was killed by an other snake, this is it. otherwise killer is nullprotected void moveToFace(C_Arena arena)
arena
- private void updateLengthState()
private void updateSpeedState()
protected void updatePilot()
private void turnHead(C_Arena arena)
arena
- private void turnHeadBack()
protected void update(C_Arena arena)
C_GameObject
update
in class C_GameObject
arena
- the arena the object is living inprivate char getCharDirHead(C_Arena arena, int direction)
direction<\code>.
- Parameters:
arena
- direction
-
- Returns:
- the field at arena
private void paintSnake(C_Arena arena)
arena
- private boolean isBlocked(char c)
c
-
protected void jumpTo(D_Vec2D pos, C_Arena arena)
C_GameObject
jumpTo
in class C_GameObject
pos
- the desteny position of the head.protected D_Vec2D[] getAllPosSorted(int sort)
getAllPosSorted
in class C_GameObject
sort
- maybe there are more than one way to sort the object positions, this
parameter specifies the kind of sort.
protected java.lang.Object clone()
clone
in class C_GameObject
public java.lang.String toString()
toString
in class C_GameObject
protected D_PlayerData getPilot()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |