Class MapScreen

java.lang.Object
com.badlogic.gdx.InputAdapter
com.badlogic.gdx.scenes.scene2d.Stage
group24.escaperoom.screens.AbstractScreen
group24.escaperoom.screens.MapScreen
All Implemented Interfaces:
com.badlogic.gdx.InputProcessor, com.badlogic.gdx.Screen, com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
GameScreen, LevelEditorScreen

public abstract class MapScreen extends AbstractScreen
  • Field Details

    • roomProxy

      protected com.badlogic.gdx.scenes.scene2d.Actor roomProxy
    • room

      protected com.badlogic.gdx.scenes.scene2d.ui.Image room
    • grid

      public Grid grid
    • batch

      protected final com.badlogic.gdx.graphics.g2d.Batch batch
    • metadata

      protected MapMetadata metadata
    • gridSize

      protected Types.Size gridSize
    • pollItems

      protected com.badlogic.gdx.utils.Array<Item> pollItems
    • cameraManager

      protected CamMan cameraManager
  • Constructor Details

    • MapScreen

      public MapScreen(MapData mapdata)
  • Method Details

    • getMetadata

      public MapMetadata getMetadata()
    • removeItemFromGrid

      public void removeItemFromGrid(Item item, boolean temporary)
      Remove an item from the grid
      Parameters:
      temporary - whether or not this is likely a temporary removal
    • updateProxy

      protected void updateProxy()
      Update the room proxy on the ui stage to align with the game stage room
    • containsItemWhere

      public boolean containsItemWhere(Predicate<Item> predicate)
      Returns:
      whether or not the an item fufilling predicate exists on the map
    • findItemWhere

      public Optional<Item> findItemWhere(Predicate<Item> predicate)
      Returns:
      an Optional containing the first item fulfilling the given predicate
    • getItemsAt

      public Optional<Item[]> getItemsAt(Types.IntVector2 pos)
      Returns:
      an Optional with all items in this square. - the inner array can be empty - Optional just protects out of bounds access
    • getItemsAt

      public Optional<Item[]> getItemsAt(int x, int y)
      Returns:
      an Optional with all items in this square. - the inner array can be empty - Optional just protects out of bounds access
    • getItemsAt

      public Optional<Item[]> getItemsAt(float x, float y)
      See Also:
    • getItemsIn

      public HashSet<Item> getItemsIn(com.badlogic.gdx.math.Rectangle region)
      Get a list of all items present in a certain region - This returns items also partially contained in the region
    • canPlace

      public static boolean canPlace(Item item, Types.IntVector2 newPos, Grid grid)
      Returns:
      whether or not item can be placed at newPos
    • canPlace

      public boolean canPlace(Item item, Types.IntVector2 newPos)
      Returns:
      whether or not item can be placed at newPos
    • loadGrid

      public void loadGrid(Grid grid)
    • maybeAddPolling

      public void maybeAddPolling(Item item)
      Registers an Item for polling if it needs it. If called with an Item that doesn't need polling, this function does nothing.
    • getItems

      public Collection<Item> getItems()
      Returns:
      all items associated with this map - not all these items are necessarily placed
    • placeItem

      public boolean placeItem(Item item)
      Place an item on the grid
    • getGrid

      public Grid getGrid()
    • getDrawables

      public TreeSet<Drawable> getDrawables()
    • draw

      public void draw(boolean endBatch)
    • draw

      public void draw()
      Overrides:
      draw in class com.badlogic.gdx.scenes.scene2d.Stage
    • itemIsPlaced

      public boolean itemIsPlaced(Item i)
    • act

      public void act(float delta)
      Overrides:
      act in class AbstractScreen
    • resize

      public void resize(int w, int h)
      Specified by:
      resize in interface com.badlogic.gdx.Screen
      Overrides:
      resize in class AbstractScreen
    • getTileDepthOf

      public int getTileDepthOf(Item item)