Class Creature

java.lang.Object
fr.formiko.kokcinelo.model.MapItem
fr.formiko.kokcinelo.model.Creature
Direct Known Subclasses:
AcidDrop, Ant, Aphid, Ladybug

public abstract class Creature extends MapItem
Abstact class that represent Creature on the map. Creature can move, fly, hit, eat, died.
Since:
0.1
Version:
2.5
  • Field Details

    • ORDER

      public static final List<Class<? extends Creature>> 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 wantedRotation
      Wanted 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

      protected Creature(String textureName)
      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

      public Set<Class<? extends Creature>> getCreaturesToHunt()
    • getCreaturesHuntedBy

      public Set<Class<? extends Creature>> getCreaturesHuntedBy()
    • getCreaturesFriendly

      public Set<Class<? extends Creature>> getCreaturesFriendly()
    • getCreaturesFriendlyWithVisibility

      public Set<Class<? extends Creature>> getCreaturesFriendlyWithVisibility()
    • haveCreatureToHunt

      public boolean haveCreatureToHunt()
    • haveCreatureHuntedBy

      public boolean haveCreatureHuntedBy()
    • getSpaceActionName

      @Null public String getSpaceActionName()
    • getSpaceActionProgress

      public float getSpaceActionProgress()
      Returns:
      progress of the creature action that can be done with space key.
    • getVisibleCreatureHuntedBy

      public Set<Creature> getVisibleCreatureHuntedBy()
      Creature witch hunt this & this can see it.
    • getClosestVisibleCreatureToHunt

      public Creature getClosestVisibleCreatureToHunt()
      Creature witch are hunted by this & this can see it.
    • getAllFriendlyCreature

      public Set<Creature> getAllFriendlyCreature()
      Returns:
      All friendly creatures of this.
    • getAllFriendlyWithVisibilityCreature

      public Set<Creature> getAllFriendlyWithVisibilityCreature()
      Returns:
      All friendly creatures of this witch this can see.
    • isFriendly

      public boolean isFriendly(Creature c)
    • isFriendlyWithVisibility

      public boolean isFriendlyWithVisibility(Creature c)
    • toString

      public String toString()
      Overrides:
      toString in class MapItem
    • see

      public boolean see(MapItem mi)
      Do this see mi
    • isTooCloseForStart

      public boolean isTooCloseForStart(MapItem mi)
    • 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 to
      degdif - 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

      public void goTo(MapItem mi)
    • runAwayFrom

      public void runAwayFrom(List<Float> forbiddenAngles, com.badlogic.gdx.math.Vector2... vectorList)
      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 from
      forbiddenAngles - contains angle to avoid as wall direction
    • closestCreature

      public Creature closestCreature(Collection<? extends Creature> coll)
      Return the closest Creature from the collection.
      Parameters:
      coll - Collection to iterate over
      Returns:
      the closest Creature from the collection
    • seeableCreatures

      public Collection<Creature> seeableCreatures(Collection<? extends Creature> coll)
      Return all the seeable Creature from the collection.
      Parameters:
      coll - Collection to iterate over
      Returns:
      the seeable creatures
    • moveAI

      public int moveAI(GameState gs)
      move as AI.
      Parameters:
      gs - GameState to use
    • getWallsAngles

      public List<Float> 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 map
      mapHeight - 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

      public void hit(Creature c)
      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.
      Overrides:
      addTime in class MapItem
      Parameters:
      timePaused - time that have run bewteen pause & resume
    • addScore

      public void addScore(int score)
      Add score to this creature team.