Beispiel #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);
        }
Beispiel #2
0
 public override void DestroyWordBehaviour(WordAbstractBehaviour behaviour, bool destroyGameObject = true)
 {
     string[] array = this.mWordBehaviours.Keys.ToArray <string>();
     for (int i = 0; i < array.Length; i++)
     {
         string key = array[i];
         if (this.mWordBehaviours[key].Contains(behaviour))
         {
             this.mWordBehaviours[key].Remove(behaviour);
             if (this.mWordBehaviours[key].Count == 0)
             {
                 this.mWordBehaviours.Remove(key);
             }
             if (destroyGameObject)
             {
                 UnityEngine.Object.Destroy(behaviour.gameObject);
                 this.mWordBehavioursMarkedForDeletion.Add(behaviour);
             }
             else
             {
                 behaviour.UnregisterTrackable();
             }
         }
     }
 }
Beispiel #3
0
        private static WordAbstractBehaviour CreateWordBehaviour()
        {
            GameObject            gameObject = new GameObject("Word-AutoTemplate");
            WordAbstractBehaviour arg_20_0   = BehaviourComponentFactory.Instance.AddWordBehaviour(gameObject);

            Debug.Log("Creating Word Behaviour");
            return(arg_20_0);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 private void UnregisterLostWords()
 {
     foreach (Word current in this.mLostWords)
     {
         if (this.mActiveWordBehaviours.ContainsKey(current.ID))
         {
             WordAbstractBehaviour expr_3A = this.mActiveWordBehaviours[current.ID];
             expr_3A.OnTrackerUpdate(TrackableBehaviour.Status.NOT_FOUND);
             expr_3A.UnregisterTrackable();
             this.mActiveWordBehaviours.Remove(current.ID);
         }
     }
 }
Beispiel #6
0
 internal void InitializeWordBehaviourTemplates()
 {
     if (this.mWordPrefabCreationMode == WordPrefabCreationMode.DUPLICATE)
     {
         List <WordAbstractBehaviour> list = this.mWordBehavioursMarkedForDeletion.ToList <WordAbstractBehaviour>();
         if (this.mAutomaticTemplate && this.mWordBehaviours.ContainsKey("Template_ID"))
         {
             foreach (WordAbstractBehaviour current in this.mWordBehaviours["Template_ID"])
             {
                 list.Add(current);
                 UnityEngine.Object.Destroy(current.gameObject);
             }
             this.mWordBehaviours.Remove("Template_ID");
         }
         WordAbstractBehaviour[] array = (WordAbstractBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(WordAbstractBehaviour));
         for (int i = 0; i < array.Length; i++)
         {
             WordAbstractBehaviour wordAbstractBehaviour = array[i];
             if (!list.Contains(wordAbstractBehaviour))
             {
                 string text = wordAbstractBehaviour.IsTemplateMode ? "Template_ID" : wordAbstractBehaviour.SpecificWord.ToLowerInvariant();
                 if (!this.mWordBehaviours.ContainsKey(text))
                 {
                     this.mWordBehaviours[text] = new List <WordAbstractBehaviour>
                     {
                         wordAbstractBehaviour
                     };
                     if (text == "Template_ID")
                     {
                         this.mAutomaticTemplate = false;
                     }
                 }
             }
         }
         if (!this.mWordBehaviours.ContainsKey("Template_ID"))
         {
             WordAbstractBehaviour item = WordManagerImpl.CreateWordBehaviour();
             this.mWordBehaviours.Add("Template_ID", new List <WordAbstractBehaviour>
             {
                 item
             });
             this.mAutomaticTemplate = true;
         }
     }
     this.mWordBehavioursMarkedForDeletion.Clear();
 }
 private void UpdateTrackablesEditor()
 {
     TrackableBehaviour[] array = (TrackableBehaviour[])UnityEngine.Object.FindObjectsOfType(typeof(TrackableBehaviour));
     for (int i = 0; i < array.Length; i++)
     {
         TrackableBehaviour trackableBehaviour = array[i];
         if (trackableBehaviour.enabled)
         {
             if (trackableBehaviour is WordAbstractBehaviour)
             {
                 WordAbstractBehaviour wordAbstractBehaviour = (WordAbstractBehaviour)trackableBehaviour;
                 string text = wordAbstractBehaviour.IsSpecificWordMode ? wordAbstractBehaviour.SpecificWord : "AnyWord";
                 wordAbstractBehaviour.InitializeWord(new WordImpl(0, text, new Vector2(500f, 100f)));
             }
             trackableBehaviour.OnTrackerUpdate(TrackableBehaviour.Status.TRACKED);
         }
     }
 }
 public abstract void DestroyWordBehaviour(WordAbstractBehaviour behaviour, bool destroyGameObject = true);
 public abstract bool TryGetWordBehaviour(Word word, out WordAbstractBehaviour behaviour);
Beispiel #10
0
 public override bool TryGetWordBehaviour(Word word, out WordAbstractBehaviour behaviour)
 {
     return(this.mActiveWordBehaviours.TryGetValue(word.ID, out behaviour));
 }
Beispiel #11
0
 private static WordAbstractBehaviour InstantiateWordBehaviour(WordAbstractBehaviour input)
 {
     return(UnityEngine.Object.Instantiate <GameObject>(input.gameObject).GetComponent <WordAbstractBehaviour>());
 }