Package breitband.GUI.ui
Class World
- java.lang.Object
-
- breitband.GUI.ui.World
-
- All Implemented Interfaces:
java.awt.event.KeyListener
,java.util.EventListener
public class World extends java.lang.Object implements java.awt.event.KeyListener
The world map, containing all regions, cities and cables.- Author:
- Juno Veenstra
-
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_MAP_SIZE
static float
REGION_FONT_SIZE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCityHighlights()
Clear all city highlightingvoid
clearRegionHighlights()
Clear all region highlightingvoid
highlightCities(java.lang.String cityA)
Highlights one cityvoid
highlightCities(java.lang.String cityA, java.lang.String cityB)
Highlights two citiesvoid
highlightCitiesWeak(java.util.Vector<City> cities, boolean clearFirst)
Highlights an array of cities dimly, used for showing cities in rangevoid
highlightRegion(java.lang.String regionName)
Highlight the given region.void
keyPressed(java.awt.event.KeyEvent e)
Register key presses for navigationvoid
keyReleased(java.awt.event.KeyEvent e)
void
keyTyped(java.awt.event.KeyEvent e)
void
moveScreen(float x, float y)
Move every city and polygon by a specific amountWorld
onCityClick(java.util.function.Consumer<GCity> action)
This event is triggered when a city is clickedvoid
placeCable(City a, City b, CableConfig c, java.awt.Color color, java.lang.String name, int amount)
Create a cable to be placed in the mapvoid
removeRangeCircles()
Method for removing/resetting the range circles by deleting each circlevoid
resetScreenTransform()
Method for setting the screen scaling and position to the default state where the entire map is visible and centeredvoid
scaleScreen(float scale)
Scale all layers by a certain factorvoid
showRangeCircles(float x, float y, int cableCount, float cableRange, float maxRange)
Method for creating circles around a city depicting the range at which you can build
-
-
-
Field Detail
-
DEFAULT_MAP_SIZE
public static final float DEFAULT_MAP_SIZE
- See Also:
- Constant Field Values
-
REGION_FONT_SIZE
public static final float REGION_FONT_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
World
public World(sag.SAGPanel panel, Region[] regions)
Create, move and scale regions and city to be centered on the map- Parameters:
panel
- SAGPanel to be drawregions
- Array of regions
-
-
Method Detail
-
moveScreen
public void moveScreen(float x, float y)
Move every city and polygon by a specific amount- Parameters:
x
- X movementy
- Y movement
-
scaleScreen
public void scaleScreen(float scale)
Scale all layers by a certain factor- Parameters:
scale
- The scaling to be applied
-
resetScreenTransform
public void resetScreenTransform()
Method for setting the screen scaling and position to the default state where the entire map is visible and centered
-
placeCable
public void placeCable(City a, City b, CableConfig c, java.awt.Color color, java.lang.String name, int amount)
Create a cable to be placed in the map- Parameters:
a
- Start Cityb
- End Cityc
- Cable typecolor
- Player colorname
- Player nameamount
- Amount of cables used (reflected in the amount of icons used in the cable)
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Register key presses for navigation- Specified by:
keyPressed
in interfacejava.awt.event.KeyListener
- Parameters:
e
- the event to be processed
-
showRangeCircles
public void showRangeCircles(float x, float y, int cableCount, float cableRange, float maxRange)
Method for creating circles around a city depicting the range at which you can build- Parameters:
x
- The x position around which the circles get drawny
- The y position around which the circles get drawncableCount
- The amount of cables of this type in the players inventory, more cables mean more rangecableRange
- The range a single cable can gomaxRange
- The maximum range cables can go combined
-
removeRangeCircles
public void removeRangeCircles()
Method for removing/resetting the range circles by deleting each circle
-
highlightRegion
public void highlightRegion(java.lang.String regionName)
Highlight the given region. (Dims every other region)- Parameters:
regionName
- Region to be highlighted
-
highlightCities
public void highlightCities(java.lang.String cityA)
Highlights one city- Parameters:
cityA
- First city to be highlighted
-
highlightCities
public void highlightCities(java.lang.String cityA, java.lang.String cityB)
Highlights two cities- Parameters:
cityA
- First city to be highlightedcityB
- Second city to be highlighted
-
highlightCitiesWeak
public void highlightCitiesWeak(java.util.Vector<City> cities, boolean clearFirst)
Highlights an array of cities dimly, used for showing cities in range- Parameters:
cities
- Cities to be highlightedclearFirst
- Whether to clear previous highlights first, which can cause issues whenhighlightCities(String)
is called first
-
clearRegionHighlights
public void clearRegionHighlights()
Clear all region highlighting
-
clearCityHighlights
public void clearCityHighlights()
Clear all city highlighting
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTyped
in interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleased
in interfacejava.awt.event.KeyListener
-
-