Package com.csse3200.game.areas.MiniMap
Class MiniMapDisplay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.areas.MiniMap.MiniMapDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
The MiniMapDisplay class is a UI component responsible for displaying a minimap
on the screen. It shows the player's position, as well as various entities like
enemies, bosses, friendly NPCs, and minigame NPCs, represented by different colored
dots. The minimap updates positions based on the entities' world coordinates.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for MiniMapDisplay.MiniMapDisplay
(GameArea gameArea) Constructor that initializes the MiniMapDisplay with a specified GameArea. -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Creates the minimap, initializing the player and entity lists from the GameArea.protected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the minimap background on the screen.float
Gets the diameter of the minimap.float
Gets the X position of the minimap on the screen.float
Gets the Y position of the minimap on the screen.Retrieves the player entity displayed on the minimap.void
Initializes all dot images for player, enemies, bosses, friendly NPCs, and minigame NPCs.void
Initializes blue dot images for friendly NPCs on the minimap.void
Initializes the green dot image representing the player on the minimap.void
Initializes large red dot images for bosses on the minimap.void
Initializes purple dot images for minigame NPCs on the minimap.void
Initializes red dot images for each enemy on the minimap.void
setMiniMapDiameter
(int size) Sets the diameter of the minimap.void
setMiniMapPosition
(float posX, float posY) Sets the position of the minimap on the screen.com.badlogic.gdx.math.Vector2
transferToMiniMapPos
(Entity entity) Transfers the world position of an entity to the corresponding minimap position.void
update()
Updates the minimap, adjusting the player and entity positions each frame.void
Updates all dot points on the minimap, including enemies, friendly NPCs, bosses, and minigame NPCs.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex, setStage
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, dispose, render
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.csse3200.game.rendering.Renderable
render
-
Constructor Details
-
MiniMapDisplay
public MiniMapDisplay()Default constructor for MiniMapDisplay. Initializes all entity lists. -
MiniMapDisplay
Constructor that initializes the MiniMapDisplay with a specified GameArea.- Parameters:
gameArea
- the game area from which to retrieve player and entities.
-
-
Method Details
-
create
public void create()Creates the minimap, initializing the player and entity lists from the GameArea.- Overrides:
create
in classUIComponent
-
initializeAllImages
public void initializeAllImages()Initializes all dot images for player, enemies, bosses, friendly NPCs, and minigame NPCs. -
initializeGreenDotImages
public void initializeGreenDotImages()Initializes the green dot image representing the player on the minimap. -
initializeRedDotImages
public void initializeRedDotImages()Initializes red dot images for each enemy on the minimap. -
initializeBlueDotImages
public void initializeBlueDotImages()Initializes blue dot images for friendly NPCs on the minimap. -
initializeLargeRedPointImages
public void initializeLargeRedPointImages()Initializes large red dot images for bosses on the minimap. -
initializePurplePointImages
public void initializePurplePointImages()Initializes purple dot images for minigame NPCs on the minimap. -
transferToMiniMapPos
Transfers the world position of an entity to the corresponding minimap position.- Parameters:
entity
- the entity to transfer.- Returns:
- the position of the entity on the minimap.
-
updateAllPoints
public void updateAllPoints()Updates all dot points on the minimap, including enemies, friendly NPCs, bosses, and minigame NPCs. -
update
public void update()Updates the minimap, adjusting the player and entity positions each frame. -
draw
protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws the minimap background on the screen.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- the sprite batch used for drawing the minimap.
-
getPlayer
Retrieves the player entity displayed on the minimap.- Returns:
- the player entity.
-
getMiniMapX
public float getMiniMapX()Gets the X position of the minimap on the screen.- Returns:
- the X coordinate of the minimap.
-
getMiniMapY
public float getMiniMapY()Gets the Y position of the minimap on the screen.- Returns:
- the Y coordinate of the minimap.
-
getMiniMapDiameter
public float getMiniMapDiameter()Gets the diameter of the minimap.- Returns:
- the diameter of the minimap.
-
setMiniMapPosition
public void setMiniMapPosition(float posX, float posY) Sets the position of the minimap on the screen.- Parameters:
posX
- the new X coordinate for the minimap.posY
- the new Y coordinate for the minimap.
-
setMiniMapDiameter
public void setMiniMapDiameter(int size) Sets the diameter of the minimap.- Parameters:
size
- the new diameter for the minimap.
-