Ejemplo n.º 1
0
    // Start is called before the first frame update
    IEnumerator Start()
    {
        while (true)
        {
            this.Status = Input.location.status;
            if (Input.location.isEnabledByUser)
            {
                switch (this.Status)
                {
                case LocationServiceStatus.Stopped:
                    Input.location.Start();
                    break;

                case LocationServiceStatus.Running:
                    this.Location = Input.location.lastData;
                    break;

                default:
                    break;
                }
            }
            else
            {
                Debug.Log("location is disabled by user");
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator Start()
    {
        while (true)
        {
            this.Status = Input.location.status;
            if (Input.location.isEnabledByUser)
            {
                switch (this.Status)
                {
                case LocationServiceStatus.Stopped:
                    Input.location.Start();
                    break;

                case LocationServiceStatus.Running:
                    this.Location = Input.location.lastData;
                    break;

                default:
                    break;
                }
            }
            else
            {
                // FIXME 位置情報を有効にして!! 的なダイアログの表示処理を入れると良さそう
                Debug.Log("location is disabled by user");
            }

            // 指定した秒数後に再度判定を走らせる
            yield return(new WaitForSeconds(IntervalSeconds));
        }
    }
Ejemplo n.º 3
0
//	public UILabel problem;

	// Use this for initialization
	void Start () {
		Input.location.Start (); //enable location settings
		Input.compass.enabled = true;
		locationStatus = Input.location.status;

		startLocationService(); //begin GPS transmittion
	}
Ejemplo n.º 4
0
        private LocationServiceStatusExt getRealStatus()
        {
            LocationServiceStatus    realStatus = realLocation.status;
            LocationServiceStatusExt stats      = LocationServiceStatusExt.Stopped;

            if (realStatus == LocationServiceStatus.Stopped)
            {
                stats = LocationServiceStatusExt.Stopped;
            }

            if (realStatus == LocationServiceStatus.Initializing)
            {
                stats = LocationServiceStatusExt.Initializing;
            }

            if (realStatus == LocationServiceStatus.Running)
            {
                stats = LocationServiceStatusExt.Running;
            }

            if (realStatus == LocationServiceStatus.Failed)
            {
                stats = LocationServiceStatusExt.Failed;
            }

            return(stats);
        }
Ejemplo n.º 5
0
    private void UpdateGPS()
    {
        if (Input.location.status == LocationServiceStatus.Running)
        {
            if (!_isGPSPaused)
            {
                var latitude  = Input.location.lastData.latitude;
                var longitude = Input.location.lastData.longitude;
                var altitude  = Input.location.lastData.altitude;
                position = new Vector3(latitude, altitude, longitude);
            }

            if (!_isCompassPaused)
            {
                var hAcc = Input.location.lastData.horizontalAccuracy;
                var vAcc = Input.location.lastData.verticalAccuracy;
                positionAccuracy = new Vector3(hAcc, vAcc, hAcc);
                heading          = Input.compass.trueHeading;
                headingAccuracy  = Input.compass.headingAccuracy;
            }

            ServiceStatus = Input.location.status;

            Debug.Log(string.Format("Lat: {0} Long: {1} Alt: {2}\nDir: {3}", position.x, position.z, position.y, heading));

            if (TextDisplay)
            {
                TextDisplay.text = string.Format("Lat: {0} Long: {1} Alt: {2}\nDir: {3}", position.x, position.z, position.y, heading);
            }
        }
        else
        {
            Debug.Log("GPS is " + Input.location.status);
        }
    }
    void Update()
    {
        Text text = GetComponent <Text> ();
        LocationServiceStatus status = Input.location.status;

        text.text = "Location services: " + status;
    }
Ejemplo n.º 7
0
    /// <summary>経緯度取得処理</summary>
    /// <returns>一定期間毎に非同期実行するための戻り値</returns>
    private IEnumerator Start()
    {
        while (true)
        {
            locationServiceStatus = Input.location.status;
            if (Input.location.isEnabledByUser)
            {
                switch (locationServiceStatus)
                {
                case LocationServiceStatus.Stopped:
                    Input.location.Start();
                    break;

                case LocationServiceStatus.Running:
                    Longitude = Input.location.lastData.longitude;
                    Latitude  = Input.location.lastData.latitude;
                    break;

                default:
                    break;
                }
            }

            yield return(new WaitForSeconds(IntervalSeconds));
        }
    }
        void GPSLocationCheck()
        {
            status = Input.location.status;

            if (!useLocationServices)
            {
                if (Application.isEditor && useBannerInsideEditor)
                {
                    showBannerWithText(true, "GPS is disabled");
                }
            }
            else if (status == LocationServiceStatus.Failed)
            {
                showBannerWithText(true, "GPS signal not found");
            }
            else if (status == LocationServiceStatus.Stopped)
            {
                showBannerWithText(true, "GPS signal not found");
            }
            else if (status == LocationServiceStatus.Initializing)
            {
                showBannerWithText(true, "Waiting for GPS signal");
            }
            else if (status == LocationServiceStatus.Running)
            {
                if (Input.location.lastData.horizontalAccuracy > desiredAccuracy)
                {
                    showBannerWithText(true, "GPS signal is weak");
                }
                else
                {
                    showBannerWithText(false, "GPS signal ok!");

                    if (!IsOriginSet)
                    {
                        SetOrigin(new Coordinates(Input.location.lastData));
                    }
                    LocationInfo info = Input.location.lastData;
                    if (info.latitude != currentLocation.latitude || info.longitude != currentLocation.longitude)
                    {
                        currentLocation.updateLocation(Input.location.lastData);
                        if (onLocationChanged != null)
                        {
                            onLocationChanged.Invoke(currentLocation);
                        }
                    }
                    CheckMotionState(new Coordinates(Input.location.lastData));
                }
            }

            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                changeLocationWASD();
            }
            if (!useLocationServices && (Application.isEditor || Application.platform == RuntimePlatform.WindowsPlayer) && demoLocation != DemoLocation.NoGPSTest && demoLocation != DemoLocation.SearchMode && !GOUtils.IsPointerOverUI() && motionMode != MotionMode.Avatar)
            {
                changeLocationWASD();
            }
        }
Ejemplo n.º 9
0
 public static void Start()
 {
     if (state == LocationServiceStatus.Stopped)
     {
         time  = Time.realtimeSinceStartup + 3;
         state = LocationServiceStatus.Initializing;
     }
 }
Ejemplo n.º 10
0
    static int IntToEnum(IntPtr L)
    {
        int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        LocationServiceStatus o = (LocationServiceStatus)arg0;

        LuaScriptMgr.PushEnum(L, o);
        return(1);
    }
Ejemplo n.º 11
0
	private void startLocationService() {
		Input.location.Start (accuracy, distance);

		while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) {
			maxWait--;
			locationStatus = Input.location.status;
		}
	}
Ejemplo n.º 12
0
    IEnumerator Start()
    {
        while (true)
        {
            this.Status = Input.location.status;
            if (Input.location.isEnabledByUser)
            {
                switch (this.Status)
                {
                case LocationServiceStatus.Stopped:
                    Input.location.Start();
                    break;

                case LocationServiceStatus.Running:
                    this.Location = Input.location.lastData;
                    break;

                default:
                    break;
                }
            }
            else
            {
                Debug.Log("location is disabled by user");
            }

            lat1       = Location.latitude;
            lon1       = Location.longitude;
            timestamp1 = Location.timestamp;

            lat1 *= RAD;
            lon1 *= RAD;
            lat2 *= RAD;
            lon2 *= RAD;

            lat_c = (lat1 + lat2) / 2;
            dx    = R_EARTH * (lon2 - lon1) * Mathf.Cos(lat_c);
            dy    = R_EARTH * (lat2 - lat1);

            distance = Mathf.Sqrt(dx * dx + dy * dy);
            time     = timestamp1 - timestamp2;
            if (time == 0)
            {
                speed = 0;
            }
            else
            {
                speed = distance / (float)time;
            }
            lat2       = Location.latitude;
            lon2       = Location.longitude;
            timestamp2 = Location.timestamp;


            // 指定した秒数後に再度判定を走らせる
            yield return(new WaitForSeconds(IntervalSeconds));
        }
    }
Ejemplo n.º 13
0
    void Update()
    {
        mockLongitude -= Input.GetAxis("Horizontal") * speed;
        mockLatitude  -= Input.GetAxis("Vertical") * speed;

        _mockStatus    = mockStatus;
        _mockLatitude  = mockLatitude;
        _mockLongitude = mockLongitude;
    }
Ejemplo n.º 14
0
    IEnumerator startLocationService()
    {
        Input.location.Start(accuracy, distance);

        while(Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return (new WaitForSeconds(1));
            maxWait--;
            locationStatus = Input.location.status;
        }
    }
Ejemplo n.º 15
0
 void Start()
 {
     gravity = new Gravity (Application.dataPath+"/Resources/Dg01_cnt2.5x2.bytes");
     Input.location.Start();           //enable location settings
     Input.compass.enabled = true;
     locationStatus = LocationServiceStatus.Running;
     lon = 0; alt = 0; lat = 0;
     dlon = 0; dalt = 0; dlat = 0;
     gAn=gravity.GetGravity(lat,lon,alt);
     gAcc = gravity.GetAcceleration (gAn);
     startLocationService();               //begin GPS transmittion
 }
Ejemplo n.º 16
0
 // Update is called once per frame
 void Update()
 {
     if (Input.location.status != _lastStatus)
     {
         _lastStatus = Input.location.status;
         if (_lastStatus == LocationServiceStatus.Running)
         {
             Debug.Log("Setting location lat: " + Input.location.lastData.latitude + " long: " + Input.location.lastData.longitude);
             Localytics.SetLocation(Input.location.lastData);
         }
     }
 }
Ejemplo n.º 17
0
    private IEnumerator StartLocationService()
    {
        ServiceStatus = LocationServiceStatus.Initializing;
        // Allow a fake location to be returned when testing on a device that doesn't have GPS
        if (UseFakeLocation)
        {
            Debug.Log(string.Format("Using fake GPS location lat:{0} lon:{1}", latitude, longitude));
            ServiceStatus = LocationServiceStatus.Running;
            yield break;
        }

        if (!Input.location.isEnabledByUser)
        {
            Debug.Log("user has not enabled gps");
            yield break;
        }

        // Wait for the GPS to start up so there's time to connect
        Input.location.Start();

        yield return(new WaitForSeconds(5));

        int maxWait = 20;

        while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return(new WaitForSeconds(1));

            maxWait--;
        }

        if (maxWait <= 0)
        {
            Debug.Log("Timed Out");
            yield break;
        }

        // If gps hasn't started by now, just give up
        ServiceStatus = Input.location.status;
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            Debug.Log("Unable to determine device location");
            yield break;
        }

        //Loop forever to get GPS updates
        while (isRunning)
        {
            yield return(new WaitForSeconds(2));

            UpdateGPS();
        }
    }
Ejemplo n.º 18
0
    private IEnumerator StartLocationService()
    {
        isReady       = false;
        ServiceStatus = LocationServiceStatus.Initializing;

        Input.compass.enabled = true;

        yield return(new WaitForSeconds(1));

        if (!Input.location.isEnabledByUser)
        {
            Debug.Log("user has not enabled gps");
            yield break;
        }

        // Wait for the GPS to start up so there's time to connect
        Input.location.Start();

        yield return(new WaitForSeconds(1));

        int maxWait = 20;

        while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return(new WaitForSeconds(1));

            maxWait--;
        }

        if (maxWait <= 0)
        {
            Debug.Log("Timed Out");
            yield break;
        }

        // If gps hasn't started by now, just give up
        ServiceStatus = Input.location.status;
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            Debug.Log("Unable to determine device location");
            yield break;
        }

        //Loop forever to get GPS updates
        while (isRunning)
        {
            yield return(new WaitForSeconds(0.5f));

            UpdateGPS();
        }
    }
Ejemplo n.º 19
0
    // Update is called once per frame
    void Update()
    {
        if (this.enableTracking)
        {
            if (Time.time - this.lastLocationCheck > kLocationCheckInterval)
            {
                this.lastLocationCheck = Time.time;

                this.locationCheckCount++;

                LocationServiceStatus status = Input.location.status;

                                #if UNITY_EDITOR
                if (this.locationCheckCount > 2)
                {
                    status = LocationServiceStatus.Running;
                }
                                #endif

                string textLabelText = "Status: " + status.ToString() + " c:" + this.locationCheckCount;

                if (status == LocationServiceStatus.Stopped)
                {
                    Input.location.Start(1, 1);
                }
                else if (status == LocationServiceStatus.Running)
                {
                    LocationInfo locInfo = Input.location.lastData;

                    textLabelText += "\nAccuracy: " + locInfo.horizontalAccuracy.ToString("F1") + " x " + locInfo.verticalAccuracy.ToString("F1");

                    this.storedLocationInfos.Add(locInfo);
                }

                for (int i = 0; i < 5; i++)
                {
                    int index = this.storedLocationInfos.Count - i - 1;

                    if (index > 0)
                    {
                        LocationInfo locInfo = this.storedLocationInfos[i];

                        textLabelText += "\ni: " + index + " {" + locInfo.latitude.ToString("F3") + "," + locInfo.longitude.ToString("F3") + "} acc: " + locInfo.horizontalAccuracy.ToString("F1") + " x " + locInfo.verticalAccuracy.ToString("F1");
                    }
                }

                this.outputText.text = textLabelText;
            }
        }
    }
Ejemplo n.º 20
0
    private void UpdateGPS()
    {
        if (Input.location.status == LocationServiceStatus.Running)
        {
            latitude      = Input.location.lastData.latitude;
            longitude     = Input.location.lastData.longitude;
            ServiceStatus = Input.location.status;

            Debug.Log(string.Format("Lat: {0} Long: {1}", latitude, longitude));
        }
        else
        {
            Debug.Log("GPS is " + Input.location.status);
        }
    }
Ejemplo n.º 21
0
 public override void Start()
 {
     if (MockLocation != null)
     {
         _running = true;
         base.Start();
     }
     else
     {
         _coroutine.RunOnce("location_service_start", LocationServiceStarter.Start(() =>
         {
             //setup a coroutine which will just copy data to this object so the thread actually can take it and send to matchmore
             _coroutine.SetupContinuousRoutine("data_update", () =>
             {
                 _status       = Input.location.status;
                 _locationInfo = Input.location.lastData;
             });
             _running = true;
             base.Start();
         }));
     }
 }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        if (Application.platform == RuntimePlatform.Android)
        {
            /*
             * double latitude = locationManager.GetLatitude();
             * double longitude = locationManager.GetLongitude();
             *
             * if (latitude != 0 && longitude != 0)
             * {
             *  transform.position = beaconManager.GetPosition(latitude, longitude);
             * }*/

            LocationServiceStatus status = iPhoneSettings.locationServiceStatus;

            if (status != LocationServiceStatus.Running)
            {
                if (prevStatus != status)
                {
                    Debug.Log("Location Status: " + status.ToString());
                    prevStatus = status;
                }
            }
            else
            {
                LocationInfo loc = iPhoneInput.lastLocation;

                if (prevLocation.latitude != loc.longitude || prevLocation.longitude != loc.longitude)
                {
                    Debug.Log("Location: " + loc.latitude.ToString() + ", " + loc.longitude.ToString());
                    prevLocation = loc;
                }

                Vector3 position = beaconManager.GetPosition(loc.latitude, loc.longitude);
                transform.position = new Vector3(position.x, transform.position.y, position.z);
            }
        }
    }
Ejemplo n.º 23
0
    public override void Update()
    {
        /*
         * double latitude = locationManager.GetLatitude();
         * double longitude = locationManager.GetLongitude();
         *
         * if (latitude != 0 && longitude != 0)
         * {
         * transform.position = beaconManager.GetPosition(latitude, longitude);
         * }*/

        LocationServiceStatus status = iPhoneSettings.locationServiceStatus;

        if (status != LocationServiceStatus.Running)
        {
            if (prevStatus != status)
            {
                Debug.Log("Location Status: " + status.ToString());
                prevStatus = status;
            }
            absolutePosition = null;
        }
        else
        {
            LocationInfo loc = iPhoneInput.lastLocation;

            if (prevLocation.latitude != loc.longitude || prevLocation.longitude != loc.longitude)
            {
                Debug.Log("Location: " + loc.latitude.ToString() + ", " + loc.longitude.ToString());
                prevLocation = loc;
            }

            absolutePosition = beaconManager.GetPosition(loc.latitude, loc.longitude);
            absolutePosition = new Vector3(absolutePosition.Value.x, playerManager.transform.position.y, absolutePosition.Value.z);
        }

        base.Update();
    }
Ejemplo n.º 24
0
        /// <summary>経緯度取得処理</summary>
        /// <returns>一定期間毎に非同期実行するための戻り値</returns>
        private IEnumerator Start()
        {
            while (true)
            {
                locationServiceStatus = Input.location.status;
                if (Input.location.isEnabledByUser)
                {
                    switch (locationServiceStatus)
                    {
                    case LocationServiceStatus.Stopped:
                        Input.location.Start();
                        break;

                    case LocationServiceStatus.Running:
                        //beforeLat = Latitude;
                        //beforeLng = Longitude;
                        Longitude = Input.location.lastData.longitude;
                        Latitude  = Input.location.lastData.latitude;
                        MapSceneManager.State.IsLoadStartLoacation = true;
                        break;

                    default:
                        break;
                    }
                }
                yield return(null);
                //if(beforeLat != Latitude || beforeLng != Longitude)
                //{
                //    MapSceneManager.Player.OnRunMotion();
                //}
                //else
                //{
                //    MapSceneManager.Player.OffRunMotion();
                //}
                //yield return new WaitForSeconds(IntervalSeconds);
            }
        }
Ejemplo n.º 25
0
    private void UpdateGPS()
    {
        if (Input.location.status == LocationServiceStatus.Running)
        {
            latitude  = Input.location.lastData.latitude.ToString();
            longitude = Input.location.lastData.longitude.ToString();

            heading         = Input.compass.trueHeading;
            headingAccuracy = Input.compass.headingAccuracy;
            ServiceStatus   = Input.location.status;

            headingVector = Input.compass.rawVector;

            //Debug.Log(string.Format("Lat: {0} Long: {1} Heading: {2} HeadingAccuracy : {3} HeadingVector3 : {4}" , latitude, longitude, heading, headingAccuracy, headingVector));
            if (!isReady)
            {
                isReady = true;
            }
        }
        else
        {
            Debug.Log("GPS is " + Input.location.status);
        }
    }
Ejemplo n.º 26
0
    /// =======================================================================
    /// 起動スクリプト
    /// =======================================================================
    IEnumerator Start()
    {
        // 使う前に setlabel を呼んどく。
        DialogManager.Instance.SetLabel("OK", "No", "Close");

        while (true)
        {
            this.Status = Input.location.status;

            if (Input.location.isEnabledByUser)
            {
                switch (this.Status)
                {
                case LocationServiceStatus.Stopped:
                    Input.location.Start();
                    break;

                case LocationServiceStatus.Running:
                    this.Location = Input.location.lastData;
                    break;

                default:
                    break;
                }
            }
            else
            {
                // 位置情報を有効にするようにユーザーへ要求
                ShowDialog_gps();
                gIsDialog = true;
            }

            // 指定した秒数後に再度判定を走らせる
            yield return(new WaitForSeconds(IntervalSeconds));
        }
    }
Ejemplo n.º 27
0
        IEnumerator LocationCheck(float repeatTime)
        {
            while (true)
            {
                status = Input.location.status;

                if (!useLocationServices)
                {
                    if (Application.isEditor && useBannerInsideEditor)
                    {
                        showBannerWithText(true, "GPS is disabled");
                    }
                    yield return(new WaitForSeconds(repeatTime));
                }
                else if (status == LocationServiceStatus.Failed)
                {
                    showBannerWithText(true, "GPS signal not found");
                    yield return(new WaitForSeconds(repeatTime));
                }
                else if (status == LocationServiceStatus.Stopped)
                {
                    showBannerWithText(true, "GPS signal not found");
                    yield return(new WaitForSeconds(repeatTime));
                }
                else if (status == LocationServiceStatus.Initializing)
                {
                    showBannerWithText(true, "GPS signal not found");
                    yield return(new WaitForSeconds(repeatTime));
                }
                else if (status == LocationServiceStatus.Running)
                {
                    if (Input.location.lastData.horizontalAccuracy > desiredAccuracy)
                    {
                        showBannerWithText(true, "GPS signal is weak");
                        yield return(new WaitForSeconds(repeatTime));
                    }
                    else
                    {
                        showBannerWithText(false, "GPS signal ok!");

                        if (!IsOriginSet)
                        {
                            SetOrigin(new Coordinates(Input.location.lastData));
                        }
                        LocationInfo info = Input.location.lastData;
                        if (info.latitude != currentLocation.latitude || info.longitude != currentLocation.longitude)
                        {
                            currentLocation.updateLocation(Input.location.lastData);
                            if (onLocationChanged != null)
                            {
                                onLocationChanged(currentLocation);
                            }
                        }
                    }
                }

                if (!useLocationServices && Application.isEditor && demoLocation != DemoLocation.NoGPSTest)
                {
                    changeLocationWASD();
                }

                yield return(new WaitForSeconds(repeatTime));
            }
        }
Ejemplo n.º 28
0
    private IEnumerator StartLocationService()
    {
        ServiceStatus = LocationServiceStatus.Initializing;
        if (UseFakeLocation)
        {
            Debug.Log(string.Format("Using fake GPS location lat:{0} lon:{1} height:{2}", position.x, position.y, position.y));
            ServiceStatus = LocationServiceStatus.Running;
            yield break;
        }

        Input.compass.enabled = true;

        yield return(new WaitForSeconds(5));

        if (!Input.location.isEnabledByUser)
        {
            Debug.Log("user has not enabled gps");
            yield break;
        }

        Input.location.Start();

        yield return(new WaitForSeconds(5));

        int maxWait = 20;

        while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return(new WaitForSeconds(1));

            maxWait--;
        }

        if (maxWait <= 0)
        {
            Debug.Log("Timed Out");
            yield break;
        }

        ServiceStatus = Input.location.status;
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            Debug.Log("Unable to dtermine device location");
            yield break;
        }

        var latitude  = Input.location.lastData.latitude;
        var longitude = Input.location.lastData.longitude;
        var altitude  = Input.location.lastData.altitude;

        position = new Vector3(latitude, altitude, longitude);

        var hAcc = Input.location.lastData.horizontalAccuracy;
        var vAcc = Input.location.lastData.verticalAccuracy;

        positionAccuracy = new Vector3(hAcc, vAcc, hAcc);

        heading         = Input.compass.trueHeading;
        headingAccuracy = Input.compass.headingAccuracy;


        while (isRunning)
        {
            UpdateGPS();
            yield return(new WaitForSeconds(0.1f));
        }
    }
Ejemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        _textTouch1.text = Vector2.zero.ToString();
        _textTouch2.text = Vector2.zero.ToString();

        if (Config.UseDebugGPSPosition)
        {
            Config.CurrentGPSPosition = Config.DebugGPSPosition;

            SetDebugInfos("Debugging", Config.DebugGPSPosition.x.ToString(CultureInfo.InvariantCulture), Config.DebugGPSPosition.y.ToString(CultureInfo.InvariantCulture), Config.DebugGPSPosition.z.ToString(), "0", "1", "1");
            _tile = Config.WorldToTilePos(Config.DebugGPSPosition.x, Config.DebugGPSPosition.y, Config.Zoom);

            if (_initialize)
            {
                LoadMap();
            }
        }
        else
        {
            _locStatus = Input.location.status;
            _locInfo   = Input.location.lastData;

            Config.CurrentGPSPosition.x = _locInfo.longitude;
            Config.CurrentGPSPosition.y = _locInfo.latitude;

            SetDebugInfos(_locStatus, _locInfo);
            _tile = Config.WorldToTilePos(_locInfo.longitude, _locInfo.latitude, Config.Zoom);

            if (_locStatus == LocationServiceStatus.Running && _locInfo.horizontalAccuracy <= Config.MinGPSAcc && _locInfo.verticalAccuracy <= Config.MinGPSAcc && _fixTimer > 0 && !Config.GoodGPSFix)
            {
                _fixTimer -= Time.deltaTime;
            }
            else
            {
                _fixTimer = Config.TimeToGoodGPSFix;
            }

            _textTimer.text = _fixTimer.ToString(CultureInfo.InvariantCulture);

            if (_fixTimer < 0 && Config.GoodGPSFix == false)
            {
                Config.GoodGPSFix = true;
            }

            if (Config.GoodGPSFix && _initialize)
            {
                LoadMap();
            }
        }

        _textZoom.text  = Config.Zoom.ToString();
        _textTilex.text = _tile.x.ToString(CultureInfo.InvariantCulture);
        _textTiley.text = _tile.y.ToString(CultureInfo.InvariantCulture);
#if UNITY_EDITOR
        _cameraOffset.x = Mathf.Clamp(_cameraOffset.x - Input.GetAxis("Horizontal") * Time.deltaTime, -Config.MaxCameraOffset.x, Config.MaxCameraOffset.x);
        _cameraOffset.y = Mathf.Clamp(_cameraOffset.y + Input.GetAxis("Vertical") * Time.deltaTime, -Config.MaxCameraOffset.y, Config.MaxCameraOffset.y);
        Camera.main.transform.Rotate(Vector3.forward, Input.GetAxis("Rotation"));
#elif UNITY_ANDROID
        if (Input.touchCount == 1)
        {
            _textTouch1.text = Input.GetTouch(0).position.ToString();
            _cameraOffset.x  = Mathf.Clamp(_cameraOffset.x - Input.GetTouch(0).deltaPosition.x *Time.deltaTime, -Config.MaxCameraOffset.x, Config.MaxCameraOffset.x);
            _cameraOffset.y  = Mathf.Clamp(_cameraOffset.y + Input.GetTouch(0).deltaPosition.y *Time.deltaTime, -Config.MaxCameraOffset.y, Config.MaxCameraOffset.y);
        }

        if (Input.touchCount == 2)
        {
            var _newAngle = Vector2.Angle(Input.GetTouch(0).position, Input.GetTouch(1).position);
            _textTouch1.text = Input.GetTouch(0).position.ToString();
            _textTouch2.text = Input.GetTouch(1).position.ToString();


            _textTouchAngle.text = _angle.ToString(CultureInfo.InvariantCulture);
            if (_angle != 0)
            {
                Camera.main.transform.Rotate(Vector3.forward, _angle - _newAngle);
            }
            _angle = _newAngle;

            _textTouchAngle.text = _angle.ToString(CultureInfo.InvariantCulture);
        }
        else
        {
            _angle = 0;
        }
#endif

        if (_goMapRoot != null && Config.GoodGPSFix)
        {
            _goMapRoot.transform.position   = new Vector3((5 - 10 * (_tile.x - Mathf.FloorToInt(_tile.x)) - _cameraOffset.x), (-5 + 10 * (_tile.y - Mathf.FloorToInt(_tile.y)) + _cameraOffset.y), 0);
            _goPosMarker.transform.position = new Vector3(-_cameraOffset.x, _cameraOffset.y, 0);
        }
    }
Ejemplo n.º 30
0
 private void SetDebugInfos(LocationServiceStatus locStatus, LocationInfo locInfo)
 {
     SetDebugInfos(locStatus.ToString(), locInfo.latitude.ToString(CultureInfo.InvariantCulture), locInfo.longitude.ToString(CultureInfo.InvariantCulture), locInfo.altitude.ToString(CultureInfo.InvariantCulture),
                   UnixTimeStampToDateTime(locInfo.timestamp).ToString(CultureInfo.InvariantCulture), locInfo.horizontalAccuracy.ToString(CultureInfo.InvariantCulture), locInfo.verticalAccuracy.ToString(CultureInfo.InvariantCulture));
 }
Ejemplo n.º 31
0
 private void SetDebugInfos(LocationServiceStatus locStatus, LocationInfo locInfo)
 {
     SetDebugInfos(locStatus.ToString(), locInfo.latitude.ToString(CultureInfo.InvariantCulture), locInfo.longitude.ToString(CultureInfo.InvariantCulture), locInfo.altitude.ToString(CultureInfo.InvariantCulture),
         UnixTimeStampToDateTime(locInfo.timestamp).ToString(CultureInfo.InvariantCulture), locInfo.horizontalAccuracy.ToString(CultureInfo.InvariantCulture), locInfo.verticalAccuracy.ToString(CultureInfo.InvariantCulture));
 }
Ejemplo n.º 32
0
    // Update is called once per frame
    void Update()
    {
        _textTouch1.text = Vector2.zero.ToString();
        _textTouch2.text = Vector2.zero.ToString();

        if (Config.UseDebugGPSPosition)
        {
            Config.CurrentGPSPosition = Config.DebugGPSPosition;

            SetDebugInfos("Debugging", Config.DebugGPSPosition.x.ToString(CultureInfo.InvariantCulture), Config.DebugGPSPosition.y.ToString(CultureInfo.InvariantCulture), Config.DebugGPSPosition.z.ToString(), "0", "1", "1");
            _tile = Config.WorldToTilePos(Config.DebugGPSPosition.x, Config.DebugGPSPosition.y, Config.Zoom);

            if (_initialize)
            {
                LoadMap();
            }
        }
        else
        {
            _locStatus = Input.location.status;
            _locInfo = Input.location.lastData;

            Config.CurrentGPSPosition.x = _locInfo.longitude;
            Config.CurrentGPSPosition.y = _locInfo.latitude;

            SetDebugInfos(_locStatus, _locInfo);
            _tile = Config.WorldToTilePos(_locInfo.longitude, _locInfo.latitude, Config.Zoom);

            if (_locStatus == LocationServiceStatus.Running && _locInfo.horizontalAccuracy <= Config.MinGPSAcc && _locInfo.verticalAccuracy <= Config.MinGPSAcc && _fixTimer > 0 && !Config.GoodGPSFix)
            {
                _fixTimer -= Time.deltaTime;
            }
            else
            {
                _fixTimer = Config.TimeToGoodGPSFix;
            }

            _textTimer.text = _fixTimer.ToString(CultureInfo.InvariantCulture);

            if (_fixTimer < 0 && Config.GoodGPSFix == false)
            {
                Config.GoodGPSFix = true;
            }

            if (Config.GoodGPSFix && _initialize)
            {
                LoadMap();
            }
        }

        _textZoom.text = Config.Zoom.ToString();
        _textTilex.text = _tile.x.ToString(CultureInfo.InvariantCulture);
        _textTiley.text = _tile.y.ToString(CultureInfo.InvariantCulture);
        #if UNITY_EDITOR
        _cameraOffset.x = Mathf.Clamp(_cameraOffset.x - Input.GetAxis("Horizontal") * Time.deltaTime, -Config.MaxCameraOffset.x, Config.MaxCameraOffset.x);
        _cameraOffset.y = Mathf.Clamp(_cameraOffset.y + Input.GetAxis("Vertical") * Time.deltaTime, -Config.MaxCameraOffset.y, Config.MaxCameraOffset.y);
        Camera.main.transform.Rotate(Vector3.forward, Input.GetAxis("Rotation"));

        #elif UNITY_ANDROID
        if (Input.touchCount == 1)
        {
            _textTouch1.text = Input.GetTouch(0).position.ToString();
            _cameraOffset.x = Mathf.Clamp(_cameraOffset.x - Input.GetTouch(0).deltaPosition.x * Time.deltaTime, -Config.MaxCameraOffset.x, Config.MaxCameraOffset.x);
            _cameraOffset.y = Mathf.Clamp(_cameraOffset.y + Input.GetTouch(0).deltaPosition.y * Time.deltaTime, -Config.MaxCameraOffset.y, Config.MaxCameraOffset.y);
        }

        if (Input.touchCount == 2)
        {
            var _newAngle = Vector2.Angle(Input.GetTouch(0).position, Input.GetTouch(1).position);
            _textTouch1.text = Input.GetTouch(0).position.ToString();
            _textTouch2.text = Input.GetTouch(1).position.ToString();

            _textTouchAngle.text = _angle.ToString(CultureInfo.InvariantCulture);
            if (_angle != 0)
            {
                Camera.main.transform.Rotate(Vector3.forward, _angle - _newAngle);
            }
            _angle = _newAngle;

            _textTouchAngle.text = _angle.ToString(CultureInfo.InvariantCulture);
        }
        else
        {
            _angle = 0;
        }
        #endif

        if (_goMapRoot != null && Config.GoodGPSFix)
        {
            _goMapRoot.transform.position = new Vector3((5 - 10*(_tile.x - Mathf.FloorToInt(_tile.x)) - _cameraOffset.x), (-5 + 10*(_tile.y - Mathf.FloorToInt(_tile.y)) + _cameraOffset.y), 0);
            _goPosMarker.transform.position = new Vector3(-_cameraOffset.x, _cameraOffset.y, 0);
        }
    }
Ejemplo n.º 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocationServiceStatusChangedEventArgs"/> class.
 /// </summary>
 /// <param name="status">The updated status of the <see cref="ILocationService"/> object.</param>
 public LocationServiceStatusChangedEventArgs(LocationServiceStatus status)
 {
     Status = status;
 }
Ejemplo n.º 34
0
 // Update is called once per frame
 void Update()
 {
     if (Input.location.status != _lastStatus)
     {
         _lastStatus = Input.location.status;
         if (_lastStatus == LocationServiceStatus.Running)
         {
             Debug.Log ("Setting location lat: " + Input.location.lastData.latitude + " long: " + Input.location.lastData.longitude);
             Localytics.SetLocation(Input.location.lastData);
         }
     }
 }
    public override void Update()
    {
        /*
            double latitude = locationManager.GetLatitude();
            double longitude = locationManager.GetLongitude();

            if (latitude != 0 && longitude != 0)
            {
                transform.position = beaconManager.GetPosition(latitude, longitude);
            }*/

        LocationServiceStatus status = iPhoneSettings.locationServiceStatus;

        if (status != LocationServiceStatus.Running)
        {
            if (prevStatus != status)
            {
                Debug.Log("Location Status: " + status.ToString());
                prevStatus = status;
            }
            absolutePosition = null;
        }
        else
        {
            LocationInfo loc = iPhoneInput.lastLocation;

            if (prevLocation.latitude != loc.latitude || prevLocation.longitude != loc.longitude)
            {
                Debug.Log("Location: " + loc.latitude.ToString() + ", " + loc.longitude.ToString());
                prevLocation = loc;
            }

            absolutePosition = beaconManager.GetPosition(loc.latitude, loc.longitude);
            absolutePosition = new Vector3(absolutePosition.Value.x, playerManager.transform.position.y, absolutePosition.Value.z);
        }

        base.Update ();
    }
Ejemplo n.º 36
0
 public static void Stop()
 {
     state = LocationServiceStatus.Stopped;
 }
Ejemplo n.º 37
0
 void Update()
 {
     _mockStatus    = mockStatus;
     _mockLatitude  = mockLatitude;
     _mockLongitude = mockLongitude;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LocationServiceStatusChangedEventArgs"/> class.
 /// </summary>
 /// <param name="status">The updated status of the <see cref="ILocationService"/> object.</param>
 public LocationServiceStatusChangedEventArgs(LocationServiceStatus status)
 {
     Status = status;
 }
Ejemplo n.º 39
0
 private void Update()
 {
     service = Input.location.status;
 }
Ejemplo n.º 40
0
    // Use this for initialization
    void Start()
    {
        Localytics.LoggingEnabled = true;

        Localytics.RegisterForAnalyticsEvents();
        Localytics.RegisterForMessagingEvents();

        // This is just for testing purpose
        Localytics.UnregisterForAnalyticsEvents();
        Localytics.UnregisterForMessagingEvents();

        Localytics.RegisterForAnalyticsEvents();
        Localytics.RegisterForMessagingEvents();

        //Localytics.TestModeEnabled = true;
        Localytics.OnLocalyticsDidTagEvent += Localytics_OnLocalyticsDidTagEvent;
        Localytics.OnLocalyticsSessionWillOpen += Localytics_OnLocalyticsSessionWillOpen;
        Localytics.OnLocalyticsSessionDidOpen += Localytics_OnLocalyticsSessionDidOpen;
        Localytics.OnLocalyticsSessionWillClose += Localytics_OnLocalyticsSessionWillClose;

        Localytics.OnLocalyticsDidDismissInAppMessage += Localytics_OnLocalyticsDidDismissInAppMessage;
        Localytics.OnLocalyticsDidDisplayInAppMessage += Localytics_OnLocalyticsDidDisplayInAppMessage;
        Localytics.OnLocalyticsWillDismissInAppMessage += Localytics_OnLocalyticsWillDismissInAppMessage;
        Localytics.OnLocalyticsWillDisplayInAppMessage += Localytics_OnLocalyticsWillDisplayInAppMessage;
        Localytics.SessionTimeoutInterval = 15;

        _openSession.onClick.AddListener(() => { Localytics.OpenSession(); Localytics.Upload(); });
        _closeSession.onClick.AddListener(() => { Localytics.CloseSession(); Localytics.Upload(); });
        _tagEventClick.onClick.AddListener(() => { Localytics.TagEvent("click"); Localytics.Upload(); });
        _tagScreen1.onClick.AddListener(() => { Localytics.TagScreen("screen1"); Localytics.Upload(); });
        _tagScreen2.onClick.AddListener(() => { Localytics.TagScreen("screen2"); Localytics.Upload(); });

        Localytics.CustomerId = "user1";

        Localytics.SetIdentifier("test_identifier", "test setIdentifier");
        Localytics.GetIdentifier("test_identifier");

        Localytics.InAppMessageDismissButtonLocationEnum = Localytics.InAppMessageDismissButtonLocation.Right;

        Localytics.TriggerInAppMessage("Sample Startup", null);

        // to set a profile attribute:
        Localytics.SetProfileAttribute("Age", 45, Localytics.ProfileScope.Organization);
        Localytics.SetProfileAttribute("Lucky numbers", new long[] { 8, 13 }, Localytics.ProfileScope.Application);
        Localytics.SetProfileAttribute("Hometown", "New York, New York", Localytics.ProfileScope.Organization);
        Localytics.SetProfileAttribute("States visited", new String[] { "New York", "California", "South Dakota" }, Localytics.ProfileScope.Application);

        // to remove a profile attribute:
        Localytics.DeleteProfileAttribute("Days until graduation", Localytics.ProfileScope.Application);

        // to add a set of values to an already-defined set of values:
        Localytics.AddProfileAttributesToSet("Lucky numbers", new long[] { 666 }, Localytics.ProfileScope.Application);
        Localytics.AddProfileAttributesToSet("States visited", new String[] { "North Dakota" }, Localytics.ProfileScope.Application);

        // to remove a set of values from an already-defined set of values:
        Localytics.RemoveProfileAttributesFromSet("Lucky numbers", new long[] { 8, 666 }, Localytics.ProfileScope.Application);
        Localytics.RemoveProfileAttributesFromSet("States visited", new String[] { "California" }, Localytics.ProfileScope.Application);

        // to increment or decrement an already-defined value:
        Localytics.IncrementProfileAttribute("Age", 1, Localytics.ProfileScope.Organization);
        Localytics.DecrementProfileAttribute("Days until graduation", 3, Localytics.ProfileScope.Application);

        Localytics.SetCustomerEmail("Convenient Email");
        Localytics.SetCustomerFirstName("Convenient FirstName");
        Localytics.SetCustomerLastName("Convenient LastName");
        Localytics.SetCustomerFullName("Convenient Full Name");

        Localytics.SetCustomDimension(1,"testCD1");
        Localytics.GetCustomDimension(1);

        Localytics.Upload();

        Input.location.Start();
        _lastStatus = Input.location.status;

        UpdateLabels();
    }