Class MapLevel
java.lang.Object
fr.r1r0r0.deltaengine.model.maplevel.MapLevel
public final class MapLevel
extends java.lang.Object
MapLevel that represent the area where entities move
It is compose of cells, entities and events
- See Also:
MapLevelBuilder
-
Field Summary
Fields Modifier and Type Field Description private BufferedHashMap<Coordinates<java.lang.Integer>,Cell>
cells
private BufferedHashMap<java.lang.String,Entity>
entities
private java.util.Collection<Event>
events
private int
height
private java.lang.String
name
private int
width
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
addEntity(Entity entity)
Add an entity in the mapvoid
addEvent(Event event)
add an eventvoid
clearEntities()
Remove all the entities present in mapvoid
clearEvents()
Remove all events in mapBufferedHashMap<Coordinates<java.lang.Integer>,Cell>
getBufferedCells()
Getter of attribute cellsBufferedHashMap<java.lang.String,Entity>
getBufferedEntities()
Getter of attribute entitiesCell
getCell(int x, int y)
Return the cell in the map with coordinate (x,y)java.util.Collection<Cell>
getCells()
Return all the cells in mapjava.util.Collection<Entity>
getEntities()
Return all the entities in mapEntity
getEntity(java.lang.String name)
Return the entity in map with the same givenjava.util.Collection<Event>
getEvents()
Return all the events in mapint
getHeight()
Return the heightjava.lang.String
getName()
Return the nameint
getWidth()
Return the widthprivate boolean
isValidCoordinate(Coordinates<java.lang.Integer> coordinates)
Return if the coordinates given are include in the area of the mapvoid
removeEntity(Entity entity)
Remove an entity in map with the same givenvoid
removeEvent(Event event)
Remove an eventvoid
replaceCell(Cell cell)
Add a case in the mapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
name
private final java.lang.String name -
width
private final int width -
height
private final int height -
cells
-
entities
-
events
-
-
Constructor Details
-
MapLevel
MapLevel(java.lang.String name, Cell[][] cells)Constructor- Parameters:
name
- name of the mapcells
- cells that compose the map, can not contain null
-
-
Method Details
-
getName
public java.lang.String getName()Return the name- Returns:
- the name
-
getWidth
public int getWidth()Return the width- Returns:
- the width
-
getHeight
public int getHeight()Return the height- Returns:
- the height
-
replaceCell
Add a case in the map- Parameters:
cell
- a cell- Throws:
MapLevelCoordinatesOutOfBoundException
- throw if a cell with coordinate out of the area define by the map is added
-
isValidCoordinate
Return if the coordinates given are include in the area of the map- Parameters:
coordinates
- a coordinate- Returns:
- if the coordinates are valid (include in the area of the map)
-
getCell
Return the cell in the map with coordinate (x,y)- Parameters:
x
- the x valuey
- the y value- Returns:
- the cell in the map with coordinate (x,y), returns OutOfBoundsCell if wanted cell is out of bounds
-
addEntity
Add an entity in the map- Parameters:
entity
- an entity- Throws:
MapLevelEntityNameStackingException
- throw if the name of the entity is already present in the map
-
getEntity
Return the entity in map with the same given- Parameters:
name
- a name- Returns:
- an entity in map with the same given, or null if there is no entity with this name
-
removeEntity
Remove an entity in map with the same given- Parameters:
entity
- an entity
-
clearEntities
public void clearEntities()Remove all the entities present in map -
addEvent
add an event- Parameters:
event
-
-
removeEvent
Remove an event- Parameters:
event
- an event
-
clearEvents
public void clearEvents()Remove all events in map -
getCells
Return all the cells in map- Returns:
- a collection of case
-
getEntities
Return all the entities in map- Returns:
- a collection of entity
-
getEvents
Return all the events in map- Returns:
- a map of event
-
getBufferedCells
Getter of attribute cells- Returns:
- attribute cells
-
getBufferedEntities
Getter of attribute entities- Returns:
- attributes entities
-