skip to Main Content

Public Methods & Properties

You can instantiate the prefab “WorldMapStrategyKit“ or add it to the scene from the Editor. Once the prefab is in the scene, you can access the functionality from code through the static instance property:

(Note that you can have more WMSK instances in the same scene. In this case, the instance property will returns the same object. To use the API on a specific instance, you can get the WMSK component of the GameObject).

All public API and properties are located in WMSK_* scripts inside Scripts folder.

Map Entitites

Most of API methods and properties are related to one of the core map entities. These are core classes that store important information about the map or its contents.

Country class

The country class describes one country and its land regions. You can get an array of countries using map.countries property and/or using any method like GetCountryIndex…. Each country object in this array has the following properties and methods:

  • country.name: the name of the country. This is used as a key internally so don’t change it. If you want to display a different label, use customLabel property.

  • country.hidden: if the country and its frontiers is visible in the map.

  • country.regions: list of land regions of the country. A country is no more than the administrative info. The physical definition of its regions are inside this property.

  • country.mainRegionindex: the index of the biggest region in the regions list.

  • country.regionsRect2D: rect2D that encloses all country regions in the map. Used internally for country mouse detection.

  • country.center: the center of the biggest region of the country in local space coordinates (see also “centroid”).

  • country.centerRect: the geometric center of the rectangle enclosing all country regions in local space coordinates.

  • country.centroid: same than “center” but ensures it falls inside the polygon.

  • country.continent: name of the continent to which the country belongs.

  • country.capitalCityIndex: index of the capital city or -1 if none exists.

  • country.fips10_4, iso_a2, iso_a3, iso_n3: standardized codes of the country.

  • country.provinces: list of provinces of the country.

  • country.customLabel: alternate label for the country. By default, the map will display the name but you can assign a different caption to this property.

  • country.labelColorOverride: set this to true to use a custom color for this country label.

  • country.labelColor: the custom color for this country label.

  • country.labelFontOverride: specifies a different font for this country label.

  • country.labelVisible: toggles visibility of this country label.

  • country.labelRotation: custom rotation for this country label.

  • country.labelOffset: custom offset for this country label.

  • country.labelFontSizeOverride: set this to true to use a custom font size.

  • country.labelFontSize: the custom font size for this country label.

  • country.uniqueId: unique identifier of the country. Can be used as a key to relate this country with your custom classes.

  • country.attrib: user defined attributes. This is a jSON object.

  • country.canCross: determines if path finding methods can cross this country (only used with FindRoute when passing country objects).

  • country.crossCost: used by path finding methods as an extra cost to pass this country (only used with FindRoute when passing country objects).

  • country.allowHighlight: if this country can be highlighted.

  • country.showProvinces: if provinces for this country will be drawn. Defaults to true.

  • country.allowProvincesHighlight: if provinces for this country can be highlighted. Defaults to true.

Province class

The province class describes one province and its land regions. You can get an array of provinces using map.provinces property and/or using any method like GetProvinceIndex…. Each province object has the following properties and methods:

  • province.name: the name of the province. This is used as a key internally so don’t change it.

  • province.regions: list of land regions of the province. A province is no more than the administrative info. The physical definition of its regions are inside this property.

  • province.mainRegionindex: the index of the biggest region in the regions list.

  • province.regionsRect2D: rect2D that encloses all province regions in the map. Used internally for province mouse detection.

  • province.center: the center of the biggest region of the province in local space coordinates (see also centroid).

  • province.centerRect: the geometric center of the rectangle enclosing all province regions in local space coordinates.

  • province.centroid: same than “center” but ensures it falls inside the polygon.
  • province.countryIndex: the index of the country to which the province belongs.

  • province.uniqueId: unique identifier of the province. Can be used as a key to relate this province with your custom classes.

  • province.attrib: user defined attributes. This is a jSON object.

  • province.canCross: determines if path finding methods can cross this province (only used with FindRoute when passing country objects).

  • province.crossCost: used by path finding methods as an extra cost to pass this province (only used with FindRoute when passing province objects).

  • province.allowHighlight: if this province can be highlighted.

City class

The city class describes one city. You can get an array of cities using map.cities property and/or using any method like GetCityIndex…. Each city object has the following properties and methods:

  • city.name: the name of the city.

  • city.province: name of the province where the city is located (optional).

  • city.countryIndex: the index of the country to which the city belongs.

  • city.unity2DLocation: location of the city in the map in local space coordinates (-0.5 .. 0.5).

  • city.population: metropolitan population in thousands.

  • city.cityClass: class of city (normal, region capital or country capital).

  • city.isVisible: if the city is currently visible (drawn) in the map.

  • city.uniqueId: unique identifier of the city. Can be used as a key to relate this city with your custom classes.

  • city.attrib: root for custom attributes.

Mount Point class

The mount point class describes one user-defined location in the map. Note that mount points are not visible at such in the map – it’s up to you to add any custom sprite or game object to their locations if you wish. You can get an array of mount points using map.mountPoints property and/or using any method like GetMountPointIndex…. Each mount point object has the following properties and methods:

  • mountpoint.name: the name of the mountpoint. User-defined.

  • mountpoint.type: type of mount point. User-defined.

  • mountpoint.countryIndex: the index of the country to which the mount point belongs.

  • mountpoint.provinceIndex: the index of the province to which the mount point belongs.

  • mountpoint.unity2DLocation: location of the mount point in the map in local space coordinates (-0.5 .. 0.5).

  • mountpoint.uniqueId: unique identifier of the mountpoint. Can be used as a key to relate this mountpoint with your custom classes.

  • mountpoint.attrib: root for custom attributes.

Cell class

The cell class describes one cell of the hexagonal grid (when enabled). You can get an array of cells using map.cells. Each cell object has the following properties and methods:

  • cell.row / cell.column: the location of the cell in the grid.

  • cell.center: location of the cell in the map in local space coordinates (-0.5 .. 0.5).

  • cell.attrib: root for custom attributes.

Utility methods

World Map Strategy Kit API includes many useful methods for a variety of tasks as well:

  • Vector2 WorldToMap2DPosition(Vector3 position): converts a world space coordinate into a 2D map coordinate.

  • Vector3 Map2DToWorldPosition(Vector2 position, float height): converts a 2D map coordinate with optional height into a world space coordinate.

     

Back To Top