Class Player

java.lang.Object
de.tum.cit.fop.maze.objects.GameObject
de.tum.cit.fop.maze.objects.Player
All Implemented Interfaces:
Saveable<PlayerMemento>

public class Player extends GameObject implements Saveable<PlayerMemento>
Main player character with health, abilities, inventory, and effects management.
  • Constructor Details

  • Method Details

    • receiveXP

      public int receiveXP(int xpReceived)
      Adds experience points to the player.
      Parameters:
      xpReceived - Amount of XP to add
      Returns:
      New total XP
    • getDamageOrHeal

      public int getDamageOrHeal(int damage)
      Applies damage or healing to the player.
      Parameters:
      damage - Positive for damage, negative for healing
      Returns:
      New health value
    • increaseMaxHealth

      public int increaseMaxHealth(int extraHealth)
      Increases player's maximum and current health.
      Parameters:
      extraHealth - Amount of health to add
      Returns:
      New maximum health
    • animate

      public void animate(com.badlogic.gdx.graphics.g2d.Batch batch)
      Description copied from class: GameObject
      Renders the object using its drawable or texture.
      Overrides:
      animate in class GameObject
      Parameters:
      batch - Sprite batch for rendering
    • endEffect

      public void endEffect(Class<? extends Effect> effectTypeClass)
      Ends a specific effect type on the player.
      Parameters:
      effectTypeClass - The effect class to remove
    • addOrReapplyEffect

      public void addOrReapplyEffect(Effect effect)
      Adds or refreshes an effect on the player.
      Parameters:
      effect - The effect to apply
    • tickEffects

      public void tickEffects(float deltaTime)
      Updates all active effects on the player.
      Parameters:
      deltaTime - Time since last tick
    • changeAnimation

      public void changeAnimation(AnimationType animationType)
      Description copied from class: GameObject
      Changes the current animation.
      Overrides:
      changeAnimation in class GameObject
      Parameters:
      animationType - New animation type
    • getCurrentHealth

      public int getCurrentHealth()
      Gets current health value.
      Returns:
      Current health
    • setCurrentHealth

      public void setCurrentHealth(int currentHealth)
      Sets current health value.
      Parameters:
      currentHealth - New health value
    • getMaxHealth

      public int getMaxHealth()
      Gets maximum health value.
      Returns:
      Maximum health
    • setMaxHealth

      public void setMaxHealth(int maxHealth)
      Sets maximum health value.
      Parameters:
      maxHealth - New maximum health
    • getEffectDuration

      public float getEffectDuration(Class<? extends Effect> effectType)
      Gets remaining duration of an active effect.
      Parameters:
      effectType - The effect class to check
      Returns:
      Time remaining, or 0 if not active
    • hasEffect

      public boolean hasEffect(Class<? extends Effect> effectType)
      Checks if player has a specific effect active.
      Parameters:
      effectType - The effect class to check
      Returns:
      True if effect is active
    • getPlayerGameObject

      public GameObject getPlayerGameObject()
      Gets the player as a GameObject.
      Returns:
      This player instance
    • collectKey

      public void collectKey()
      Collects a key and updates inventory.
    • isAttacking

      public boolean isAttacking()
      Checks if player is currently attacking.
      Returns:
      True if attacking
    • setAttacking

      public void setAttacking(boolean attacking)
      Sets attacking state.
      Parameters:
      attacking - New attacking state
    • die

      public void die()
      Handles player death sound.
    • hasKeys

      public boolean hasKeys()
      Checks if player has all required keys.
      Returns:
      True if has all keys
    • getXp

      public int getXp()
      Gets player XP.
      Returns:
      Current XP
    • setXp

      public void setXp(int xp)
      Sets player XP.
      Parameters:
      xp - New XP value
    • isCanDash

      public boolean isCanDash()
      Checks if player can use dash ability.
      Returns:
      True if dash is unlocked
    • setCanDash

      public void setCanDash(boolean canDash)
      Sets dash ability availability.
      Parameters:
      canDash - New dash availability
    • isCanInvis

      public boolean isCanInvis()
      Checks if player can use invisibility ability.
      Returns:
      True if invis is unlocked
    • setCanInvis

      public void setCanInvis(boolean canInvis)
      Sets invisibility ability availability.
      Parameters:
      canInvis - New invis availability
    • getSoundController

      public SoundController getSoundController()
      Gets the sound controller.
      Returns:
      Sound controller instance
    • setHasKeys

      public void setHasKeys(boolean hasKey)
      Sets whether player has all keys.
      Parameters:
      hasKey - New key status
    • getCurrentKeys

      public int getCurrentKeys()
      Gets current number of keys collected.
      Returns:
      Number of keys
    • setCurrentKeys

      public void setCurrentKeys(int keys)
      Sets current number of keys.
      Parameters:
      keys - New key count
    • getRequiredKeys

      public int getRequiredKeys()
      Gets number of keys required.
      Returns:
      Required key count
    • setRequiredKeys

      public void setRequiredKeys(int requiredKeys)
      Sets number of keys required.
      Parameters:
      requiredKeys - New required count
    • setPosition

      public void setPosition(com.badlogic.gdx.math.Vector2 pos)
      Sets player position.
      Parameters:
      pos - New position vector
    • getAchievementUI

      public AchievementUI getAchievementUI()
      Gets achievement UI.
      Returns:
      Achievement UI instance
    • getKills

      public int getKills()
      Gets number of kills.
      Returns:
      Kill count
    • setKills

      public void setKills(int kills)
      Sets number of kills.
      Parameters:
      kills - New kill count
    • updateRequiredKeys

      public void updateRequiredKeys()
      Updates required keys from current game field.
    • getMemento

      public PlayerMemento getMemento()
      Description copied from interface: Saveable
      Creates a memento capturing the current state of this object.
      Specified by:
      getMemento in interface Saveable<PlayerMemento>
      Returns:
      A memento containing the object's state
    • loadFromMemento

      public void loadFromMemento(PlayerMemento memento)
      Description copied from interface: Saveable
      Restores the object's state from a memento.
      Specified by:
      loadFromMemento in interface Saveable<PlayerMemento>
      Parameters:
      memento - The memento containing the state to restore