Map - UQdeco2800/2022-studio-3 GitHub Wiki
Accessible through ServiceLocator. For an entity to be registered with MapService it must add a MapComponent. Entities registered with MapService are displayable on the minimap, are treated as obstacles to avoid during path finding and have their positions tracked in the game throughout their entire lifecycle. Available map tiles and MapComponent positions are accessible through MapService methods, which is helpful for movement functionality and interactions of game units.
List getPath(GridPoint2, GridPoint2) -> returns the shortest path from a start tile position to end tile position in a sequential list of tile positions using BFS (see MapSerice Path finding)
boolean isOccupied(GridPoint2) -> returns true if tile is occupied, else false
Entity getEntityAt(GridPoint2) throws NoEntityException -> returns the entity occupying the tile, else throws an exception
MapService implements a Breadth First Search (BFS) algorithm for path finding to be later implemented in other features.
Visual and game play tests:
- Registering functionality: Entities registered with MapService and with a MapComponent set to display will be displayed on the mini map. When all entities set to display, the number of icons on the mini map equals the number of game play entities.
- Disposal functionality: When entities are removed from the map (e.g. through resource collection) their icon disappears from the mini map and the game runs without exception.
- Tracking functionality: Entities with a MapComponent and that are set to display show up on the mini map in a position relative to where they are on the game. As they move, their mini map icon moves relatively.
Added to an entity to an entity to register it with the MapService, and to be rendered to the mini map. By default it does not display on the mini map.
void display() -> sets the entity to be displayed on the mini map.
void setDisplayColour(Color) -> sets the colour the entity appears as on the mini map.
Visual and game play tests:
- Display functionality: Entities with a MapComponent set to display will be rendered to the mini map.
- Icon colouring functionality: Entities with a MapComponent set to display will be rendered to the mini map to the colour that has been manually set for them, else they will render with the default colour red.
- Registering functionality: Entities registered with MapService and with a MapComponent set to display will be displayed on the mini map. When all entities set to display, the number of icons on the mini map equals the number of game play entities. (See MapService Testing)
- Disposal functionality: When entities are removed from the map (e.g. through resource collection) their icon disappears from the mini map and the game runs without exception. (See MapService Testing)
- Update functionality: Entities with a MapComponent and that are set to display show up on the mini map in a position relative to where they are on the game. As they move, their mini map icon moves relatively. (See MapService Testing)
Sequence diagram as it interfaces with the Entity and MinimapComponent classes