Class Map


  • public class Map
    extends java.lang.Object
    This class hold all information about map that is loaded into application
    • Field Detail

      • name

        private java.lang.String name
      • person

        private final Person person
      • moveToCells

        private final java.util.LinkedList<EventMoveToCell> moveToCells
      • block

        private final java.util.LinkedList<Block> block
      • interactionCells

        private final java.util.LinkedList<InteractionCell> interactionCells
      • triggerCells

        private final java.util.LinkedList<TriggerCell> triggerCells
      • doorCells

        private final java.util.LinkedList<DoorCell> doorCells
      • chestCells

        private final java.util.LinkedList<ChestCell> chestCells
      • npcs

        private java.util.LinkedList<Npc> npcs
      • idExit

        private int idExit
      • imageCell

        private final ImageCell imageCell
      • canvasSize

        private int[] canvasSize
      • scanner

        private static java.util.Scanner scanner
      • mapWithSpawn

        private static java.lang.String mapWithSpawn
    • Constructor Detail

    • Method Detail

      • findMapByName

        public static Map findMapByName​(java.lang.String nameOfMap,
                                        WindowOfFreeMove window)
        Finds map by name in a list of loaded maps
        Parameters:
        nameOfMap - is map name that is being searched for
        window - is reference for WindowOfFreeMove
        Returns:
        found map
      • loadMapFromFile

        public static Map loadMapFromFile​(java.lang.String name,
                                          WindowOfFreeMove window)
        Creates map and prepares all fields, then passes map on loadMap
        Parameters:
        name - is map file name
        window - is reference for WindowOfFreeMove
        Returns:
        loaded map
      • loadMap

        public static void loadMap​(Map map,
                                   java.lang.String data,
                                   java.lang.String[] size,
                                   int y,
                                   WindowOfFreeMove window)
        Parses line of text into corresponding cells with attributes and populates corresponding lists wit them
        Parameters:
        map - is map being loaded
        data - is line of map file to be parsed
        size - is array of map's size in cells
        y - is current Y value of line being parsed
        window - is reference for WindowOfFreeMove
      • linkMaps

        public void linkMaps​(Map map,
                             WindowOfFreeMove window)
        Parses MOVETO and DOORTO cells, which link different maps together
        Parameters:
        map - is map being linked
        window - is reference on WindowOfFreeMove
      • addMoveToEvent

        public void addMoveToEvent​(EventMoveToCell moveToCell)
        Updates map's cell matrix and adds cell to corresponding list
        Parameters:
        moveToCell - is MOVETO cell being added
      • addInteractionEvent

        public void addInteractionEvent​(InteractionCell interactionCell)
        Updates map's cell matrix and adds cell to corresponding list
        Parameters:
        interactionCell - is INTER cell being added
      • addInteractionEvent

        public void addInteractionEvent​(TriggerCell triggerCell)
        Updates map's cell matrix and adds cell to corresponding list
        Parameters:
        triggerCell - is TRIGGER cell being added
      • addInteractionEvent

        public void addInteractionEvent​(DoorCell doorCell)
        Updates map's cell matrix and adds cell to corresponding list
        Parameters:
        doorCell - is DOOR(TO) cell being added
      • addInteractionEvent

        public void addInteractionEvent​(ChestCell chestCell)
        Updates map's cell matrix and adds cell to corresponding list
        Parameters:
        chestCell - is CHEST cell being added
      • setNpcs

        public void setNpcs​(Npc npc)
      • getNpcs

        public java.util.LinkedList<Npc> getNpcs()
      • setName

        public void setName​(java.lang.String name)
      • getName

        public java.lang.String getName()
      • getPerson

        public Person getPerson()
      • getIdExit

        public int getIdExit()
      • getMapWithSpawn

        public static java.lang.String getMapWithSpawn()
      • getBlocks

        public java.util.LinkedList<Block> getBlocks()
      • getMoveToCells

        public java.util.LinkedList<EventMoveToCell> getMoveToCells()
      • getInteractionEventCells

        public java.util.LinkedList<InteractionCell> getInteractionEventCells()
      • getTriggerCells

        public java.util.LinkedList<TriggerCell> getTriggerCells()
      • getDoorCells

        public java.util.LinkedList<DoorCell> getDoorCells()
      • getChestCells

        public java.util.LinkedList<ChestCell> getChestCells()
      • setIdExit

        public void setIdExit​(int id)
      • setSpawnPoint

        public void setSpawnPoint​(int x,
                                  int y)
      • getSpawnPoint

        public int[] getSpawnPoint()
      • getImageCell

        public ImageCell getImageCell()
      • getMapArray

        public TypeOfCell[][] getMapArray()
      • getCanvasSize

        public int[] getCanvasSize()
      • setCanvasSize

        public void setCanvasSize​(int[] size)
      • isBusyCell

        public boolean isBusyCell​(int x,
                                  int y)
      • isBusyCell

        public boolean isBusyCell​(int x,
                                  int y,
                                  boolean half)
      • isCellMoveTo

        public boolean isCellMoveTo​(int x,
                                    int y)
      • isInteractionCell

        public boolean isInteractionCell​(int x,
                                         int y)
      • isActiveTriggerCell

        public boolean isActiveTriggerCell​(int x,
                                           int y)
      • isTriggerCell

        public boolean isTriggerCell​(int x,
                                     int y)
      • isDoor

        public boolean isDoor​(int x,
                              int y)
      • isClosedDoor

        public boolean isClosedDoor​(int x,
                                    int y)
      • isActiveChest

        public boolean isActiveChest​(int x,
                                     int y)
      • isChest

        public boolean isChest​(int x,
                               int y)
      • findInteractionByXY

        public InteractionCell findInteractionByXY​(int x,
                                                   int y,
                                                   int directionSight)
      • findInteractionByXY

        public InteractionCell findInteractionByXY​(int x,
                                                   int y)
      • findTriggerByXY

        public TriggerCell findTriggerByXY​(int x,
                                           int y)
      • findDoorByXY

        public DoorCell findDoorByXY​(int x,
                                     int y,
                                     int directionSight)
      • findDoorByXY

        public DoorCell findDoorByXY​(int x,
                                     int y)
      • findBlockByXY

        public Block findBlockByXY​(int x,
                                   int y)
      • findChestByXY

        public ChestCell findChestByXY​(int x,
                                       int y,
                                       int directionSight)
      • findChestByXY

        public ChestCell findChestByXY​(int x,
                                       int y)
      • findMoveToByXY

        public EventMoveToCell findMoveToByXY​(int x,
                                              int y)
      • findNpcByName

        public Npc findNpcByName​(java.lang.String name)
      • findCellByXY

        public Cell findCellByXY​(int x,
                                 int y)
      • directionSightSwitch

        public int[] directionSightSwitch​(int x,
                                          int y,
                                          int directionSight)
        Translates direction of sight into new coords
        Parameters:
        x - is starting X value
        y - is starting Y value
        directionSight - is direction of hero's sight
        Returns:
        array of new X and Y coordinates