Package fr.formiko.kokcinelo.model
Class Creature
java.lang.Object
fr.formiko.kokcinelo.model.MapItem
fr.formiko.kokcinelo.model.Creature
Abstact class that represent Creature on the map.
Creature can move, fly, hit, eat, died.
- Since:
- 0.1
- Version:
- 2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected int
protected float
protected float
protected boolean
protected float
protected int
protected float
protected long
protected long
protected long
protected long
protected float
protected float
protected float
protected int
protected int
protected float
protected int
protected float
protected float
Wanted rotation relative to current one. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addScore
(int score) Add score to this creature team.void
addTime
(long timePaused) Add time to values that need it.void
boost()
Boost the creature.boolean
boolean
canHit()
boolean
canRun()
boolean
canShoot()
closestCreature
(Collection<? extends Creature> coll) Return the closest Creature from the collection.void
die()
Die, remove from controller & play diing animation.float
Creature witch are hunted by this & this can see it.int
float
float
int
float
float
long
float
float
float
float
float
int
float
Creature witch hunt this & this can see it.float
Return the angle of wall.float
void
goTo
(float newRotation) Set wanted rotation to reach newRotation.void
goTo
(com.badlogic.gdx.math.Vector2 v) Set wanted rotation to go to v.void
goTo
(com.badlogic.gdx.math.Vector2 v, float degdif) Set wanted rotation to go to v.void
boolean
boolean
void
Hit a Creature.boolean
isAI()
Return true if is an AI.boolean
isAlive()
boolean
boolean
boolean
void
minorRandomRotation
(double frequency) Sometime, rotate a bit, randomly.int
move as AI.void
Move in the facing direction at max speed.void
moveFront
(float percentOfSpeed) Move in the facing direction at speed percentOfSpeed.void
run()
void
runAwayFrom
(List<Float> forbiddenAngles, com.badlogic.gdx.math.Vector2... vectorList) Set wanted rotation to run away from v.boolean
Do this see miseeableCreatures
(Collection<? extends Creature> coll) Return all the seeable Creature from the collection.void
setCollectedFrequency
(int collectedFrequency) void
setCurrentSpeed
(float currentSpeed) void
setDefaultMoveFrontSpeed
(float defaultMoveFrontSpeed) void
setHearRadius
(float hearRadius) void
setHitPoints
(float hitPoints) void
setLastCollectedTime
(long lastCollectedTime) void
setLifePoints
(float lifePoints) Setter with max value.void
setMaxLifePoints
(float maxLifePoints) void
setMovingSpeed
(float movingSpeed) void
setShootPoints
(float shootPoints) void
setShootRadius
(int shootRadius) void
setVisionRadius
(float visionRadius) void
setWantedRotation
(float wantedRotation) void
shoot()
Shoot a Creature.void
stayInMap
(float mapWidth, float mapHeight) Check if the Creature is in the map & move inside if needed.toString()
Methods inherited from class fr.formiko.kokcinelo.model.MapItem
distanceTo, distanceTo, equals, getActor, getCenter, getCenterX, getCenterY, getHitRadius, getId, getRotation, getZoom, hashCode, hitBoxConnected, isInRadius, moveIn, removeActor, setCenter, setCenterX, setCenterY, setRandomLoaction, setRotation, setZoom
-
Field Details
-
ORDER
-
fliing
protected boolean fliing -
maxLifePoints
protected float maxLifePoints -
hitPoints
protected float hitPoints -
shootPoints
protected float shootPoints -
visionRadius
protected float visionRadius -
hearRadius
protected float hearRadius -
movingSpeed
protected float movingSpeed -
wantedRotation
protected float wantedRotationWanted rotation relative to current one. -
lastHitTime
protected long lastHitTime -
lastShootTime
protected long lastShootTime -
lastCollectedTime
protected long lastCollectedTime -
lastRunTime
protected long lastRunTime -
hitFrequency
protected int hitFrequency -
shootFrequency
protected int shootFrequency -
shootRadius
protected int shootRadius -
collectedFrequency
protected int collectedFrequency -
runFrequency
protected int runFrequency -
lifePoints
protected float lifePoints -
currentSpeed
protected float currentSpeed -
defaultMoveFrontSpeed
protected float defaultMoveFrontSpeed -
canFly
protected boolean canFly
-
-
Constructor Details
-
Creature
Main constructor.- Parameters:
textureName
- name of the texture to use from assets/images/
-
-
Method Details
-
getGivenPoints
public int getGivenPoints() -
getVisionRadius
public float getVisionRadius() -
setVisionRadius
public void setVisionRadius(float visionRadius) -
getHearRadius
public float getHearRadius() -
setHearRadius
public void setHearRadius(float hearRadius) -
getMaxRotationPerSecond
public float getMaxRotationPerSecond() -
getMovingSpeed
public float getMovingSpeed() -
setMovingSpeed
public void setMovingSpeed(float movingSpeed) -
getCurrentSpeed
public float getCurrentSpeed() -
setCurrentSpeed
public void setCurrentSpeed(float currentSpeed) -
getDefaultMoveFrontSpeed
public float getDefaultMoveFrontSpeed() -
setDefaultMoveFrontSpeed
public void setDefaultMoveFrontSpeed(float defaultMoveFrontSpeed) -
getWantedRotation
public float getWantedRotation() -
setWantedRotation
public void setWantedRotation(float wantedRotation) -
getLifePoints
public float getLifePoints() -
setLifePoints
public void setLifePoints(float lifePoints) Setter with max value. -
isAlive
public boolean isAlive() -
getMaxLifePoints
public float getMaxLifePoints() -
setMaxLifePoints
public void setMaxLifePoints(float maxLifePoints) -
getHitPoints
public float getHitPoints() -
setHitPoints
public void setHitPoints(float hitPoints) -
getShootPoints
public float getShootPoints() -
setShootPoints
public void setShootPoints(float shootPoints) -
getShootRadius
public int getShootRadius() -
setShootRadius
public void setShootRadius(int shootRadius) -
getAnimationSpeedMultiplier
public float getAnimationSpeedMultiplier() -
getCollectedFrequency
public int getCollectedFrequency() -
setCollectedFrequency
public void setCollectedFrequency(int collectedFrequency) -
getLastCollectedTime
public long getLastCollectedTime() -
setLastCollectedTime
public void setLastCollectedTime(long lastCollectedTime) -
getCreaturesToHunt
-
getCreaturesHuntedBy
-
getCreaturesFriendly
-
getCreaturesFriendlyWithVisibility
-
haveCreatureToHunt
public boolean haveCreatureToHunt() -
haveCreatureHuntedBy
public boolean haveCreatureHuntedBy() -
getSpaceActionName
-
getSpaceActionProgress
public float getSpaceActionProgress()- Returns:
- progress of the creature action that can be done with space key.
-
getVisibleCreatureHuntedBy
Creature witch hunt this & this can see it. -
getClosestVisibleCreatureToHunt
Creature witch are hunted by this & this can see it. -
getAllFriendlyCreature
- Returns:
- All friendly creatures of this.
-
getAllFriendlyWithVisibilityCreature
- Returns:
- All friendly creatures of this witch this can see.
-
isFriendly
-
isFriendlyWithVisibility
-
toString
-
see
Do this see mi -
isTooCloseForStart
-
boost
public void boost()Boost the creature. -
moveFront
public void moveFront(float percentOfSpeed) Move in the facing direction at speed percentOfSpeed. If a wantedRotation have been set, go for it.- Parameters:
percentOfSpeed
- percent of max speed.
-
moveFront
public void moveFront()Move in the facing direction at max speed. -
goTo
public void goTo(com.badlogic.gdx.math.Vector2 v, float degdif) Set wanted rotation to go to v.- Parameters:
v
- contains coordinate of Point to got todegdif
- Degre difference to go to
-
goTo
public void goTo(float newRotation) Set wanted rotation to reach newRotation.- Parameters:
newRotation
- rotation to reach
-
goTo
public void goTo(com.badlogic.gdx.math.Vector2 v) Set wanted rotation to go to v.- Parameters:
v
- contains coordinate of Point to got to
-
goTo
-
runAwayFrom
Set wanted rotation to run away from v. To run away from we calculate angle to each enemy & wall. Then we run away from the biggest angle.- Parameters:
vectorList
- contains coordinate of Points to run away fromforbiddenAngles
- contains angle to avoid as wall direction
-
closestCreature
Return the closest Creature from the collection.- Parameters:
coll
- Collection to iterate over- Returns:
- the closest Creature from the collection
-
seeableCreatures
Return all the seeable Creature from the collection.- Parameters:
coll
- Collection to iterate over- Returns:
- the seeable creatures
-
moveAI
move as AI.- Parameters:
gs
- GameState to use
-
getWallsAngles
Return the angle of wall. It is used to avoid wall when running away by adding them as enemies.- Returns:
- the angle of wall (sorted)
-
stayInMap
public void stayInMap(float mapWidth, float mapHeight) Check if the Creature is in the map & move inside if needed. It also change wantedRotation if a wall have been hit.- Parameters:
mapWidth
- width of the mapmapHeight
- height of the map
-
minorRandomRotation
public void minorRandomRotation(double frequency) Sometime, rotate a bit, randomly. It will move by max 20° from the current rotation.- Parameters:
frequency
- double in [0,1]. Next to 0 it hapend only fiew time. Next to 1 almost all time.
-
canHit
public boolean canHit()- Returns:
- true if this can hit other creatures
-
hit
Hit a Creature.- Parameters:
c
- creature to hit
-
die
public void die()Die, remove from controller & play diing animation. -
canShoot
public boolean canShoot()- Returns:
- true if this can shoot other creatures
-
canRun
public boolean canRun() -
canBeCollected
public boolean canBeCollected() -
shoot
public void shoot()Shoot a Creature. -
run
public void run() -
isAI
public boolean isAI()Return true if is an AI. -
addTime
public void addTime(long timePaused) Add time to values that need it. It is used when the game is resume to avoid that creature can hit & shoot again even if game time have'nt run. -
addScore
public void addScore(int score) Add score to this creature team.
-