コード例 #1
0
    // Probably want to build a proper, dedicated line-drawing class if you start using this function extensively.
    public void InstantiateDominationLines(Ruler ruler)
    {
        Location        loc           = ruler.GetHomeLocation();
        List <Location> lineLocations = new List <Location>();

        foreach (Location location in ruler.GetControlledLocations())
        {
            lineLocations.Add(location);
        }

        foreach (Location lineloc in lineLocations)
        {
            GameObject   lineObj = Instantiate(linePrefab);
            LineRenderer line    = lineObj.GetComponent <LineRenderer>();
            // Set false to not scale to map holder and go offpos. Alternatively set localscale to 1,1,1 at bottom.
            lineObj.transform.SetParent(MapController.Instance.GetActiveMapHolder().transform, false);
            lineList.Add(lineObj);
            line.startWidth = lineStartSize;
            line.endWidth   = lineEndSize;
            lineObj.transform.localPosition = new Vector3(0, 0, 0);
            line.SetPosition(0, ruler.GetPositionVector());
            line.SetPosition(1, lineloc.GetPositionVector());
            line.startColor = Color.blue;
            line.endColor   = Color.red;
        }
    }