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>cellsprivate BufferedHashMap<java.lang.String,Entity>entitiesprivate java.util.Collection<Event>eventsprivate intheightprivate java.lang.Stringnameprivate intwidth -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddEntity(Entity entity)Add an entity in the mapvoidaddEvent(Event event)add an eventvoidclearEntities()Remove all the entities present in mapvoidclearEvents()Remove all events in mapBufferedHashMap<Coordinates<java.lang.Integer>,Cell>getBufferedCells()Getter of attribute cellsBufferedHashMap<java.lang.String,Entity>getBufferedEntities()Getter of attribute entitiesCellgetCell(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 mapEntitygetEntity(java.lang.String name)Return the entity in map with the same givenjava.util.Collection<Event>getEvents()Return all the events in mapintgetHeight()Return the heightjava.lang.StringgetName()Return the nameintgetWidth()Return the widthprivate booleanisValidCoordinate(Coordinates<java.lang.Integer> coordinates)Return if the coordinates given are include in the area of the mapvoidremoveEntity(Entity entity)Remove an entity in map with the same givenvoidremoveEvent(Event event)Remove an eventvoidreplaceCell(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
-