示例#1
0
    void NoteUserCommunication(string key, DataStore.IValue value)
    {
        var comVal = value as CommunicationValue;

        if (comVal == null)
        {
            return;
        }

        // if we're standing by, then ignore anything that's not a direct address.
        if (DataStore.GetBoolValue("me:standingBy"))
        {
            if (!comVal.val.directAddress)
            {
                return;
            }
            DataStore.SetValue("me:standingBy", new DataStore.BoolValue(false), this, "noted direct address");
        }

        ComCommand cmd = comVal.val as ComCommand;

        if (cmd != null)
        {
            HandleCommand(cmd);
        }
    }
示例#2
0
    void NoteUserSpeech(string key, DataStore.IValue value)
    {
        string input = value.ToString().Trim();

        if (string.IsNullOrEmpty(input))
        {
            return;
        }

        // Initialize a parser with the raw input
        var        parser = new Parser();
        ParseState st     = parser.InitState(input);

        // Apply parsing rules until we can do no more
        int rule;

        while ((rule = parser.NextStep(st)) > 0)
        {
            //Print(st.ToString() + " {" + rule + "}");
        }
        SetValue("user:parse", st.TreeForm(), "parsed: " + input);

        // Now, attempt to grok the input (convert it to a Communication)
        Communication comm = Grok.GrokInput(input, st);

        SetValue("user:communication", new CommunicationValue(comm), comm.ToString());
    }
示例#3
0
 /// <summary>
 /// Set a value in the data store, and also update our module display (if any).
 /// </summary>
 /// <param name="key">Key of interest</param>
 /// <param name="value">Value to store</param>
 /// <param name="comment">Comment explaining the change</param>
 protected void SetValue(string key, DataStore.IValue value, string comment)
 {
     this.comment = comment;
     if (DataStore.SetValue(key, value, this, comment) && display != null)
     {
         display.ShowUpdate(key, value, comment);
     }
 }
示例#4
0
 public void ShowUpdate(string key, DataStore.IValue value, string comment)
 {
     if (key != null && value != null)
     {
         valueUpdateText.text = key + " := " + value.ToString();
     }
     commentText.text  = "\"" + comment + "\"";
     lastHighlightTime = Time.time;
 }
示例#5
0
    void NoteMeAttending(string key, DataStore.IValue value)
    {
        string attending = value.ToString();

        lookingAtUser = (attending == "user");
        if (lookingAtUser && !holdingEyesClosed)
        {
            targetOpenLevel = 0.7f;
        }
        UpdateDisplayComment();
    }
示例#6
0
 void NoteStandingBy(string key, DataStore.IValue value)
 {
     if ((value as DataStore.BoolValue).val)
     {
         mode = Mode.Disengaged;
     }
     else
     {
         mode   = Mode.Engaged;
         target = Camera.main.transform.position;
     }
 }
示例#7
0
 void NoteMeIntentEyesClosed(string key, DataStore.IValue value)
 {
     holdingEyesClosed = (value as DataStore.BoolValue).val;
     if (holdingEyesClosed)
     {
         targetOpenLevel = 0;
     }
     else
     {
         targetOpenLevel = 0.7f;
     }
     UpdateDisplayComment();
 }
示例#8
0
    void NoteSpeechIntent(string key, DataStore.IValue value)
    {
        var speech = value.ToString();

        if (string.IsNullOrEmpty(speech))
        {
            StopSpeaking();
        }
        else
        {
            Speak(speech);
        }
    }
示例#9
0
    void NoteUserSpeech(string key, DataStore.IValue value)
    {
        // Parse the user's speech.
        string speech = value.ToString();

        if (!string.IsNullOrEmpty(speech))
        {
            UpdateParse(speech);
        }
        else
        {
            SetValue("user:parse", "", "speech is empty");
        }
    }
示例#10
0
 void NoteLookOrPointAt(string key, DataStore.IValue value)
 {
     if (value.ToString() == "userPoint" && key == "me:intent:lookAt")
     {
         mode = Mode.Looking;
     }
     else if (value.ToString() == "userPoint" && key == "me:intent:pointAt")
     {
         mode = Mode.Pointing;
     }
     else if (mode != Mode.Off)
     {
         mode = Mode.Off;
         SetValue("me:intent:target", "", "mode := Mode.Off");
         SetValue("me:intent:action", "", "mode := Mode.Off");
     }
 }
示例#11
0
    void NotePointAt(string key, DataStore.IValue value)
    {
        string atWhat = value.ToString();

        if (string.IsNullOrEmpty(atWhat))
        {
            if (mode == Mode.LookingAtMyPoint)
            {
                mode   = Mode.Engaged;
                target = Camera.main.transform.position;
            }
        }
        else
        {
            mode = Mode.LookingAtMyPoint;
        }
    }
示例#12
0
    void NoteUserCommunication(string key, DataStore.IValue value)
    {
        var comVal = value as CommunicationValue;

        if (comVal == null)
        {
            return;
        }

        // if we're standing by, then ignore anything that's not a direct address.
        if (DataStore.GetBoolValue("me:standingBy"))
        {
            if (!comVal.val.directAddress)
            {
                return;
            }
            // Note that we do NOT change me:standingBy here.  That's the
            // responsibility of CommandsModule.  Doing it in both places
            // causes grief.
        }

        HandleInput(comVal.val);
    }
示例#13
0
    void NoteLookAt(string key, DataStore.IValue value)
    {
        string atWhat = value.ToString();

        if (atWhat == "userPoint")
        {
            mode = Mode.LookingAtUserPoint;
        }
        else if (atWhat == "user")
        {
            mode   = Mode.Engaged;
            target = Camera.main.transform.position;
        }
        else if (string.IsNullOrEmpty(atWhat))
        {
            // Nothing specific to look at; check attention.
            if (DataStore.GetStringValue("me:attending") == "user")
            {
                mode   = Mode.Engaged;
                target = Camera.main.transform.position;
            }
            else
            {
                mode   = Mode.Disengaged;
                target = idleGazePosition.position;
            }
        }
        else
        {
            Transform t = lookableObjects.Find(atWhat);
            if (t != null)
            {
                mode   = Mode.LookingAtObject;
                target = t.position;
            }
        }
    }
示例#14
0
    /// <summary>
    /// Handle a change in a DataStore value.  (This method is hooked up
    /// as a DataStore.onValueChanged receiver in the Start method above).
    /// </summary>
    /// <param name="key">key whose value has changed</param>
    private void ValueChanged(string key)
    {
        // Pass the change on to any subscribers.
        List <Client> clients;

        if (subscribersByKey.TryGetValue(key, out clients))
        {
            DataStore.IValue value = DataStore.GetValue(key);
            string           msg   = null;
            if (value is DataStore.IntValue)
            {
                msg = string.Format("SETI {0} {1}", key, ((DataStore.IntValue)value).val);
            }
            else if (value is DataStore.IntValue)
            {
                msg = string.Format("SETB {0} {1}", key, ((DataStore.BoolValue)value).val ? "T" : "F");
            }
            else if (value is DataStore.StringValue)
            {
                msg = string.Format("SETS {0} {1}", key, ((DataStore.StringValue)value).val);
            }
            else if (value is DataStore.Vector3Value)
            {
                Vector3 v = ((DataStore.Vector3Value)value).val;
                msg = string.Format("SETV {0} {1} {2} {3}", key, v.x, v.y, v.z);
            }
            if (msg == null)
            {
                return;
            }
            foreach (Client client in clients)
            {
                client.WriteLine(msg);
            }
        }
    }
示例#15
0
 void NoteChange(string key, DataStore.IValue value)
 {
     lastChangedKey   = key;
     lastChangedValue = value;
     changeCount++;
 }
示例#16
0
 void Handler(string key, DataStore.IValue value)
 {
     // May add some handler here for different settings.  Need to discuss.
 }
示例#17
0
 void NoteScreenOrDeskMode(string key, DataStore.IValue value)
 {
     // May add some handler here for different settings.  Need to discuss.
 }
示例#18
0
 public bool Equals(DataStore.IValue other)
 {
     return(other is CommunicationValue && val.Equals(((CommunicationValue)other).val));
 }
示例#19
0
 public bool Equals(DataStore.IValue other)
 {
     return(other is WordValue && val.Equals(((WordValue)other).val));
 }