Class PlantProximityComponent

All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable

public class PlantProximityComponent extends HitboxComponent
Component to inform the plant when the player is close enough for plant sounds to be played. This will prevent the game from being clogged up with plant sounds.
  • Constructor Details

    • PlantProximityComponent

      public PlantProximityComponent()
      Constructor for the plant proximity component. Just used to setting the radius of the area. The radius will be the same for all plants.
  • Method Details

    • getRadius

      public float getRadius()
      Gets the radius of the hitbox area.
      Returns:
      the radius of the hitbox area.
    • getShape

      public com.badlogic.gdx.physics.box2d.CircleShape getShape()
      Gets the shape of the hitbox area.
      Returns:
      the shape of the hitbox area
    • create

      public void create()
      Sets up the radius for the collider and listen for relevant services.
      Overrides:
      create in class HitboxComponent
    • onCollisionStart

      public void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other)
      Checks if the entity is the player on collision start. If the entity is the player then tell the plant that the player is in range.
      Parameters:
      me - The fixture of this component.
      other - The fixture of the colliding entity.