Exemple #1
0
    void UpdateMessageObjects()
    {
        // add new icons and move all icons if user position has changed

        Dictionary <string, List <long> > updates = UpdateNearbyMessages(distThreshold);

        ClearMessageObjects(updates["remove"]);

        // add icons for new messages within range
        //this.transform.Find("helperText").GetComponent<TextMesh>().text = "" + messages.Count;
        //print("add: " + updates["add"].Count + " remove: " + updates["remove"].Count);
        foreach (long mid in updates["add"])
        {
            print("adding message ball with id " + mid);
            // set location of icon to be the difference between the user and the message's 3-d location
            messageBalls[mid] = Instantiate(metalBall, messages[mid].getLoc().diff(loc_origin), Quaternion.AngleAxis(180, Vector3.up));

            // attache the message info to the icon
            messageBalls[mid].AddComponent <Message>();
            messageBalls[mid].GetComponent <Message>().message = messages[mid].getMessage();
            messageBalls[mid].GetComponent <Message>().id      = mid;
        }

        // move all icons if user location changed since last update
        if (!last_loc.equals(loc_origin))
        {
            foreach (long mid in messageBalls.Keys)
            {
                messageBalls[mid].transform.position = messages[mid].getLoc().diff(loc_origin);
            }
            last_loc = loc_origin.copy();
        }

        updateLock = false;
    }
Exemple #2
0
    private OLocation loc_origin; // current user location

    // Use this for initialization
    void Start()
    {
        // load with initialized location
        // for demo purposes, use dummy locations
        loc_origin = new OLocation(1, 1, 10);
        last_loc   = loc_origin.copy();

        // initialize empty dicts of messages, icons
        messages     = new Dictionary <long, Message>();
        messageBalls = new Dictionary <long, GameObject>();

        // hide the UI overlay
        uiCanvasGroup.alpha          = 0f;
        uiCanvasGroup.blocksRaycasts = false;

        //InvokeRepeating("UpdateLocation", 0, LOC_UPDATE_DELAY);
    }