Esempio n. 1
0
        /// <summary>
        /// Illustrates how to add custom markers over the map using the AddMarker API.
        /// In this example a building prefab is added to a random city (see comments for other options).
        /// </summary>
        void AddMarkerTextOnRandomPlace()
        {
            // Every marker is put on a plane-coordinate (in the range of -0.5..0.5 on both x and y)
            Vector2 planeLocation = new Vector2(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f));

            // Add the text
            TextMesh tm = map.AddMarker2DText("Random Caption", planeLocation);

            tm.color = Color.yellow;

            // Fly to the destination and see the building created
            map.FlyToLocation(planeLocation, 2f, 0.1f);

            // Optionally add a blinking effect to the marker
            MarkerBlinker.AddTo(tm.gameObject, 3, 0.2f);
        }
Esempio n. 2
0
        /// <summary>
        /// Illustrates how to add custom markers over the map using the AddMarker API.
        /// In this example a building prefab is added to a random city (see comments for other options).
        /// </summary>
        void AddMarkerOnRandomCity()
        {
            // Every marker is put on a spherical-coordinate (assuming a radius = 0.5 and relative center at zero position)
            Vector2 planeLocation;

            // Add a marker on a random city
            City city = map.cities[Random.Range(0, map.cities.Count)];

            planeLocation = city.unity2DLocation;

            // or... choose a city by its name:
//		int cityIndex = map.GetCityIndex("Moscow");
//		planeLocation = map.cities[cityIndex].unity2DLocation;

            // or... use the centroid of a country
//		int countryIndex = map.GetCountryIndex("Greece");
//		planeLocation = map.countries[countryIndex].center;

            // or... use a custom location lat/lon. Example put the building over New York:
//		map.calc.fromLatDec = 40.71f;	// 40.71 decimal degrees north
//		map.calc.fromLonDec = -74.00f;	// 74.00 decimal degrees to the west
//		map.calc.fromUnit = UNIT_TYPE.DecimalDegrees;
//		map.calc.Convert();
//		planeLocation = map.calc.toPlaneLocation;

            // Send the prefab to the AddMarker API setting a scale of 0.1f (this depends on your marker scales)
            GameObject star = Instantiate(Resources.Load <GameObject>("Sprites/StarSprite"));

            map.AddMarker2DSprite(star, planeLocation, 0.02f, true);

            // Add an optional click handler for this sprite
            MarkerClickHandler handler = star.GetComponent <MarkerClickHandler>();

            handler.OnMarkerMouseDown  += (buttonIndex => Debug.Log("Click on sprite with button " + buttonIndex + "!"));
            handler.OnMarkerMouseEnter += () => Debug.Log("Pointer is on sprite!");
            handler.OnMarkerMouseExit  += () => Debug.Log("Pointer exits sprite!");

            // Fly to the destination and see the building created
            map.FlyToLocation(planeLocation);

            // Optionally add a blinking effect to the marker
            MarkerBlinker.AddTo(star, 3, 0.2f);
        }
Esempio n. 3
0
        IEnumerator LaunchMissile(float delay, string countryOrigin, string countryDest, Color color)
        {
            float start = Time.time;

            while (Time.time - start < delay)
            {
                yield return(null);
            }

            // Initiates line animation
            int cityOrigin = map.GetCityIndexRandom(map.GetCountry(countryOrigin));
            int cityDest   = map.GetCityIndexRandom(map.GetCountry(countryDest));

            if (cityOrigin < 0 || cityDest < 0)
            {
                yield break;
            }

            Vector2            origin    = map.cities [cityOrigin].unity2DLocation;
            Vector2            dest      = map.cities [cityDest].unity2DLocation;
            float              elevation = 1f;
            float              width     = 0.25f;
            LineMarkerAnimator lma       = map.AddLine(origin, dest, color, elevation, width);

            lma.dashInterval          = 0.0003f;
            lma.dashAnimationDuration = 0.5f;
            lma.drawingDuration       = 4f;
            lma.autoFadeAfter         = 1f;

            // Add flashing target
            GameObject sprite = Instantiate(target) as GameObject;

            sprite.GetComponent <SpriteRenderer> ().material.color = color * 0.9f;
            map.AddMarker2DSprite(sprite, dest, 0.003f);
            MarkerBlinker.AddTo(sprite, 4, 0.1f, 0.5f, true);

            // Triggers explosion
            StartCoroutine(AddCircleExplosion(4f, dest, Color.yellow));
        }
Esempio n. 4
0
        /// <summary>
        /// Illustrates how to add custom markers over the map using the AddMarker API.
        /// In this example a building prefab is added to a random city (see comments for other options).
        /// </summary>
        void AddMarker3DObjectOnRandomCity()
        {
            // Every marker is put on a plane-coordinate (in the range of -0.5..0.5 on both x and y)
            Vector2 planeLocation;

            // Add a marker on a random city
            City city = map.cities[Random.Range(0, map.cities.Length)];

            planeLocation = city.unity2DLocation;

            // or... choose a city by its name:
            //		int cityIndex = map.GetCityIndex("Moscow");
            //		planeLocation = map.cities[cityIndex].unity2DLocation;

            // or... use the centroid of a country
            //		int countryIndex = map.GetCountryIndex("Greece");
            //		planeLocation = map.countries[countryIndex].center;

            // or... use a custom location lat/lon. Example put the building over New York:
            //		map.calc.fromLatDec = 40.71f;	// 40.71 decimal degrees north
            //		map.calc.fromLonDec = -74.00f;	// 74.00 decimal degrees to the west
            //		map.calc.fromUnit = UNIT_TYPE.DecimalDegrees;
            //		map.calc.Convert();
            //		planeLocation = map.calc.toPlaneLocation;

            // Send the prefab to the AddMarker API setting a scale of 0.1f (this depends on your marker scales)
            GameObject tower = Instantiate(Resources.Load <GameObject>("Tower/tower"));

            map.AddMarker3DObject(tower, planeLocation, 1f);

            // Fly to the destination and see the building created
            map.FlyToLocation(planeLocation, 2f, 0.2f);

            // Optionally add a blinking effect to the marker
            MarkerBlinker.AddTo(tower, 3, 0.2f);
        }