/// <summary> /// Illustrates how to add custom markers over the globe 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> ("StarSprite/StarSprite")); map.AddMarker(star, planeLocation, 0.02f); // 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); }
/// <summary> /// Creates a tank instance and adds it to specified city /// </summary> void DropTankOnCity() { // Get a random big city int cityIndex = map.GetCityIndex("Lhasa", "China"); // Get city location Vector2 cityPosition = map.cities [cityIndex].unity2DLocation; if (tank != null) { DestroyImmediate(tank); } GameObject tankGO = Instantiate(Resources.Load <GameObject> ("Tank/CompleteTank")); tank = tankGO.WMSK_MoveTo(cityPosition); tank.type = (int)UNIT_TYPE.TANK; tank.autoRotation = true; tank.terrainCapability = TERRAIN_CAPABILITY.OnlyGround; // Zoom into tank map.FlyToLocation(cityPosition, 2.0f, 0.15f); }
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); }
/// <summary> /// Creates a tower instance and adds it to the map at a random city /// </summary> void AddRandomTower() { // Get a random big city int cityIndex = -1; do { cityIndex = Random.Range(0, map.cities.Count); } while (map.cities[cityIndex].population < 10000); // Get city location Vector2 cityPosition = map.cities [cityIndex].unity2DLocation; // Create tower and add it to the map AddTowerAtPosition(cityPosition.x, cityPosition.y); // Fly to the location with provided zoom level map.FlyToLocation(cityPosition, 2.0f, 0.1f); }