Package ruscz.game.gameOfProd.Map
Class Map
- java.lang.Object
-
- ruscz.game.gameOfProd.Map.Map
-
public class Map extends java.lang.ObjectThis class hold all information about map that is loaded into application
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.LinkedList<Block>blockprivate int[]canvasSizeprivate java.util.LinkedList<DoorCell>doorCellsprivate java.util.LinkedList<ChestCell>chestCellsprivate intidExitprivate ImageCellimageCellprivate java.util.LinkedList<InteractionCell>interactionCellsprivate TypeOfCell[][]mapArrayprivate static java.lang.StringmapWithSpawnprivate java.util.LinkedList<EventMoveToCell>moveToCellsprivate java.lang.Stringnameprivate java.util.LinkedList<Npc>npcsprivate Personpersonprivate static java.util.Scannerscannerprivate SoundManagersoundManagerprivate java.util.LinkedList<TriggerCell>triggerCells
-
Constructor Summary
Constructors Constructor Description Map(TypeOfCell[][] mapArray)
-
Method Summary
Modifier and Type Method Description voidaddInteractionEvent(DoorCell doorCell)Updates map's cell matrix and adds cell to corresponding listvoidaddInteractionEvent(ChestCell chestCell)Updates map's cell matrix and adds cell to corresponding listvoidaddInteractionEvent(InteractionCell interactionCell)Updates map's cell matrix and adds cell to corresponding listvoidaddInteractionEvent(TriggerCell triggerCell)Updates map's cell matrix and adds cell to corresponding listvoidaddMoveToEvent(EventMoveToCell moveToCell)Updates map's cell matrix and adds cell to corresponding listint[]directionSightSwitch(int x, int y, int directionSight)Translates direction of sight into new coordsBlockfindBlockByXY(int x, int y)CellfindCellByXY(int x, int y)DoorCellfindDoorByXY(int x, int y)DoorCellfindDoorByXY(int x, int y, int directionSight)EventMoveToCellfindEventByXY(int x, int y)ChestCellfindChestByXY(int x, int y)ChestCellfindChestByXY(int x, int y, int directionSight)InteractionCellfindInteractionByXY(int x, int y)InteractionCellfindInteractionByXY(int x, int y, int directionSight)static MapfindMapByName(java.lang.String nameOfMap, WindowOfFreeMove window)Finds map by name in a list of loaded mapsEventMoveToCellfindMoveToByXY(int x, int y)NpcfindNpcByName(java.lang.String name)TriggerCellfindTriggerByXY(int x, int y)java.util.LinkedList<Block>getBlocks()int[]getCanvasSize()java.util.LinkedList<DoorCell>getDoorCells()java.util.LinkedList<ChestCell>getChestCells()intgetIdExit()ImageCellgetImageCell()java.util.LinkedList<InteractionCell>getInteractionEventCells()TypeOfCell[][]getMapArray()static java.lang.StringgetMapWithSpawn()java.util.LinkedList<EventMoveToCell>getMoveToCells()java.lang.StringgetName()java.util.LinkedList<Npc>getNpcs()PersongetPerson()SoundManagergetSoundManager()int[]getSpawnPoint()java.util.LinkedList<TriggerCell>getTriggerCells()booleanisActiveChest(int x, int y)booleanisActiveTriggerCell(int x, int y)booleanisBusyCell(int x, int y)booleanisBusyCell(int x, int y, boolean half)booleanisCellMoveTo(int x, int y)booleanisClosedDoor(int x, int y)booleanisDoor(int x, int y)booleanisChest(int x, int y)booleanisInteractionCell(int x, int y)booleanisTriggerCell(int x, int y)voidlinkMaps(Map map, WindowOfFreeMove window)Parses MOVETO and DOORTO cells, which link different maps togetherstatic voidloadMap(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 themstatic MaploadMapFromFile(java.lang.String name, WindowOfFreeMove window)Creates map and prepares all fields, then passes map on loadMapvoidsetCanvasSize(int[] size)voidsetIdExit(int id)voidsetName(java.lang.String name)voidsetNpcs(Npc npc)voidsetSpawnPoint(int x, int y)
-
-
-
Field Detail
-
name
private java.lang.String name
-
mapArray
private final TypeOfCell[][] mapArray
-
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
-
soundManager
private final SoundManager soundManager
-
scanner
private static java.util.Scanner scanner
-
mapWithSpawn
private static java.lang.String mapWithSpawn
-
-
Constructor Detail
-
Map
public Map(TypeOfCell[][] mapArray)
-
-
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 forwindow- 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 namewindow- 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 loadeddata- is line of map file to be parsedsize- is array of map's size in cellsy- is current Y value of line being parsedwindow- 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 linkedwindow- 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()
-
getSoundManager
public SoundManager getSoundManager()
-
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)
-
findEventByXY
public EventMoveToCell findEventByXY(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 valuey- is starting Y valuedirectionSight- is direction of hero's sight- Returns:
- array of new X and Y coordinates
-
-