// Utility functions called from OnGUI: void FlyToCountry(int countryIndex) { // Get zoom level for the extents of the country float zoomLevel = map.GetCountryRegionZoomExtents(countryIndex); map.FlyToCountry(countryIndex, 2.0f, zoomLevel); map.BlinkCountry(countryIndex, Color.green, Color.black, 4.0f, 2.5f); }
void Start() { // 1) Get a reference to the WMSK API map = WMSK.instance; // 2) Create the dummy background country named "Pool" and move all provinces to it map.CountryCreateProvincesPool("Pool", true); // 3) Create a new country from province "Yunnan" in the pool of provinces (previously part of China) Province province = map.GetProvince("Yunnan", "Pool"); int yunnanCountryIndex = map.ProvinceToCountry(province, "Yunnan Country", false); // 4) Adds more provinces from the pool to the new country province = map.GetProvince("Guangxi", "Pool"); map.CountryTransferProvinceRegion(yunnanCountryIndex, province.mainRegion, false); province = map.GetProvince("Guizhou", "Pool"); map.CountryTransferProvinceRegion(yunnanCountryIndex, province.mainRegion, false); province = map.GetProvince("Sichuan", "Pool"); map.CountryTransferProvinceRegion(yunnanCountryIndex, province.mainRegion, false); // 5) Refresh map and frontiers map.drawAllProvinces = true; map.Redraw(true); // 6) Add province names map.DrawProvinceLabels(yunnanCountryIndex); // 7) Fly to country and fit zoom float zoomLevel = map.GetCountryRegionZoomExtents(yunnanCountryIndex); map.FlyToCountry(yunnanCountryIndex, 2f, zoomLevel); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); /* Register events: this is optionally but allows your scripts to be informed instantly as the mouse enters or exits a country, province or city */ map.OnCityEnter += (int cityIndex) => Debug.Log("Entered city " + map.cities[cityIndex].name); map.OnCityExit += (int cityIndex) => Debug.Log("Exited city " + map.cities[cityIndex].name); map.OnCityClick += (int cityIndex, int buttonIndex) => Debug.Log("Clicked city " + map.cities[cityIndex].name); map.OnProvinceEnter += (int provinceIndex, int regionIndex) => Debug.Log("Entered province " + map.provinces[provinceIndex].name); map.OnProvinceExit += (int provinceIndex, int regionIndex) => Debug.Log("Exited province " + map.provinces[provinceIndex].name); map.OnProvinceClick += (int provinceIndex, int regionIndex, int buttonIndex) => Debug.Log("Clicked province " + map.provinces[provinceIndex].name); map.FlyToCountry("France", 3, 0.05f); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.normal.textColor = Color.white; labelStyleShadow = new GUIStyle(labelStyle); labelStyleShadow.normal.textColor = Color.black; buttonStyle = new GUIStyle(labelStyle); buttonStyle.alignment = TextAnchor.MiddleLeft; buttonStyle.normal.background = Texture2D.whiteTexture; buttonStyle.normal.textColor = Color.white; colorPicker = gameObject.GetComponent <ColorPicker> (); sliderStyle = new GUIStyle(); sliderStyle.normal.background = Texture2D.whiteTexture; sliderStyle.fixedHeight = 4.0f; sliderThumbStyle = new GUIStyle(); sliderThumbStyle.normal.background = Resources.Load <Texture2D> ("GUI/thumb"); sliderThumbStyle.overflow = new RectOffset(0, 0, 8, 0); sliderThumbStyle.fixedWidth = 20.0f; sliderThumbStyle.fixedHeight = 12.0f; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); /* Register events: this is optionally but allows your scripts to be informed instantly as the mouse enters or exits a country, province or city */ map.OnCellEnter += (int cellIndex) => Debug.Log("Entered cell #" + cellIndex + " at row " + map.cells [cellIndex].row + ", column " + map.cells [cellIndex].column); map.OnCellExit += (int cellIndex) => Debug.Log("Exited cell #" + cellIndex + " at row " + map.cells [cellIndex].row + ", column " + map.cells [cellIndex].column); map.OnCellClick += (int cellIndex, int buttonIndex) => { int row = map.cells [cellIndex].row; int col = map.cells [cellIndex].column; Debug.Log("Clicked cell #" + cellIndex + " at row " + row + ", column " + col + ", center = " + map.cells [cellIndex].center); switch (mode) { case ACTION_MODE.Blink: case ACTION_MODE.FadeOut: case ACTION_MODE.Flash: AnimateCells(row, col); break; case ACTION_MODE.Paint: PaintCurrentCell(); break; case ACTION_MODE.FadeCountry: PaintCurrentCountry(); break; } }; map.SetZoomLevel(0.3f); map.showGrid = true; cellsCount = map.gridColumns; map.FlyToCountry("Spain", 0, 0.17f); }
// Utility functions called from OnGUI: void FlyToCountryAndBlinkIt(string countryName) { int countryIndex = map.GetCountryIndex(countryName); float fitZoomLevel = map.GetCountryZoomExtents(countryIndex, true); map.FlyToCountry(countryIndex, 2.0f, fitZoomLevel); map.BlinkCountry(countryName, Color.green, Color.black, 4.0f, 2.5f); }
IEnumerator TransferProvinces() { // Reset map map.ReloadData(); map.Redraw(); // Transfer some German provinces to Poland int countryIndex = map.GetCountryIndex("Poland"); // Step 1: Focus on area of provinces map.showProvinces = true; map.drawAllProvinces = true; map.FlyToProvince("Germany", "Brandenburg", 1f, 0.04f); yield return(new WaitForSeconds(1f)); // Step 2: Mark provinces string[] provincesToTransfer = new string[] { "Brandenburg", "Mecklenburg-Vorpommern", "Sachsen-Anhalt", "Sachsen", "Thüringen" }; foreach (string provinceName in provincesToTransfer) { int provinceIndex = map.GetProvinceIndex("Germany", provinceName); map.BlinkProvince(provinceIndex, Color.white, Color.red, 2f, 0.15f); LineMarkerAnimator lma = map.AddLine(new Vector2[] { map.provinces [provinceIndex].center, map.countries [countryIndex].center }, Color.yellow, 1f, 0.15f); lma.dashInterval = 0.0001f; lma.dashAnimationDuration = 0.3f; lma.drawingDuration = 2.5f; lma.autoFadeAfter = 0.5f; lma.fadeOutDuration = 0f; } yield return(new WaitForSeconds(3f)); // Step 3: transfer some German provinces to Poland foreach (string provinceName in provincesToTransfer) { Province province = map.GetProvince(provinceName, "Germany"); if (!map.CountryTransferProvinceRegion(countryIndex, province.mainRegion, false)) { Debug.LogError("Could not transfer province " + provinceName + " to Poland."); } } map.Redraw(); // End map.FlyToCountry("Poland", 1f, 0.04f); map.BlinkCountry("Poland", Color.white, Color.green, 2f, 0.15f); Debug.Log("Done."); }
IEnumerator TransferCountry() { // Reset map map.ReloadData(); map.Redraw(); // Countries in action string targetCountry = "Czech Republic"; string sourceCountry = "Slovakia"; int targetCountryIndex = map.GetCountryIndex(targetCountry); int sourceCountryIndex = map.GetCountryIndex(sourceCountry); if (sourceCountryIndex < 0 || targetCountryIndex < 0) { Debug.Log("Countries not found."); yield break; } // Step 1: Mark countries map.FlyToCountry(sourceCountry, 1f, 0.05f); map.BlinkCountry(sourceCountry, Color.white, Color.red, 2f, 0.15f); yield return(new WaitForSeconds(1f)); // Step 2: Add animated line LineMarkerAnimator lma = map.AddLine(new Vector2[] { map.countries[sourceCountryIndex].center, map.countries[targetCountryIndex].center }, Color.yellow, 2f, 0.15f); lma.dashInterval = 0.0005f; lma.dashAnimationDuration = 0.3f; lma.drawingDuration = 2.5f; lma.autoFadeAfter = 0.5f; lma.fadeOutDuration = 0f; yield return(new WaitForSeconds(3f)); // Step 3: Transfer Slovakia to Czech Republic Region sourceRegion = map.GetCountry("Slovakia").mainRegion; if (!map.CountryTransferCountryRegion(targetCountryIndex, sourceRegion, false)) { Debug.LogError("Country could not be transferred."); yield break; } // Step 4: rename Czech Republic to Czechoslovakia if (!map.CountryRename("Czech Republic", "Czechoslovakia")) { Debug.LogError("Country could not be renamed."); } // Step 5: refresh any change on screen and highlight the new country map.Redraw(); map.BlinkCountry("Czechoslovakia", Color.white, Color.blue, 2f, 0.15f); }
void Start() { map = WMSK.instance; int USAIndex = map.GetCountryIndex("United States of America"); Region region = map.GetCountry(USAIndex).mainRegion; map.RegionGenerateExtrudeGameObject("Extruded USA", region, 1f, Color.gray); map.FlyToCountry(USAIndex, 4f, 0.2f); }
void Start() { // Get a reference to the World Map API: map = WMSK.instance; // Color and add outline to Algeria int countryIndex = map.GetCountryIndex("Algeria"); map.ToggleCountrySurface(countryIndex, true, new Color(1, 1, 1, 0.25f)); map.ToggleCountryOutline(countryIndex, true, borderTexture, 0.5f, Color.gray); // Color and add outline to Niger countryIndex = map.GetCountryIndex("Niger"); map.ToggleCountrySurface(countryIndex, true, new Color(0, 1, 0, 0.25f)); map.ToggleCountryOutline(countryIndex, true, borderTexture, 0.5f, Color.green); // Merge three country regions and add a common border (Spain + France + Germany) DrawOutline(); // Zoom into the zone map.FlyToCountry(countryIndex, 0, 0.3f); }
void Start() { // UI Setup - non-important, only for this demo labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.normal.textColor = Color.white; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); // Real useful code: // 1) Get a reference to the WMSK API map = WMSK.instance; // 2) Remove any existing map; to prevent loading geodata files at start, check the toggle DontLoadGeodataAtStart in WMSK inspector map.ClearAll(); // 3) Create country based on cells defined by columns and rows int[,] cells = new int[, ] { { 20, 10 }, { 21, 10 }, { 20, 11 }, { 21, 11 } }; countryIndex = CreateHexCountry("My country", cells); // Focus on country map.FlyToCountry(countryIndex, 2f, 0.2f); // Optional: Fill the new country with a color map.ToggleCountrySurface(countryIndex, true, countryColor); // Optional: allow country expansion using click on other cells map.OnCellClick += CellClicked; }