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) => 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) => Debug.Log("Clicked province " + map.provinces [provinceIndex].name);

            map.FlyToCountry("France", 3, 0.05f);
        }
Beispiel #2
0
        void Start()
        {
            // Get a reference to the World Map API:
            map = WMSK.instance;

            // setup GUI resizer - only for the demo
            GUIResizer.Init(800, 500);

            // Get list of European countries
            europeanCountries = new List <Country>();
            for (int k = 0; k < map.countries.Length; k++)
            {
                Country country = map.countries[k];
                if (country.continent.Equals("Europe"))
                {
                    europeanCountries.Add(country);
                    // Distribute countries between 2 players
                    if (country.center.x < 0.04f)
                    {
                        country.attrib["player"] = 1;
                    }
                    else
                    {
                        country.attrib["player"] = 2;
                    }
                }
            }

            // Colors
            player1Color = new Color(1, 0.5f, 0, 0.65f);
            player2Color = new Color(0, 0.5f, 1, 0.65f);

            // On map click listener
            map.OnClick += (float x, float y) => {
                if (enableToggleOwnership)
                {
                    ChangeCountryOwnerShip(x, y);
                }
                else if (enableClickToMoveTank)
                {
                    MoveTankWithPathFinding(new Vector2(x, y));
                }
            };

            // Setup map rect
            map.windowRect = new Rect(-0.0587777f, 0.1964018f, 0.1939751f, 0.1939751f);
            map.SetZoomLevel(0.1939751f);
            map.CenterMap();

            // Paint countries
            PaintCountries();

            // Drop our tester tank
            DropTankOnCity();

            // Enable custom pathfinding matrix (we'll setup this matrix when moving the unit)
            map.pathFindingEnableCustomRouteMatrix = true;
        }
Beispiel #3
0
        void Start()
        {
            StartHackerspaces();


            // 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> ("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);

            // Some example commands below
//			map.ToggleCountrySurface("Brazil", true, Color.green);
//			map.ToggleCountrySurface(35, true, Color.green);
//			map.ToggleCountrySurface(33, true, Color.green);
//			map.FlyToCountry(33);
//			map.FlyToCountry("Brazil");
//			map.navigationTime = 0; // jump instantly to next country
//			map.FlyToCountry ("India");

            /* 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) =>
            {
                OnCityClickHackerspaces(cityIndex);
            };
            //Debug.Log ("Clicked city " + map.cities [cityIndex].name);
            map.OnCountryEnter  += (int countryIndex, int regionIndex) => Debug.Log("Entered country " + map.countries [countryIndex].name);
            map.OnCountryExit   += (int countryIndex, int regionIndex) => Debug.Log("Exited country " + map.countries [countryIndex].name);
            map.OnCountryClick  += (int countryIndex, int regionIndex) => Debug.Log("Clicked country " + map.countries [countryIndex].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) => Debug.Log("Clicked province " + map.provinces [provinceIndex].name);
        }
Beispiel #4
0
        void Start()
        {
            // 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);
        }
Beispiel #5
0
        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 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);
                if (enableFadeOut)
                {
                    FadeOutCells(row, col);
                }
            };

            map.SetZoomLevel(0.3f);
            map.showGrid = true;
            cellsCount   = map.gridColumns;

            map.FlyToCountry("Spain", 0, 0.17f);
        }
Beispiel #6
0
    void Start()
    {
        // Get a reference to the World Map API:
        map = WorldMap2D.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> ("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.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) => Debug.Log ("Clicked city " + map.cities [cityIndex].name);
         * map.OnCountryEnter += (int countryIndex, int regionIndex) => Debug.Log ("Entered country " + map.countries [countryIndex].name);
         * map.OnCountryExit += (int countryIndex, int regionIndex) => Debug.Log ("Exited country " + map.countries [countryIndex].name);
         * map.OnCountryClick += (int countryIndex, int regionIndex) => Debug.Log ("Clicked country " + map.countries [countryIndex].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) => Debug.Log ("Clicked province " + map.provinces [provinceIndex].name);
         */
        map.CenterMap();
    }
Beispiel #7
0
    void Start()
    {
        // Get a reference to the World Map API:
        map = WorldMap2D.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> ("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);

        map.CenterMap();         // Center map on the screen

//			map.ToggleCountrySurface("Brazil", true, Color.green);
//			map.ToggleCountrySurface(35, true, Color.green);
//			map.ToggleCountrySurface(33, true, Color.green);
//			map.FlyToCountry(33);
//			map.FlyToCountry("Brazil");

//			map.navigationTime = 0;
//			map.FlyToCountry ("India");
    }
Beispiel #8
0
        float timeOfDay = 0.0f;         // in hours (0-23.99)

        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;
            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);

            map.CenterMap();

            // Instantiate game object and position it instantly over the city
            GameObject tower    = Instantiate(Resources.Load <GameObject> ("Tower/Tower"));
            Vector2    position = map.GetCity("Lhasa", "China").unity2DLocation;

            tower.WMSK_MoveTo(position);

            // Zoom in
            map.FlyToLocation(position, 1f, 0.1f);
        }
Beispiel #9
0
        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);

            map.OnClick += (float x, float y) => {
                if (enableAddTowerOnClick)
                {
                    AddTowerAtPosition(x, y);
                }
                else if (enableClickToMoveTank)
                {
                    MoveTankWithPathFinding(new Vector2(x, y));
                }
                else if (enableClickToMoveShip)
                {
                    // as ship has terrainCapability set to Water we just need to call one function to make it go over there along an optimal path
                    ship.MoveTo(new Vector2(x, y), 0.1f);
                }
            };

            map.CenterMap();
        }
Beispiel #10
0
        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;
            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;

            // Prepare line texture
            lineMaterialAerial = Instantiate(Resources.Load <Material>("PathLine/aerialPath"));
            lineMaterialGround = Instantiate(Resources.Load <Material>("PathLine/groundPath"));

            // setup GUI resizer - only for the demo
            GUIResizer.Init(800, 500);

            // plug our mouse click listener - it will be used to move the tank to target destination
            map.OnClick += (float x, float y) => {
                if (enableClickToMoveTank)
                {
                    MoveTankWithPathFinding(new Vector2(x, y));
                }
            };

            // plug our mouse move listener - it received the x,y map position of the mouse
            map.OnMouseMove += (float x, float y) => {
                // while tank is moving avoid showing paths
                if (tank.isMoving)
                {
                    return;
                }
                // if show linear path is enabled, then just show a straight (or curved line if arc elevation is specified) from tank to destination
                if (showLinearPath)
                {
                    UpdateLinearPathLine(x, y);
                }
                else
                {
                    // show route path is enabled, then we'll compute the path and draw a line that pass through those points
                    UpdateRoutePathLine(x, y);
                }
            };

            map.CenterMap();

            // Drop the tank on the Tibet
            DropTankOnCity();

//			Vector2 paris = map.GetCity("Paris", "France").unity2DLocation;
//			Vector2 madrid = map.GetCity("Madrid", "Spain").unity2DLocation;
//			Vector2 mid = (paris + madrid) * 0.5f;
//			pathLine = map.AddLine(paris, madrid, lineMaterialAerial, 2, 0.1f);
//			pathLine.dashInterval = 0.001f;
//			pathLine.dashAnimationDuration = 1f;
//
//			map.FlyToLocation(mid, 0.0f, 0.1f);
        }