Class SplitMoblings

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.npc.SplitMoblings

public class SplitMoblings extends Component
A component that splits the target mob entity into multiple entities after after the mob dies. This class adds a method to the existing event listener "dieStart".

Amount of moblings spawned must be provided in the construcor. Scaled size of the moblings can be altered in the X and Y direction if desired. If not provided scaling alteration is assumed to be 0.75.

  • Field Details

  • Constructor Details

    • SplitMoblings

      public SplitMoblings(int amount)
      Initialises a component that splits mob into multiple moblings. Amount of moblings split based on the amount provided param.
      Parameters:
      amount - Amount of moblings to be split.
      Require:
      amount > 0
    • SplitMoblings

      public SplitMoblings(int amount, float scale)
      Initialises a component that splits mob into multiple moblings. Amount of moblings split is based on the amount provided param. The overalling scaling (x and y) is also altered in the param.
      Parameters:
      amount - Amount of moblings to be split.
      scale - X and Y scaling of the moblings in respect to the original size of the mobs.
      Require:
      amount > 0
    • SplitMoblings

      public SplitMoblings(int amount, float scaleX, float scaleY)
      Initialises a component that splits mob into multiple moblings. Amount of moblings split is based on the amount provided param. The individual scaling (x and y) is also altered in the param.
      Parameters:
      amount - Amount of moblings to be split.
      scaleX - X scaling of the moblings compared to original size.
      scaleY - Y scaling of the moblings compared to original size.
      Require:
      amount > 0
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • spawnAdditionalMob

      public void spawnAdditionalMob(float positionX, float positionY, float initialScaleX, float initialScaleY)
      Helper function that spawns a xeno grunt based on a x and y-coordinate and scales down/up the entity based on the initial scale and this object's scale.
      Parameters:
      positionX - New spawn x-coordinate
      positionY - New spawn y-coordinate
      initialScaleX - Initial horizontal scale of the entity
      initialScaleY - Initial vertical scale of the entity