Ejemplo n.º 1
0
        protected void Update()
        {
            ready = true;
            if (GeoExtension.Instance.IsLocationValid())
            {
                var inputLatLon = GeoExtension.Instance.Location;
                if (GeoExtension.Instance.IsLocationValid() &&
                    (GM.LatLonToMeters(lastUpdatedPosition) - GM.LatLonToMeters(inputLatLon)).sqrMagnitude >= 1f)
                {
                    lastUpdatedPosition = inputLatLon;
                    if (GM.SeparationInMeters(geoCharacter.LatLon, inputLatLon) > 150)
                    {
                        geoCharacter.InstantMoveTo(inputLatLon);
                    }
                    else
                    {
                        geoCharacter.MoveTo(inputLatLon);
                    }
                }
            }

            if (InventoryManager.Instance.Opened)
            {
                Camera.main.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            else
            {
                switch (mapScene.CameraType)
                {
                case CameraType.Aerial2D:
                    Camera.main.transform.position = character.transform.position + Vector3.up * 50;
                    Camera.main.transform.rotation = Quaternion.Euler(90, 0, 0);
                    break;

                case CameraType.Ortographic3D:
                    throw new System.NotImplementedException();

                case CameraType.Perspective3D:
                    throw new System.NotImplementedException();

                default:
                    break;
                }
            }

            //            Debug.Log("LatLon: " + geoCharacter.LatLon + " LT->Meters->LT: " + GM.MetersToLatLon(GM.LatLonToMeters(geoCharacter.LatLon)));

            //geoCharacter.MoveTo(geoCharacter.LatLon + GM.MetersToLatLon(new Vector2d(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))));
            //geoCharacter.MoveTo(GM.MetersToLatLon(GM.LatLonToMeters(mapScene.LatLon.y, mapScene.LatLon.x) + new Vector2d(100, 100)));
            //geoCharacter.MoveTo(new Vector2d(-3.707398, 40.415363));
            //character.Move(new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical")), false, false);
        }
Ejemplo n.º 2
0
        protected void Update()
        {
            if (Input.location.status == LocationServiceStatus.Running && Input.location.lastData.timestamp != 0 && Input.location.lastData.latitude != 0)
            {
                var inputLatLon = new Vector2d(Input.location.lastData.latitude, Input.location.lastData.longitude);
                if (GPSController.Instance.IsLocationValid() &&
                    (GM.LatLonToMeters(lastUpdatedPosition) - GM.LatLonToMeters(inputLatLon)).sqrMagnitude >= 1f)
                {
                    ready = true;
                    lastUpdatedPosition = inputLatLon;
                    if (GM.SeparationInMeters(geoCharacter.LatLon, inputLatLon) > 150)
                    {
                        geoCharacter.LatLon = inputLatLon;
                    }
                    else
                    {
                        geoCharacter.MoveTo(inputLatLon);
                    }
                }
            }

            switch (mapScene.CameraType)
            {
            case CameraType.Aerial2D:
                Camera.main.transform.position = character.transform.position + Vector3.up * 50;
                Camera.main.transform.rotation = Quaternion.Euler(90, 0, 0);
                break;

            case CameraType.Ortographic3D:
                throw new System.NotImplementedException();

            case CameraType.Perspective3D:
                throw new System.NotImplementedException();

            default:
                break;
            }
            //            Debug.Log("LatLon: " + geoCharacter.LatLon + " LT->Meters->LT: " + GM.MetersToLatLon(GM.LatLonToMeters(geoCharacter.LatLon)));

            //geoCharacter.MoveTo(geoCharacter.LatLon + GM.MetersToLatLon(new Vector2d(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))));
            //geoCharacter.MoveTo(GM.MetersToLatLon(GM.LatLonToMeters(mapScene.LatLon.y, mapScene.LatLon.x) + new Vector2d(100, 100)));
            //geoCharacter.MoveTo(new Vector2d(-3.707398, 40.415363));
            //character.Move(new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical")), false, false);
        }
Ejemplo n.º 3
0
        protected void Update()
        {
            ready = uAdventurePlugin.ready;
            if (GeoExtension.Instance.IsLocationValid())
            {
                var inputLatLon = GeoExtension.Instance.Location;
                if (GeoExtension.Instance.IsLocationValid() &&
                    (GM.LatLonToMeters(lastUpdatedPosition) - GM.LatLonToMeters(inputLatLon)).sqrMagnitude >= 1f)
                {
                    lastUpdatedPosition = inputLatLon;
                    if (GM.SeparationInMeters(geoCharacter.LatLon, inputLatLon) > 150)
                    {
                        geoCharacter.InstantMoveTo(inputLatLon);
                    }
                    else
                    {
                        geoCharacter.MoveTo(inputLatLon);
                    }
                }
            }

            if ((uAdventureRaycaster.Instance.Override == null || uAdventureRaycaster.Instance.Override == gameObject) && Input.touchCount >= 2)
            {
                var touch0 = Input.GetTouch(0);
                var touch1 = Input.GetTouch(1);
                if (!isPinching)
                {
                    isPinching = true;
                    uAdventureRaycaster.Instance.Override = this.gameObject;
                    startDist  = (touch1.position - touch0.position).sqrMagnitude;
                    startOrtho = LastOrthoSize;
                }

                if ((touch0.phase == TouchPhase.Moved || touch0.phase == TouchPhase.Stationary) &&
                    (touch1.phase == TouchPhase.Moved || touch1.phase == TouchPhase.Stationary))
                {
                    var currentDist = (touch1.position - touch0.position).sqrMagnitude;
                    var distGrowth  = startDist / currentDist;
                    var ortho       = startOrtho * distGrowth;
                    LastOrthoSize = Mathf.Clamp(ortho, MinOrthoSize, MaxOrthoSize);
                }
            }
            else if (isPinching)
            {
                uAdventureRaycaster.Instance.Override = null;
                isPinching = false;
            }


            if ((uAdventureRaycaster.Instance.Override == null || uAdventureRaycaster.Instance.Override == gameObject) && Input.mouseScrollDelta.y != 0)
            {
                LastOrthoSize = Mathf.Clamp(LastOrthoSize - Input.mouseScrollDelta.y, MinOrthoSize, MaxOrthoSize);
            }

            if (InventoryManager.Instance.Opened)
            {
                Camera.main.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            else
            {
                mapScene.CameraType = CameraType.Ortographic3D;
                var distancePercentage            = (LastOrthoSize - MinOrthoSize) / (MaxOrthoSize - MinOrthoSize);
                var distancePercentageWithMinimum = distancePercentage * 0.65f + 0.35f; // Adjusted to a minimum distance of 30%

                switch (mapScene.CameraType)
                {
                case CameraType.Aerial2D:
                    Camera.main.orthographic       = true;
                    Camera.main.orthographicSize   = LastOrthoSize;
                    Camera.main.transform.position = character.transform.position + Vector3.up * 50;
                    Camera.main.transform.LookAt(character.transform.position);
                    break;

                case CameraType.Ortographic3D:
                    Camera.main.orthographic       = true;
                    Camera.main.orthographicSize   = LastOrthoSize;
                    Camera.main.transform.position = character.transform.position + Vector3.up * 50 + Vector3.back * 50 * (1 - distancePercentage);
                    Camera.main.transform.LookAt(character.transform.position);
                    break;

                case CameraType.Perspective3D:
                    Camera.main.orthographic       = false;
                    Camera.main.transform.position = character.transform.position + Vector3.up * 70 * distancePercentageWithMinimum + Vector3.back * 35 * (1 - distancePercentageWithMinimum);
                    Camera.main.transform.LookAt(character.transform.position);
                    break;

                default:
                    break;
                }
            }

            //            Debug.Log("LatLon: " + geoCharacter.LatLon + " LT->Meters->LT: " + GM.MetersToLatLon(GM.LatLonToMeters(geoCharacter.LatLon)));

            //geoCharacter.MoveTo(geoCharacter.LatLon + GM.MetersToLatLon(new Vector2d(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))));
            //geoCharacter.MoveTo(GM.MetersToLatLon(GM.LatLonToMeters(mapScene.LatLon.y, mapScene.LatLon.x) + new Vector2d(100, 100)));
            //geoCharacter.MoveTo(new Vector2d(-3.707398, 40.415363));
            //character.Move(new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical")), false, false);
        }
        protected void Update()
        {
            ready = true;
            if (GeoExtension.Instance.IsLocationValid())
            {
                var inputLatLon = GeoExtension.Instance.Location;
                if (GeoExtension.Instance.IsLocationValid() &&
                    (GM.LatLonToMeters(lastUpdatedPosition) - GM.LatLonToMeters(inputLatLon)).sqrMagnitude >= 1f)
                {
                    lastUpdatedPosition = inputLatLon;
                    if (GM.SeparationInMeters(geoCharacter.LatLon, inputLatLon) > 150)
                    {
                        geoCharacter.InstantMoveTo(inputLatLon);
                    }
                    else
                    {
                        geoCharacter.MoveTo(inputLatLon);
                    }
                }
            }

            if (InventoryManager.Instance.Opened)
            {
                Camera.main.transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            else
            {
                switch (mapScene.CameraType)
                {
                case CameraType.Aerial2D:
                    Camera.main.transform.position = character.transform.position + Vector3.up * 50;
                    Camera.main.transform.rotation = Quaternion.Euler(90, 0, 0);
                    break;

                case CameraType.Ortographic3D:
                    throw new System.NotImplementedException();

                case CameraType.Perspective3D:
                    throw new System.NotImplementedException();

                default:
                    break;
                }
            }

            //            Debug.Log("LatLon: " + geoCharacter.LatLon + " LT->Meters->LT: " + GM.MetersToLatLon(GM.LatLonToMeters(geoCharacter.LatLon)));

            //geoCharacter.MoveTo(geoCharacter.LatLon + GM.MetersToLatLon(new Vector2d(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))));
            //geoCharacter.MoveTo(GM.MetersToLatLon(GM.LatLonToMeters(mapScene.LatLon.y, mapScene.LatLon.x) + new Vector2d(100, 100)));
            //geoCharacter.MoveTo(new Vector2d(-3.707398, 40.415363));
            //character.Move(new Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical")), false, false);
            if ((uAdventureRaycaster.Instance.Override == null || uAdventureRaycaster.Instance.Override == gameObject) && Input.touchCount >= 2)
            {
                var touch0 = Input.GetTouch(0);
                var touch1 = Input.GetTouch(1);
                if (!isPinching)
                {
                    isPinching = true;
                    uAdventureRaycaster.Instance.Override = this.gameObject;
                    startDist  = (touch1.position - touch0.position).sqrMagnitude;
                    startOrtho = Camera.main.orthographicSize;
                }

                if ((touch0.phase == TouchPhase.Moved || touch0.phase == TouchPhase.Stationary) &&
                    (touch1.phase == TouchPhase.Moved || touch1.phase == TouchPhase.Stationary))
                {
                    var currentDist = (touch1.position - touch0.position).sqrMagnitude;
                    var distGrowth  = startDist / currentDist;
                    var ortho       = startOrtho * distGrowth;
                    Camera.main.orthographicSize = LastOrthoSize = Mathf.Clamp(ortho, MinOrthoSize, MaxOrthoSize);
                }
            }
            else if (isPinching)
            {
                uAdventureRaycaster.Instance.Override = null;
                isPinching = false;
            }
        }