Class UpgradeTree

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.upgradetree.UpgradeTree

public class UpgradeTree extends Component
Represents the upgrade tree component for the game, which manages weapon upgrades.
  • Constructor Details

    • UpgradeTree

      public UpgradeTree()
      Constructs a new UpgradeTree with default weapons unlocked.
  • Method Details

    • getUnlockedWeapons

      public List<Object> getUnlockedWeapons()
      Returns a list of all unlocked weapons.
      Returns:
      The list of unlocked weapons.
    • unlockWeapon

      public void unlockWeapon(Object weapon)
      Unlocks a specified weapon type, adding it to the list of unlocked weapons if it's not already there.
      Parameters:
      weapon - The type of weapon to unlock. unlockWeapon() - adding weapon on nodes if weapon is locked, also plays the sound when upgrading weapons
    • isWeaponUnlocked

      public boolean isWeaponUnlocked(Object weapon)
      Checks if a given weapon type is already unlocked.
      Parameters:
      weapon - The type of weapon to check.
      Returns:
      True if the weapon is unlocked, false otherwise.
    • getMaterials

      public int getMaterials()
      Retrieves the current number of materials available to the player. It fetches this value from the game's state observer, updating the local materials value.
      Returns:
      The number of materials.
    • subtractMaterials

      public void subtractMaterials(int amount)
      Subtracts a given amount from the available extractor resources.
      Parameters:
      amount - The amount of materials to subtract.