예제 #1
0
        void Start()
        {
            // 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 points
            Vector2[] points =
            {
                new Vector2(0.05f, 0.12f),
                new Vector2(0.07f, 0.18f),
                new Vector2(0.23f, 0.25f),
                new Vector2(0.3f,   0.2f),
                new Vector2(0.31f, 0.11f),
                new Vector2(0.28f, 0.14f),
                new Vector2(0.25f, 0.09f),
                new Vector2(0.2f, 0.1f)
            };
            int countryIndex = CreateCountry("My country", points);

            //CreateProvince("My Province", countryIndex, points);

            // 4) Draw the map
            map.Redraw();

            // Optional: Fill the new country with a color
            Color countryColor = new Color(0.698f, 0.396f, 0.094f);

            map.ToggleCountrySurface(countryIndex, true, countryColor);
        }
예제 #2
0
        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;
        }