Beispiel #1
0
    public void SetName()
    {
        Vector2Int        left, center, right;
        List <Vector2Int> ter = new List <Vector2Int>();

        for (int i = 0; i < regions.Count; i++)
        {
            ter.Add(regions[i].Capital);
        }
        MapMetrics.CalculLCR(ter, out left, out center, out right);

        Vector3 l = MapMetrics.GetCellPosition(left, true);
        Vector3 c = MapMetrics.GetCellPosition(center, true);
        Vector3 r = MapMetrics.GetCellPosition(right, true);

        l -= c; r -= c;
        l  = new Vector3(l.x, l.z, l.y);
        r  = new Vector3(r.x, r.z, r.y);


        left  -= center;
        right -= center;
        float maxd = left.magnitude + right.magnitude;
        float maxS = maxd * 2.4f / name.Length;
        int   S    = Mathf.RoundToInt(regions.Count * 0.6f);

        if (maxS < 1 || S < 1)
        {
            Text.SetActive(false);
            return;
        }
        int fontSize = (int)Mathf.Clamp((4 + Mathf.Clamp(S, 0, 10)), 3, maxS);

        Text.transform.position = c;
        Text.transform.SetParent(Main.instance.Names);

        Text.GetComponent <CurvedText>().SetProperies(name, l, r, fontSize);
    }