Class Player

  • All Implemented Interfaces:
    com.badlogic.gdx.InputProcessor

    public final class Player
    extends com.badlogic.gdx.graphics.g2d.Sprite
    implements com.badlogic.gdx.InputProcessor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static float MIN_TELEPORT_DISTANCE
      How close Auber has to be to a teleporter in order to teleport.
    • Constructor Summary

      Constructors 
      Constructor Description
      Player​(com.badlogic.gdx.graphics.g2d.Sprite newSprite, com.badlogic.gdx.utils.Array<com.badlogic.gdx.maps.tiled.TiledMapTileLayer> newCollisionLayer, boolean isDemo)
      Class constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void arrestUp​(boolean inUse)
      Sets whether the player is using the arrest powerup.
      static boolean canHeal()
      Returns whether the player can currently heal.
      void dispose()
      Called when this object is deleted.
      void draw​(com.badlogic.gdx.graphics.g2d.Batch batch)
      Used to draw the player to the screen.
      void drawArrow​(com.badlogic.gdx.graphics.g2d.Batch batch)
      Draws arrows pointing in the direction of key systems being destroyed.
      void drawCircle​(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)
      Draws the arrest radius for Auber.
      java.lang.String encode()
      Encodes this Player to a string.
      void findInfirmary​(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
      Finds the location of the infirmary on the map.
      void freezeUp​(boolean inUse)
      Sets whether the player is using the freeze powerup.
      static boolean getFreeze()
      Gets whether the player is using the freeze powerup.
      float getHealth()
      Returns this player's health.
      static boolean getHighlight()
      Gets whether the player is using the highlight powerup.
      com.badlogic.gdx.math.Vector2 getPosition()
      Gets the position of this Player.
      boolean getRequestedPause()
      Returns whether the user has requested pause.
      boolean getRequestedSave()
      Returns whether the user has requested save.
      static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> getTeleporterLocations​(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
      Get the location of the teleporters on the map.
      void handledSave()
      Called when the player has been saved.
      void heal()
      Heal Auber for the full amount.
      void heal​(int amount)
      Heal Auber for a certain amount.
      void highlightUp​(boolean inUse)
      Sets whether the player is using the highlight powerup.
      boolean keyDown​(int keycode)
      When a key is pressed, this method is called.
      boolean keyTyped​(char character)  
      boolean keyUp​(int keycode)
      When a key is lifted, this method is called.
      boolean mouseMoved​(int screenX, int screenY)  
      void resetHealStopTime()
      Sets the heal stop time to 0.
      boolean scrolled​(int amount)  
      static void setCanHeal​(boolean newCanHeal)
      Sets whether the player can heal.
      void setHealStopTime​(float value)
      Sets when the player stopped healing.
      void setHealth​(float newHealth)
      Sets this player's health.
      void setRequestedPause​(boolean value)
      Sets whether the user has requested pause.
      void setTeleporters​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> newTeleporters)
      Sets the array of teleporter locations.
      void setUsingArrestPowerUp​(boolean newArrestPowerUp)
      Sets whether the player is using the arrest powerup.
      void setUsingSpeedPowerUp​(boolean newSpeedPowerUp)
      Sets whether the player is using the speed powerup.
      void shieldUp​(boolean inUse)
      Sets whether the player is using the freeze powerup.
      void speedUp​(boolean inUse)
      Sets whether the player is using the speed powerup.
      void takeDamage​(float amount)
      Take damage for amount given.
      void teleport()
      Teleport player to the other teleporter.
      boolean touchDown​(int screenX, int screenY, int pointer, int button)
      Called when a mouse left click is clicked.
      boolean touchDragged​(int screenX, int screenY, int pointer)  
      boolean touchUp​(int screenX, int screenY, int pointer, int button)  
      void update​(float delta)
      Used to update the player, move in direction, change scale, and check for collision.
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite

        draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion

        getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MIN_TELEPORT_DISTANCE

        public static final float MIN_TELEPORT_DISTANCE
        How close Auber has to be to a teleporter in order to teleport.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Player

        public Player​(com.badlogic.gdx.graphics.g2d.Sprite newSprite,
                      com.badlogic.gdx.utils.Array<com.badlogic.gdx.maps.tiled.TiledMapTileLayer> newCollisionLayer,
                      boolean isDemo)
        Class constructor.
        Parameters:
        newSprite - The sprite to use for the player.
        newCollisionLayer - The collision layer the player will exist on.
        isDemo - Whether the game demo is running.
    • Method Detail

      • draw

        public void draw​(com.badlogic.gdx.graphics.g2d.Batch batch)
        Used to draw the player to the screen.
        Overrides:
        draw in class com.badlogic.gdx.graphics.g2d.Sprite
        Parameters:
        batch - Batch for the player to be drawn in
      • drawArrow

        public void drawArrow​(com.badlogic.gdx.graphics.g2d.Batch batch)
        Draws arrows pointing in the direction of key systems being destroyed.
        Parameters:
        batch - Batch for the arrow to be rendered in
      • drawCircle

        public void drawCircle​(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)
        Draws the arrest radius for Auber.
        Parameters:
        shapeRenderer - Shape renderer to be used for drawing shapes.
      • findInfirmary

        public void findInfirmary​(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
        Finds the location of the infirmary on the map.
        Parameters:
        tileLayer - the TileLayer to search for infirmaries.
      • update

        public void update​(float delta)
        Used to update the player, move in direction, change scale, and check for collision.
        Parameters:
        delta - The time since the previous frame, in seconds.
      • keyDown

        public boolean keyDown​(int keycode)
        When a key is pressed, this method is called.
        Specified by:
        keyDown in interface com.badlogic.gdx.InputProcessor
        Parameters:
        keycode - Code of key that was pressed
        Returns:
        true if successful
      • keyUp

        public boolean keyUp​(int keycode)
        When a key is lifted, this method is called.
        Specified by:
        keyUp in interface com.badlogic.gdx.InputProcessor
        Parameters:
        keycode - Code of key that was lifted
        Returns:
        true if successful
      • keyTyped

        public boolean keyTyped​(char character)
        Specified by:
        keyTyped in interface com.badlogic.gdx.InputProcessor
      • touchDown

        public boolean touchDown​(int screenX,
                                 int screenY,
                                 int pointer,
                                 int button)
        Called when a mouse left click is clicked.
        Specified by:
        touchDown in interface com.badlogic.gdx.InputProcessor
        Parameters:
        screenX - X Screen coordinate of mouse press
        screenY - Y Screen coordinate of mouse press
        pointer - The pointer for the event.
        button - The button.
        Returns:
        True if successful
      • touchUp

        public boolean touchUp​(int screenX,
                               int screenY,
                               int pointer,
                               int button)
        Specified by:
        touchUp in interface com.badlogic.gdx.InputProcessor
      • touchDragged

        public boolean touchDragged​(int screenX,
                                    int screenY,
                                    int pointer)
        Specified by:
        touchDragged in interface com.badlogic.gdx.InputProcessor
      • mouseMoved

        public boolean mouseMoved​(int screenX,
                                  int screenY)
        Specified by:
        mouseMoved in interface com.badlogic.gdx.InputProcessor
      • scrolled

        public boolean scrolled​(int amount)
        Specified by:
        scrolled in interface com.badlogic.gdx.InputProcessor
      • heal

        public void heal​(int amount)
        Heal Auber for a certain amount.
        Parameters:
        amount - Amount to heal by.
      • heal

        public void heal()
        Heal Auber for the full amount.
      • takeDamage

        public void takeDamage​(float amount)
        Take damage for amount given.
        Parameters:
        amount - Amount of damage to deal.
      • teleport

        public void teleport()
        Teleport player to the other teleporter. There are only 2 so player is teleported to the furthest one.
      • getTeleporterLocations

        public static com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> getTeleporterLocations​(com.badlogic.gdx.maps.tiled.TiledMapTileLayer tileLayer)
        Get the location of the teleporters on the map.
        Parameters:
        tileLayer - Tile map layer containing the teleporters.
        Returns:
        Array of the positions of teleporters.
      • speedUp

        public void speedUp​(boolean inUse)
        Sets whether the player is using the speed powerup.
        Parameters:
        inUse - Whether the player is using the speed powerup.
      • shieldUp

        public void shieldUp​(boolean inUse)
        Sets whether the player is using the freeze powerup.
        Parameters:
        inUse - Whether the player is using the freeze powerup.
      • freezeUp

        public void freezeUp​(boolean inUse)
        Sets whether the player is using the freeze powerup.
        Parameters:
        inUse - Whether the player is using the freeze powerup.
      • highlightUp

        public void highlightUp​(boolean inUse)
        Sets whether the player is using the highlight powerup.
        Parameters:
        inUse - Whether the player is using the highlight powerup.
      • getFreeze

        public static boolean getFreeze()
        Gets whether the player is using the freeze powerup.
        Returns:
        True if the player is using the freeze powerup, false otherwise.
      • getHighlight

        public static boolean getHighlight()
        Gets whether the player is using the highlight powerup.
        Returns:
        True if the player is using the highlight powerup, false otherwise.
      • getHealth

        public float getHealth()
        Returns this player's health.
        Returns:
        A float containing this player's health.
      • setHealth

        public void setHealth​(float newHealth)
        Sets this player's health.
        Parameters:
        newHealth - The new value of the player's health.
      • setHealStopTime

        public void setHealStopTime​(float value)
        Sets when the player stopped healing.
        Parameters:
        value - When the player stopped healing.
      • setUsingArrestPowerUp

        public void setUsingArrestPowerUp​(boolean newArrestPowerUp)
        Sets whether the player is using the arrest powerup.
        Parameters:
        newArrestPowerUp - Whether the player is using the arrest powerup.
      • setUsingSpeedPowerUp

        public void setUsingSpeedPowerUp​(boolean newSpeedPowerUp)
        Sets whether the player is using the speed powerup.
        Parameters:
        newSpeedPowerUp - Whether the player is using the speed powerup.
      • arrestUp

        public void arrestUp​(boolean inUse)
        Sets whether the player is using the arrest powerup.
        Parameters:
        inUse - Whether the player is using the arrest powerup.
      • dispose

        public void dispose()
        Called when this object is deleted.
      • getPosition

        public com.badlogic.gdx.math.Vector2 getPosition()
        Gets the position of this Player.
        Returns:
        A Vector2 containing the position of this player.
      • setCanHeal

        public static void setCanHeal​(boolean newCanHeal)
        Sets whether the player can heal.
        Parameters:
        newCanHeal - The new value of canHeal.
      • resetHealStopTime

        public void resetHealStopTime()
        Sets the heal stop time to 0.
      • canHeal

        public static boolean canHeal()
        Returns whether the player can currently heal.
        Returns:
        A boolean containing whether the player can currently heal.
      • setTeleporters

        public void setTeleporters​(com.badlogic.gdx.utils.Array<com.badlogic.gdx.math.Vector2> newTeleporters)
        Sets the array of teleporter locations.
        Parameters:
        newTeleporters - The array of teleporter locations.
      • getRequestedPause

        public boolean getRequestedPause()
        Returns whether the user has requested pause.
        Returns:
        Whether the user has requested pause.
      • getRequestedSave

        public boolean getRequestedSave()
        Returns whether the user has requested save.
        Returns:
        Whether the user has requested save.
      • setRequestedPause

        public void setRequestedPause​(boolean value)
        Sets whether the user has requested pause.
        Parameters:
        value - Whether the user has requested pause.
      • handledSave

        public void handledSave()
        Called when the player has been saved.
      • encode

        public java.lang.String encode()
        Encodes this Player to a string.
        Returns:
        This Player encoded as a string.