Esempio n. 1
0
        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);
        }
        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.");
        }
Esempio n. 3
0
        //void ExpandProvince (Region region) {
        //				if (principalProvinceIndex < 0 || region == null)
        //								return;

        //				// Store principal province id which is immutable - province index will change because the provinces array is modified after one province merges another (one of them disappears).
        //				int provinceUniqueId = map.provinces [principalProvinceIndex].uniqueId;
        //				string provinceName = region.entity.name;

        //				if (map.ProvinceTransferProvinceRegion (principalProvinceIndex, region, true)) {
        //								// Restore principal id before provinces array changed
        //								SelectPrincipalProvince (map.GetProvinceIndex (provinceUniqueId));
        //								Debug.Log ("Province " + provinceName + " conquered by " + map.provinces [principalProvinceIndex].name + "!");
        //				}
        //}

        void ExpandProvince(Region region)
        {
            int countryIndex = map.GetCountryIndex("Sweden");

            map.CountryTransferProvinceRegion(countryIndex, region, true);
        }