Reset() public method

public Reset ( ) : void
return void
Example #1
0
        private void SwitchComponents(string command)
        {
            var gameObjectName = command.Replace("within", "").Trim();

            if (gameObjectName.EndsWith("."))
            {
                gameObjectName = gameObjectName.Substring(0, gameObjectName.Length - 1);
            }
            if (gameObjectName == "global")
            {
                gameObjectName = "GlobalKB";
            }
            var newGameObject = GameObject.Find(gameObjectName);

            if (newGameObject == null)
            {
                newGameObject = GameObject.Find(char.ToUpper(gameObjectName[0]) + gameObjectName.Substring(1));
            }
            if (newGameObject == null)
            {
                Output.WriteLine("No GameObject named {0}", gameObjectName);
                return;
            }
            var kb = newGameObject.GetComponent <KB>();

            if (kb == null)
            {
                Output.WriteLine("Cannot change GameObjects: {0} has no KB.", gameObjectName);
                return;
            }
            CurrentGameObject           = newGameObject;
            PrologContext.KnowledgeBase = kb.KnowledgeBase;
            PrologContext.Reset(CurrentGameObject);
            if (OnChangeKB != null)
            {
                OnChangeKB(kb.KnowledgeBase);
            }
            Output.WriteLine("Now using the KB of {0}", gameObjectName);
        }
Example #2
0
        private void SwitchComponents(string command)
        {
            var gameObjectName = command.Replace("within", "").Trim();

            if (gameObjectName == "global")
            {
                gameObjectName = "GlobalKB";
            }
            var newGameObject = GameObject.Find(gameObjectName);

            if (newGameObject == null)
            {
                newGameObject = GameObject.Find(char.ToUpper(gameObjectName[0]) + gameObjectName.Substring(1));
            }
            if (newGameObject == null)
            {
                Output.WriteLine("No GameObject named {0}", gameObjectName);
                return;
            }
            var kb = newGameObject.GetComponent <KB>();

            if (kb == null)
            {
                Output.WriteLine("Cannot change GameObjects: {0} has no KB.", gameObjectName);
                return;
            }
            CurrentGameObject           = newGameObject;
            PrologContext.KnowledgeBase = kb.KnowledgeBase;
            PrologContext.Reset(CurrentGameObject);
            var eli = UnityEngine.Object.FindObjectOfType <ELInspector>();

            if (eli != null)
            {
                eli.SetKB(kb.KnowledgeBase);
            }
            Output.WriteLine("Now using the KB of {0}", gameObjectName);
        }