/// <summary> /// Initializes a new instance of the <see cref="Chatbot.Trigger"/> class. /// </summary> /// <param name="Chatbot">Chatbot.</param> public void Initialize(GameObject tmpgameobj, Chatbot.Core tmpbot) { // Throw error if not attached to a Game Object if (tmpgameobj == null) { Debug.LogWarning("To use chatbot you need to attatch ChatbotCore.cs script to a GameObject and pass GameObject to Chatbot. GameObject is empty."); } // Get Chatbot.Core Instance this.bot = tmpbot; if (this.bot == null) { Debug.LogWarning("To use chatbot you need to attatch ChatbotCore.cs script to a GameObject and pass GameObject to Chatbot. GameObject is empty."); } // Create list of attatched triggers. Trigger[] AttatchedTriggers; // Get all Triggers attatched to the Chatbot Gameobject AttatchedTriggers = tmpgameobj.GetComponentsInChildren <Trigger>(); // Loop throug all Triggers foreach (Trigger tmpTrigger in AttatchedTriggers) { // And add them to the TriggerList AttatchedTrigger tmpTriggerItem = new AttatchedTrigger(); // Initialize AttatchedTrigger instance tmpTriggerItem.Initialize(this.bot, tmpTrigger); // And add tmpTriggerItem to TriggerList TriggerList.Add(tmpTriggerItem); } }
/// <summary> /// Initializes a new instance of the <see cref="Chatbot.Trigger"/> class. /// </summary> /// <param name="Chatbot">Chatbot.</param> public void Initialize(GameObject tmpbot, Chatbot.Core tmpbotcore, Chatbot.Motives tmpmotives) { // Get Chatbot.Core Instance this.bot = tmpbotcore; if (this.bot == null) { Debug.LogWarning("Chatbot.Core instance not passed"); } // Throw error if no chatbot gameobject attached if (tmpbot == null) { Debug.LogWarning("Chatbot Gameobject is not passed."); } // Throw error if no Chatbot.Motives instance attached if (tmpmotives == null) { Debug.LogWarning("Chatbot.Motives instance is not passed."); } // Retrieve Chatbot.Motives instance motives = tmpmotives; // Get planner GameObject planner = tmpbot.GetComponentInChildren <Planner>().gameObject; // Throw error if no planner attached if (planner == null) { Debug.LogWarning("To use chatbot you need to attatch Planner.cs script to the Planner GameObject and pass Planner GameObject to Chatbot. GameObject is empty."); } // No parent selected Parent = null; // Next motive should be selected SelectNextMotive = true; // Look for all motives without children OnlySelectChildren = false; }
/// <summary> /// Initializes the AttatchedTrigger instance. /// </summary> public void Initialize(Chatbot.Core tmpbot, Trigger tmpTrigger) { // Throw exception if tmpTrigger is not assigned if (tmpTrigger == null) { Debug.LogWarning("Trigger == null"); } // Register Trigger instance trigger = tmpTrigger; // Set last time active to now and // subtract timeoutintervall, to be able // to recieve trigger from helperfunction // immediately. timelastactive = System.DateTime.Now.Subtract(TimeSpan.FromMilliseconds(tmpTrigger.timeoutintervall)); // Check, wether bot exists if (tmpbot == null) { Debug.LogWarning("Passed Chatbot.Core instance == null"); } // Retrieve Chatbor.Core instance bot = tmpbot; // Settings resetted to default (code below) isresetted = true; //Check if there are assigned settings if (trigger.Settings != null) { // Settings string array should have same size // as Settings GameObject array. Settings = new string[trigger.Settings.Length]; // Set settings name and value to default for (int i = 0; i < Settings.Length; i++) { // First check if user already assigned Setting GameObject // and wether it has Setting instance attatched if (trigger.Settings[i] != null && trigger.Settings[i].gameObject.GetComponent <Setting>()) { // Retrieve settings name Settings[i] = trigger.Settings[i].gameObject.name; // And set settings value to defaultSetting bot.SetGlobalSetting(Settings[i], defaultSetting); // Also change Settings in Unity scene to default trigger.Settings[i].gameObject.GetComponent <Setting>().value = defaultSetting; } } } // Grab Trigger values from Scene RetrieveTriggerSettingsFromScene(); }
/// <summary> /// Initializes a new instance of the <see cref="Chatbot.Motives"/> class. /// </summary> /// <param name="Chatbot">Chatbot.</param> public void Initialize(GameObject tmpchatbot) { // Check wether Gameobject is availabe and // throw exception if null if (tmpchatbot == null) { Debug.LogWarning("No Gameobject passed."); } // Keep chatbot gameobject chatbot = tmpchatbot; bot = chatbot.GetComponent <ChatbotCore> ().bot; if (bot == null) { Debug.LogWarning("No Chatbot.Core instance passed."); } // Does AssignedMotives instance exist? if (chatbot.GetComponentInChildren <AssignedMotives> () != null) { // Search Gameobject with AssignedMotives Component assignedmotives = chatbot.GetComponentInChildren <AssignedMotives> ().gameObject; } else { Debug.LogWarning("There is no AssignedMotives Script attatched."); } // Temporary motive array Motive[] motive; // Gather all Motive instances motive = assignedmotives.GetComponentsInChildren <Motive>(); // Loop through all motives if existing if (motive != null && bot != null) { for (int i = 0; i < motive.Length; i++) { // If motive exists if (motive[i] != null) { // Create new AttatchedMotive instance AttatchedMotive tmpmotive = new AttatchedMotive(); // Initialize tmpmotive.Initialize(bot, motive[i]); // Attatch to MotiveList MotiveList.Add(tmpmotive); } } } }
#pragma warning restore 0414 /// <summary> /// Initialize AttatchedMotive instance. /// </summary> public void Initialize(Chatbot.Core parambot, Motive parammotive) { // Retrieve Core if existing, else // throw exception if (parambot != null) { bot = parambot; } else { Debug.LogWarning("Chatbot.Core instance not passed."); } // Retrieve Motive if existing else throw exception if (parammotive != null) { motive = parammotive; } else { Debug.LogWarning("Motive instance not passed."); } // Retrieve settings from scene RetrieveMotiveSettingsFromScene(); }