예제 #1
0
        private WordAbstractBehaviour AssociateWordBehaviour(WordResult wordResult)
        {
            string text = wordResult.Word.StringValue.ToLowerInvariant();
            List <WordAbstractBehaviour> list;

            if (this.mWordBehaviours.ContainsKey(text))
            {
                list = this.mWordBehaviours[text];
            }
            else
            {
                if (!this.mWordBehaviours.ContainsKey("Template_ID"))
                {
                    Debug.Log("No prefab available for string value " + text);
                    return(null);
                }
                list = this.mWordBehaviours["Template_ID"];
            }
            foreach (WordAbstractBehaviour current in list)
            {
                if (current.Trackable == null)
                {
                    WordAbstractBehaviour result = this.AssociateWordBehaviour(wordResult, current);
                    return(result);
                }
            }
            if (list.Count < this.mMaxInstances)
            {
                WordAbstractBehaviour wordAbstractBehaviour = WordManagerImpl.InstantiateWordBehaviour(list.First <WordAbstractBehaviour>());
                list.Add(wordAbstractBehaviour);
                return(this.AssociateWordBehaviour(wordResult, wordAbstractBehaviour));
            }
            return(null);
        }
예제 #2
0
 private void AssociateWordResultsWithBehaviours()
 {
     foreach (Word current in new List <Word>(this.mWaitingQueue))
     {
         if (this.mTrackedWords.ContainsKey(current.ID))
         {
             WordResult wordResult = this.mTrackedWords[current.ID];
             if (this.AssociateWordBehaviour(wordResult) != null)
             {
                 this.mWaitingQueue.Remove(current);
             }
         }
         else
         {
             this.mWaitingQueue.Remove(current);
         }
     }
     foreach (WordResult current2 in this.mNewWords)
     {
         if (this.AssociateWordBehaviour(current2) == null)
         {
             this.mWaitingQueue.Add(current2.Word);
         }
     }
 }
예제 #3
0
        private WordAbstractBehaviour AssociateWordBehaviour(WordResult wordResult, WordAbstractBehaviour wordBehaviourTemplate)
        {
            if (this.mActiveWordBehaviours.Count >= this.mMaxInstances)
            {
                return(null);
            }
            Word word = wordResult.Word;

            wordBehaviourTemplate.InitializeWord(word);
            this.mActiveWordBehaviours.Add(word.ID, wordBehaviourTemplate);
            return(wordBehaviourTemplate);
        }
예제 #4
0
 private void UpdateWordBehaviourPoses()
 {
     foreach (KeyValuePair <int, WordAbstractBehaviour> current in this.mActiveWordBehaviours)
     {
         if (this.mTrackedWords.ContainsKey(current.Key))
         {
             WordResult wordResult  = this.mTrackedWords[current.Key];
             Vector3    position    = wordResult.Position;
             Quaternion orientation = wordResult.Orientation;
             Vector2    size        = wordResult.Word.Size;
             current.Value.transform.rotation = orientation;
             Vector3 vector = current.Value.transform.rotation * new Vector3(-size.x * 0.5f, 0f, -size.y * 0.5f);
             current.Value.transform.position = position + vector;
             current.Value.OnTrackerUpdate(wordResult.CurrentStatus);
         }
     }
 }