Пример #1
0
        public void ScaleCities()
        {
            map.GetLocalHitFromScreenPos(Input.mousePosition, out lastPos);
            lastPos             = transform.TransformPoint(lastPos);
            lastCamPos          = map.currentCamera.transform.position;
            lastIconSize        = map.cityIconSize;
            lastOrtographicSize = map.currentCamera.orthographicSize;

            Vector3 a = map.currentCamera.WorldToScreenPoint(transform.position);
            Vector3 b = new Vector3(a.x, a.y + CITY_SIZE_ON_SCREEN, a.z);

            if (map.currentCamera.pixelWidth == 0)
            {
                return;                                              // Camera pending setup
            }
            Vector3 aa    = map.currentCamera.ScreenToWorldPoint(a);
            Vector3 bb    = map.currentCamera.ScreenToWorldPoint(b);
            float   scale = (aa - bb).magnitude * map.cityIconSize;

            if (map.currentCamera.orthographic)
            {
                scale /= 1 + (map.currentCamera.orthographicSize * map.currentCamera.orthographicSize) * (0.1f / map.transform.localScale.x);
            }
            else
            {
                scale /= 1 + (lastCamPos - lastPos).sqrMagnitude * (0.1f / map.transform.localScale.x);
            }
            Vector3 newScale = new Vector3(scale / WorldMap2D.mapWidth, scale / WorldMap2D.mapHeight, 1.0f);

            foreach (Transform t in transform.Find("Normal Cities"))
            {
                t.localScale = newScale;
            }
            foreach (Transform t in transform.Find("Region Capitals"))
            {
                t.localScale = newScale * 1.75f;
            }
            foreach (Transform t in transform.Find("Country Capitals"))
            {
                t.localScale = newScale * 2.0f;
            }
        }
Пример #2
0
        public void ScaleMountPoints()
        {
            if (map == null)
            {
                return;
            }
            map.GetLocalHitFromScreenPos(Input.mousePosition, out lastPos);
            lastPos             = transform.TransformPoint(lastPos);
            lastCamPos          = map.mainCamera.transform.position;    // Camera.main.transform.position;
            lastIconSize        = map.cityIconSize;
            lastOrtographicSize = map.currentCamera.orthographicSize;

            Vector3 a = map.currentCamera.WorldToScreenPoint(transform.position);
            Vector3 b = new Vector3(a.x, a.y + MOUNTPOINT_SIZE_ON_SCREEN, a.z);

            if (map.currentCamera.pixelWidth == 0)
            {
                return;                                              // Camera pending setup
            }
            Vector3 aa    = map.currentCamera.ScreenToWorldPoint(a);
            Vector3 bb    = map.currentCamera.ScreenToWorldPoint(b);
            float   scale = (aa - bb).magnitude * map.cityIconSize;

            if (map.currentCamera.orthographic)
            {
                scale /= 1 + (map.currentCamera.orthographicSize * map.currentCamera.orthographicSize) * (0.1f / map.transform.localScale.x);
            }
            else
            {
                scale /= 1 + (lastCamPos - lastPos).sqrMagnitude * (0.1f / map.transform.localScale.x);
            }
            Vector3 newScale = new Vector3(scale / WorldMap2D.mapWidth, scale / WorldMap2D.mapHeight, 1.0f);

            newScale *= 2.0f;
            foreach (Transform t in transform)
            {
                t.localScale = newScale;
            }
        }