/// <summary>
        /// Example of how to add custom lines to the map
        /// Similar to the AddMarker functionality, you need two spherical coordinates and then call AddLine
        /// </summary>
        void AddTrajectories()
        {
            // In this example we will add random lines from 5 cities to another cities (see AddMaker example above for other options to get locations)

            for (int line = 0; line < 5; line++)
            {
                // Get two random cities
                int city1 = Random.Range(0, map.cities.Count);
                int city2 = Random.Range(0, map.cities.Count);

                // Get their sphere-coordinates
                Vector2 start = map.cities [city1].unity2DLocation;
                Vector2 end   = map.cities [city2].unity2DLocation;

                // Add line with random color, speeds and elevation
                Color color            = new Color(Random.Range(0.5f, 1), Random.Range(0.5f, 1), Random.Range(0.5f, 1));
                float elevation        = Random.Range(0, 0.5f);                 // elevation is % relative to the Earth radius
                float lineWidth        = 0.8f;
                LineMarkerAnimator lma = map.AddLine(start, end, color, elevation, lineWidth);

                // Additional line effects
                lma.drawingDuration = 4.0f;
                lma.autoFadeAfter   = 2.0f;               // line stays for 2 seconds, then fades out - set this to zero to avoid line removal
            }
        }
Beispiel #2
0
    public void drawRailroadOnMap(assemblyCsharp.Province prov, Nation player)
    {
        WorldMapStrategyKit.Province mapProvince = map.provinces[prov.getIndex()];
        Vector2 provCenter = mapProvince.center;

        for (int i = 0; i < prov.Neighbours.Count; i++)
        {
            if (PlayerCalculator.getAllProvinces(player).Contains(prov.Neighbours[i]))
            {
                // draw rail segment from prv to neighbourProv
                assemblyCsharp.Province neighbourProvince = State.getProvinces()[prov.Neighbours[i]];
                if (neighbourProvince.railroad && !neighbourProvince.Linked.Contains(prov.getIndex()) &&
                    !prov.Linked.Contains(neighbourProvince.getIndex()))
                {
                    WorldMapStrategyKit.Province mapNeighbourProvince = map.provinces[prov.Neighbours[i]];
                    Vector2    neighbourCenter = mapNeighbourProvince.center;
                    Cell       startCell       = map.GetCell(provCenter);
                    Cell       endCell         = map.GetCell(neighbourCenter);
                    List <int> cellIndices     = map.FindRoute(startCell, endCell, 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 railroad 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);
                    neighbourProvince.Linked.Add(prov.getIndex());
                    prov.Linked.Add(neighbourProvince.getIndex());
                }
            }
        }
    }
Beispiel #3
0
        /// <summary>
        /// Used when show Linear Path toggle is checked
        /// </summary>
        void UpdateLinearPathLine(float x, float y)
        {
            if (pathLine != null)               // remove existing line
            {
                Destroy(pathLine.gameObject);
            }

            // destination of linear path
            Vector2 destination = new Vector2(x, y);

            // optionally choose a material for the line (you may simply pass a color instead)
            Material lineMat = pathArcElevation > 0 ? lineMaterialAerial : lineMaterialGround;

            // draw the line
            pathLine = map.AddLine(tank.currentMap2DLocation, destination, lineMat, pathArcElevation, pathLineWidth);
            pathLine.drawingDuration       = pathDrawingDuration;
            pathLine.dashInterval          = pathDashInterval;
            pathLine.dashAnimationDuration = pathDashAnimationDuration;

            UpdateCircle(destination);
        }