示例#1
0
        /// <summary>
        /// Checks if tank is near Paris. Then moves it to Moscow. Otherwise, moves it back to Paris.
        /// </summary>
        void MoveTankAndFollow()
        {
            string destinationCity, destinationCountry;

            if (tank == null)
            {
                DropTankOnCity();
            }

            // Gets position of Paris in map
            Vector2 parisPosition = map.GetCity("Paris", "France").unity2DLocation;

            // Is the tank nearby (less than 50 km)? Then set destination to Moscow, otherwize Paris again
            if (map.calc.Distance(tank.currentMap2DLocation, parisPosition) < 50000)
            {
                destinationCity    = "Moscow";
                destinationCountry = "Russia";
            }
            else
            {
                destinationCity    = "Paris";
                destinationCountry = "France";
            }

            // Get position of destination
            Vector2 destination = map.GetCity(destinationCity, destinationCountry).unity2DLocation;

            // For this movement, we will move the tank following a straight line
            tank.terrainCapability = TERRAIN_CAPABILITY.Any;

            // Move the tank to the new position with smooth ease
            tank.easeType = EASE_TYPE.SmoothStep;

            // Use a close zoom during follow - either current zoom level or 0.1f maximum so tank is watched closely
            tank.follow          = true;
            tank.followZoomLevel = Mathf.Min(0.1f, map.GetZoomLevel());

            // Move it!
            tank.MoveTo(destination, 4.0f);

            // Finally, signal me when tank stops
            tank.OnMoveEnd += (thisTank) => Debug.Log("Tank has stopped at " + thisTank.currentMap2DLocation + " location.");
        }
示例#2
0
    private static void initProvince(ProvinceSettings provSettings)
    {
        map.ToggleProvinceSurface(map.GetProvinceIndex("Spain", provSettings.province), true, new Color(provSettings.initcolor.r / 255f, provSettings.initcolor.g / 255f, provSettings.initcolor.b / 255f), null, true);
        Vector2    barLocation  = map.GetCity(provSettings.city, "Spain").unity2DLocation;
        GameObject provinceBars = (GameObject)Instantiate(Resources.Load("Bar3DSimple"));

        map.AddMarker3DObject(provinceBars, barLocation, 0.5f);
        provinceBars.transform.eulerAngles = new Vector3(0, 0, 0);
        provinceBars.transform.localScale  = new Vector3(0.0005f, 0.0005f, 0.001f);
        provinceBars.transform.position    = new Vector3(provinceBars.transform.position.x, provinceBars.transform.position.y - 0.1f, -3);
    }
示例#3
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);
        }
示例#4
0
    private void placeRailRoad(int start, int end)
    {
        //Vector2 beginLoc = map.cities[start].unity2DLocation;
        // Vector2 endLoc = map.cities[end].unity2DLocation;
        Cell       cell1       = map.GetCell(map.GetCity(start).unity2DLocation);
        Cell       cell2       = map.GetCell(map.GetCity(end).unity2DLocation);
        List <int> cellIndices = map.FindRoute(cell1, cell2, TERRAIN_CAPABILITY.OnlyGround);

        if (cellIndices == null)
        {
            return;
        }
        int positionsCount = cellIndices.Count;

        Debug.Log("Number of positions: " + positionsCount);

        Vector2[] positions = new Vector2[positionsCount];
        for (int k = 0; k < positionsCount; k++)
        {
            positions[k] = map.cells[cellIndices[k]].center;
        }

        // Build a road along the map coordinates
        LineMarkerAnimator lma         = map.AddLine(positions, Color.white, 0.0f, 0.15f);
        Texture2D          railwayMatt = Resources.Load("Sprites/GUI/railRoad", typeof(Texture2D)) as Texture2D;

        lma.lineMaterial.mainTexture      = railwayMatt;
        lma.lineMaterial.mainTextureScale = new Vector2(16f, 2f);
        // Province startProv = map.GetProvince(start);
        //  Province endProv = map.GetProvince(end);
        //  Vector2 startCent = startProv.center;
        //  Vector2 endCent = endProv.center;

        // Cell startCell = map.GetCell(startCent);
        //  Cell endCell = map.GetCell(startCent);
        //Debug.Log(startCell.points);
        //List<int> startCells = map.GetCellsInProvince(start);
        // List<int> endCells =  map.GetCellsInProvince(end);
        // Cell startCell = map.cells[startCells[0]];
        // Cell endCell = map.cells[endCells[0]];
        // List<int> routePoints = map.FindRoute(startProv, endProv, 12);
        // List<int> cellIndices = map.FindRoute(beginLoc, endLoc, TERRAIN_CAPABILITY.OnlyGround);
        // LineMarkerAnimator pathLine = map.AddLine(beginLoc, endLoc, Color.white, 0.5f, 3f);

        /* if (cellIndices == null)
         * {
         *   Debug.Log("No cell indices!!!!");
         *
         *   return;
         * }
         * int positionsCount = cellIndices.Count;
         * Vector2[] positions = new Vector2[positionsCount];
         * for (int k = 0; k < positionsCount; k++)
         * {
         *   positions[k] = map.cells[cellIndices[k]].center;
         * }
         * Texture2D railwayMatt = Resources.Load("Sprites/GUI/railroad2", typeof(Texture2D)) as Texture2D;
         * // Build a road along the map coordinates
         * //LineMarkerAnimator pathLine = map.AddLine(startProv.center, endProv.center, Color.white, 0, 0.1f);
         * LineMarkerAnimator pathLine = map.AddLine(positions, Color.white, 0, 1.5f); */
        // Texture2D railwayMatt = Resources.Load("Sprites/GUI/railroad2", typeof(Texture2D)) as Texture2D;

        //  pathLine.lineMaterial.mainTexture = railwayMatt;
        //  pathLine.lineMaterial.mainTextureScale = new Vector2(8f, 1f);
    }