Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (working)
        {
            // temporary
            localGui.addDebug("Test Location: " + Input.location.lastData.latitude + " " +
                              Input.location.lastData.longitude + " " +
                              Input.location.lastData.altitude);
            // end temporary

            // check to see if the location has changed since last Update
            if (lastLongitude != Input.location.lastData.longitude || lastLatitude != Input.location.lastData.latitude || lastAltitude != Input.location.lastData.altitude)
            {
                lastLongitude = Input.location.lastData.longitude;
                lastLatitude  = Input.location.lastData.latitude;
                lastAltitude  = Input.location.lastData.altitude;

                localGui.addDebug("Location Changed: " + lastLatitude + " " +
                                  lastLongitude + " " +
                                  lastAltitude);

                if (localGui.penDown)
                {
                    localGui.addDebug("New Location Recorded: " + lastLatitude + " " +
                                      lastLongitude + " " +
                                      lastAltitude);
                    // add new location (point) to NetworkHelper
                    mNetworkHelper.addPoint("" + localGui.strokeName, (long)Input.location.lastData.timestamp, lastLatitude, lastLongitude, lastAltitude);
                }
            }
        }
    }
Exemplo n.º 2
0
    // Use this for initialization
    IEnumerator Start()
    {
        local_gui      = GameObject.Find("myGUI").GetComponentInChildren <myGUIScript> ();
        network_helper = GameObject.Find("myNetworkHelper").GetComponentInChildren <myNetworkHelperScript> ();

        if (this.myGUISkin == null)
        {
            local_gui.addDebug("Please assign a GUIskin on the editor!");
            this.enabled = false;
            yield return(false);
        }

        if (!Input.location.isEnabledByUser)
        {
            local_gui.addDebug("User has not enabled Location");
            yield return(false);
        }

        Input.location.Start(1f, 1f);

        // Wait until service initializes
        int maxWait = 20;

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

            maxWait--;
        }

        // Service didn't initialize in 20 seconds
        if (maxWait < 1)
        {
            print("Timed out");
            yield return(false);
        }

        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            local_gui.addDebug("Unable to determine device location");
            return(false);
        }
        else
        {
            local_gui.addDebug("Location: " + Input.location.lastData.latitude + " " +
                               Input.location.lastData.longitude + " " +
                               (long)Input.location.lastData.timestamp);
            working = true;
        }
    }
Exemplo n.º 3
0
    // Use this for initialization
    IEnumerator Start()
    {
        local_gui = GameObject.Find ("myGUI").GetComponentInChildren<myGUIScript> ();
        network_helper = GameObject.Find ("myNetworkHelper").GetComponentInChildren<myNetworkHelperScript> ();

        if (this.myGUISkin == null) {
            local_gui.addDebug ("Please assign a GUIskin on the editor!");
            this.enabled = false;
            yield return false;
        }

        if (!Input.location.isEnabledByUser) {
            local_gui.addDebug ("User has not enabled Location");
            yield return false;
        }

        Input.location.Start (1f, 1f);

        // Wait until service initializes
        int maxWait = 20;
        while ((Input.location.status == LocationServiceStatus.Initializing) && (maxWait > 0)) {
            yield return new WaitForSeconds (1);
            maxWait--;
        }

        // Service didn't initialize in 20 seconds
        if (maxWait < 1) {
            print ("Timed out");
            yield return false;
        }

        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed) {
            local_gui.addDebug ("Unable to determine device location");
            return false;
        } else {
            local_gui.addDebug ("Location: " + Input.location.lastData.latitude + " " +
                                Input.location.lastData.longitude + " " +
                                (long)Input.location.lastData.timestamp);
            working = true;
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (working)
        {
            if (lastLongitude != Input.location.lastData.longitude || lastLatitude != Input.location.lastData.latitude || lastAltitude != Input.location.lastData.altitude)
            {
                lastLongitude = Input.location.lastData.longitude;
                lastLatitude  = Input.location.lastData.latitude;
                lastAltitude  = Input.location.lastData.altitude;

                local_gui.addDebug("Location Changed: " + lastLatitude + " " + lastLongitude + " " + lastAltitude);
            }
            if (local_gui.penDown)
            {
                //	local_gui.addDebug ("New Location Recorded: " + lastLatitude + " " +lastLongitude + " " + lastAltitude);
                network_helper.addPoint("" + local_gui.stroke_name, (long)Input.location.lastData.timestamp, lastLatitude, lastLongitude, lastAltitude);
            }
        }
    }