Ejemplo n.º 1
0
    public override void PutMessage(GameMsg msg)
    {
        AssessmentScenarioMsg asmsg = msg as AssessmentScenarioMsg;
        if (asmsg != null)
        {
            QuickInfoMsg qimsg = new QuickInfoMsg();
            qimsg.text = asmsg.PrettyPrint();
            QuickInfoDialog.GetInstance().PutMessage(qimsg);
        }
        AssessmentListMsg almsg = msg as AssessmentListMsg;
        if (almsg != null)
        {
#if DEBUG_ASSESSMENT_LIST
            QuickInfoMsg qimsg = new QuickInfoMsg();
            qimsg.text = almsg.PrettyPrint();
            QuickInfoDialog.GetInstance().PutMessage(qimsg);
#endif
        }
        AssessmentItemMsg aimsg = msg as AssessmentItemMsg;
        if (aimsg != null)
        {
            if (aimsg.Item.Fatal == true)
            {
                QuickInfoMsg qimsg = new QuickInfoMsg();
                qimsg.title = "FATAL";
                qimsg.text = aimsg.PrettyPrint();
                QuickInfoDialog.GetInstance().PutMessage(qimsg);
            }
        }
    }
Ejemplo n.º 2
0
    public override void PutMessage(GameMsg msg)
    {
		if (GUIManager.GetInstance() != null)
			GUIManager.GetInstance().Fade = false; // this doesn't belong here at all. but it needs to happen.

		InteractStatusMsg ismsg = msg as InteractStatusMsg;
		if (ismsg != null)
		{
			if (ismsg.InteractName == "GO:TO:ASSESSMENT")
			{
				MenuLoader loader = new GameObject("tmp").AddComponent<MenuLoader>() as MenuLoader;
				if ( loader != null )
					loader.GotoAssessment();
			}
		}

        base.PutMessage(msg);

		// let assessment manager chew on this msg
		AssessmentMgr.GetInstance().PutMessage(msg);
		
//		InteractionMgr.GetInstance().EvaluateInteractionSet(msg);
		
#if DEBUG_ASSESSMENT_ITEM
        AssessmentItemMsg aimsg = msg as AssessmentItemMsg;
        if (aimsg != null)
        {
            // do a quickinfo dialog for the 1st list item
            QuickInfoMsg qimsg = new QuickInfoMsg();
            qimsg.timeout = 3.0f;
            qimsg.title = "Assessment Item";
            qimsg.text = aimsg.PrettyPrint();
            QuickInfoDialog.GetInstance().PutMessage(qimsg);
        }
#endif
#if DEBUG_ASSESSMENT_LIST
        AssessmentListMsg almsg = msg as AssessmentListMsg;
        if (almsg != null)
        {
            // do a quickinfo dialog for the 1st list item
            QuickInfoMsg qimsg = new QuickInfoMsg();
            qimsg.timeout = 3.0f;
            qimsg.title = "Assessment List";
            qimsg.text = almsg.PrettyPrint();
            QuickInfoDialog.GetInstance().PutMessage(qimsg);
        }
#endif

        // send to MedLabMgr
        //MedLabMgr.GetInstance().PutMessage(msg);
    }
Ejemplo n.º 3
0
    public void Utterance( string utterance, string speaker )
    {
		if (utterance.Contains("url=") )
		{
			string oldurl = url;
			// replace send URL
			url = utterance.Replace("url=","");		
			// if *, replace with default
			if ( url == "default" )
				url = urlDefault;
			
			// reissue setup command
            ContextSetupRequest("1.0", "trauma", null);

			QuickInfoMsg msg = new QuickInfoMsg();
            msg.title = "NLU URL";
            msg.text = "new NLU url <" + url + "> old was <" + oldurl + ">";
            msg.timeout = 0.0f;
            QuickInfoDialog.GetInstance().PutMessage(msg);
			
			return;
		}
        if (csr.context_uid == "NONE" || Initialized == false)
        {
            QuickInfoMsg msg = new QuickInfoMsg();
            msg.title = "NLU STATUS";
            msg.text = "Waiting for NLU Initialization! : status=" + status;
            msg.h = Screen.height - 50;
            msg.timeout = 0.0f;
            QuickInfoDialog.GetInstance().PutMessage(msg);
            return;
        }

        StringBuilder memout = new StringBuilder();
        XmlWriter writer = XmlWriter.Create(memout);
        writer.WriteStartDocument();

        writer.WriteStartElement("process_utterance_request");

        writer.WriteStartElement("context_uid");
        writer.WriteString(csr.context_uid);
        writer.WriteEndElement();

        writer.WriteStartElement("utterance");
        writer.WriteString(utterance);
        writer.WriteEndElement();

        writer.WriteStartElement("speaker");
        writer.WriteString(speaker);
        writer.WriteEndElement();

        writer.WriteEndElement();

        writer.WriteEndDocument();

        // send command
		StartCoroutine(SendCmdWWW(memout.ToString()));
	}
Ejemplo n.º 4
0
    public void ParseContextSetupReply(XmlReader reader)
    {
        // verify node is "context_setup_reply
        if (reader.Name == "context_setup_reply")
        {
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "apiversion")
                {
                    csr.apiversion = reader.ReadElementContentAsString();
                    //UnityEngine.Debug.Log("apiversion=" + csr.apiversion);
                }
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "setup_request_status")
                {
                    csr.setup_request_status = reader.ReadElementContentAsInt();
                    //UnityEngine.Debug.Log("setup_request_status=" + csr.setup_request_status);
                }
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "context_uid")
                {
                    csr.context_uid = reader.ReadElementContentAsString();
					
#if SHOW_INIT
                    QuickInfoMsg msg = new QuickInfoMsg();
                    msg.title = "NLU STATUS";
                    msg.text = "NLU Initialized : " + CmdTime + " seconds";
                    msg.timeout = 2.0f;
                    QuickInfoDialog.GetInstance().PutMessage(msg);
#endif

                    Initialized = true;

                    //UnityEngine.Debug.Log("context_uid=" + csr.context_uid);
                }
            }
        }
    }
Ejemplo n.º 5
0
	/* ----------------------------  SERIALIZATION ----------------------------------------- */	
	
	
	
	public void PutMessage( ScriptedAction scriptedAction ){
		// create a message of the appropriate type, and send it to the singleton, or	
		if (msgType == eMsgType.interactMsg){
			BaseObject bo = ObjectManager.GetInstance().GetBaseObject(gameObjectName);
			if (bo == null){
				Debug.LogWarning("GameMsgForm "+name+" could not send message to '"+gameObjectName+"', not known to ObjectManager.");
				return;
			}
			GameObject target = bo.gameObject;
			if (target != null){
				InteractMsg newMsg = new InteractMsg(target,map.GetMap());
				// add flag to let everyone know that this command as generated internally
				newMsg.scripted = true;
				//	newMsg.map.task = map.task; // Task master faults if this is null

				for(int i=0;i<newMsg.map.param.Count;i++)
				{
					if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
						newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
				}
				// this is problematic, because BaseObject.PutMessage does NOTHING! TODO
				//target.GetComponent<BaseObject>().PutMessage(newMsg);
				ObjectManager.GetInstance ().GetBaseObject(gameObjectName).PutMessage(newMsg);
			}
		}
		if (msgType == eMsgType.interactStatusMsg){
			GameObject target = GameObject.Find (gameObjectName);
			if (target != null){
				InteractMsg newMsg;
				if (sendMap)
					newMsg = new InteractMsg(target,map.GetMap());
				else
					newMsg = new InteractMsg(target,interactName,log);
				// add flag to let everyone know that this command as generated internally
				newMsg.scripted = true;
				//newMsg.map.task = map.task; // Task master faults if this is null
				if (sendMap)
					for(int i=0;i<newMsg.map.param.Count;i++)
					{
						if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
							newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
					}
				InteractStatusMsg newisMsg = new InteractStatusMsg(newMsg);
				if (Params != null && Params.Length > 0){
					newisMsg.Params=new List<string>();
					for(int i=0;i<Params.Length;i++)
					{
						if ( Params[i] != null && Params[i] != "" )
							newisMsg.Params.Add (scriptedAction.executedBy.ResolveArgs(Params[i])); // substitute any #values
					}
				}
				// send to all objects
			//	ObjectManager.GetInstance().PutMessage(newisMsg);  // the brain sends to the object manager
				// send to the brain
				Brain.GetInstance().PutMessage(newisMsg);
			}
		}
		if (msgType == eMsgType.animateMsg){
			
		}
		if (msgType == eMsgType.taskMsg){
			
		}
		if (msgType == eMsgType.errorDialogMsg){
			
		}
		if (msgType == eMsgType.interactDialogMsg){
			
		}
		if (msgType == eMsgType.quickInfoDialogMsg){
			QuickInfoMsg newMsg = new QuickInfoMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			// all the QuickInfo's had a timeout of 0 which was not getting passed, so if you see that, leave it alone
			// treat -1 as the value to leave the dialog up.
			if (timeout == 0) timeout = 2;
			if (timeout == -1) timeout = 0;
			newMsg.timeout = timeout;
			newMsg.modal = modal;
			newMsg.command = command;
			
			QuickInfoDialog.GetInstance().PutMessage( newMsg );
		}
		if (msgType == eMsgType.popupMsg){
			
		}
		if (msgType == eMsgType.dialogMsg){
			
			DialogMsg newMsg = new DialogMsg();

			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			newMsg.className = className;
			newMsg.name = dialogName;
			newMsg.anchor = anchor;
			newMsg.xmlName = xmlName;
			newMsg.arguments = new List<string>();
			newMsg.callback += scriptedAction.DialogCallback;
			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (StringLookup(scriptedAction.executedBy.ResolveArgs(arg))); // substitute any #values
			}
			// fire off the dialog
			GUIManager.GetInstance().PutMessage( newMsg );
		}	
		if (msgType == eMsgType.guiScreenMsg){
			
			GUIScreenMsg newMsg = new GUIScreenMsg();
		
			newMsg.ScreenName = ScreenName;

			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (StringLookup(scriptedAction.executedBy.ResolveArgs(arg))); // substitute any #values
			}
			// fire off the dialog
			GUIManager.GetInstance().PutMessage( newMsg );
		}		
	}
Ejemplo n.º 6
0
	public GameMsg ToGameMsg( ScriptedAction scriptedAction ){
		// create a message of the appropriate type, and send it to the singleton, or	
		if (msgType == eMsgType.interactMsg){
			GameObject target = GameObject.Find (gameObjectName); // cant use ObjectManager from the editor
			if (target != null){
				InteractMsg newMsg = new InteractMsg(target,map.GetMap());
				//	newMsg.map.task = map.task; // Task master faults if this is null

				for(int i=0;i<newMsg.map.param.Count;i++)
				{
					if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
						newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
				}
				// this is problematic, because BaseObject.PutMessage does NOTHING! TODO
				//target.GetComponent<BaseObject>().PutMessage(newMsg);
				return newMsg as GameMsg;
			}
		}
		if (msgType == eMsgType.interactStatusMsg){
			GameObject target = GameObject.Find (gameObjectName);
			if (target != null){
				InteractMsg newMsg;
				if (sendMap)
					newMsg = new InteractMsg(target,map.GetMap());
				else
					newMsg = new InteractMsg(target,interactName,log);
				//newMsg.map.task = map.task; // Task master faults if this is null
				if (sendMap)
					for(int i=0;i<newMsg.map.param.Count;i++)
					{
						if ( newMsg.map.param[i] != null && newMsg.map.param[i] != "" )
							newMsg.map.param[i]= scriptedAction.executedBy.ResolveArgs(newMsg.map.param[i]); // substitute any #values
					}
				InteractStatusMsg newisMsg = new InteractStatusMsg(newMsg);
				if (Params.Length > 0){
					newisMsg.Params=new List<string>();
					for(int i=0;i<Params.Length;i++)
					{
						if ( Params[i] != null && Params[i] != "" )
							newisMsg.Params.Add (scriptedAction.executedBy.ResolveArgs(Params[i])); // substitute any #values
					}
				}
				return newisMsg as GameMsg;
			}
		}
		if (msgType == eMsgType.quickInfoDialogMsg){
			DialogMsg newMsg = new QuickInfoMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			
			return newMsg as GameMsg;
		}
		if (msgType == eMsgType.dialogMsg){
			
			DialogMsg newMsg = new DialogMsg();
		
			newMsg.x = x;
			newMsg.y = y;
			newMsg.w = w;
			newMsg.h = h;
			newMsg.text = text;
			newMsg.title = title;
			newMsg.time = time;
			newMsg.modal = modal;
			newMsg.command = command;
			newMsg.className = className;
			newMsg.xmlName = xmlName;
			newMsg.arguments = new List<string>();
			newMsg.callback += scriptedAction.DialogCallback;
			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (scriptedAction.executedBy.ResolveArgs(arg)); // substitute any #values
			}
			// fire off the dialog
			return newMsg as GameMsg;
		}	
		if (msgType == eMsgType.guiScreenMsg){
			
			GUIScreenMsg newMsg = new GUIScreenMsg();
		
			newMsg.ScreenName = ScreenName;

			foreach( string arg in arguments )
			{
				if ( arg != null && arg != "" )
					newMsg.arguments.Add (scriptedAction.executedBy.ResolveArgs(arg)); // substitute any #values
			}
			// fire off the dialog
			return newMsg as GameMsg;
		}
		return null;
	}	
Ejemplo n.º 7
0
    public void Play(string character, string tag)
    {
        VoiceMap map = Find(character, tag);
        if (map != null)
        {
			if (map.Audio == "Audio/missingAudio")
				Debug.LogError("missing audio for tag "+tag+" "+character);
            // play the audio
			if (map.Dynamic == true )
			{
				// play dynamic text
				// get the dynamic audio player
				DynamicAudioMgr da = Brain.GetInstance().gameObject.GetComponent<DynamicAudioMgr>() as DynamicAudioMgr;
				if ( da != null )
				{
	                Character c = ObjectManager.GetInstance().GetBaseObject(character) as Character;
                	if (c != null)
                	{
						AudioSource source = Brain.GetInstance().GetAudioSource(character);
						c.TalkTime = da.Play(source,map.Audio,FindList(character).VoiceMaps);
                   		c.LookAt(map.LookAt, c.TalkTime);
						// queue gap for this duration
						// it looks like da.Play is going to play right now, but if there is other speech queued, it will speak over the top.
						// this needs to be interleaved with the non-dynamic audio
						// lets try playing the dynamic
						Brain.GetInstance().QueueAudioGap(c.TalkTime,character);
						// set the map text
						map.Text = da.GetPlayString();
					}
				}
			}
			else
			{
	            // get the clip
            	if (map.Clip == null)
	                map.Clip = SoundMgr.GetInstance().GetClip(map.Audio);
			}
			
            if (map.Clip != null)
            {
                // do LookAt
                Character c = ObjectManager.GetInstance().GetBaseObject(character) as Character;
                if (c != null)
                {
					// check for ignore
                    if (map.LookAt == null || map.LookAt == "")
                        map.LookAt = "camera";
					
					if (map.LookAt.ToLower() != "ignore")
					{
                    	// look
                    	c.LookAt(map.LookAt, Time.time + map.Clip.length);
						// set talk time
						c.TalkTime = Time.time + map.Clip.length;
					}
                }

				if ( map.Audio.Contains ("missing") ){
					UnityEngine.Debug.LogError("VoiceMgr.Play(" + character + "," + tag + ") audio missing for command<" + map.Tag + ">");
//				else
  //              	UnityEngine.Debug.Log("VoiceMgr.Play(" + character + "," + tag + ") ok");
					if (map.Text != ""){ // let us hear the text spoken
						Brain.GetInstance().PlayTTS(map.Text, character);
						float phraseLength = 2 + (map.Text.Length/15f);
						c.LookAt(map.LookAt, Time.time + phraseLength);
						c.TalkTime = Time.time + phraseLength; // rough amount of time to speak the text
						Brain.GetInstance().QueueAudioGap(phraseLength,character);
					}
				}else{
                Brain.GetInstance().QueueAudio(map.Clip,character);
					}
            }
            // put up dialog
            if (map.Text != null)
            {
#if USE_INFO_DIALOG
                InfoDialogMsg infomsg1 = new InfoDialogMsg();
                infomsg1.command = DialogMsg.Cmd.open;
                infomsg1.title = "<" + character + ">";
                infomsg1.text = Parse(map.Text);
                InfoDialogLoader.GetInstance().PutMessage(infomsg1);
#else
                QuickInfoMsg infomsg1 = new QuickInfoMsg();
                infomsg1.command = DialogMsg.Cmd.open;
                infomsg1.title = character;
                infomsg1.text = map.Text;
                infomsg1.timeout = 2.0f;
                QuickInfoDialog.GetInstance().PutMessage(infomsg1);

                UnityEngine.Debug.LogWarning("VoiceMgr.Play(" + character + "," + tag + ") can't play clip, text=[" + map.Text + "]");
#endif
        	}
        }
#if DEBUG_VM
        else
            UnityEngine.Debug.LogWarning("VoiceMgr.Play(" + character + "," + tag + ") can't find tag or character");
#endif
    }
Ejemplo n.º 8
0
    public static void Parse(string action)
    {
        // var:object.variable equals:0.5 .. sets equal
        // var:object.variable dec:0.5 .. decrements by .5
#if DEBUG_DECISION_ENGINE
        UnityEngine.Debug.Log("Action.Parse(" + action + ")");
#endif
        if (action.Contains("var") && action.Contains("equals"))
        {
            DecisionVariable variable = GetVar(action, "var");
            if (variable != null)
            {
                // get value of operator
                string val = GetArg(action,"equals");
                if (val != null)
                {
#if DEBUG_DECISION_ENGINE
                    UnityEngine.Debug.Log("Action.Parse(equals:" + action + ") : variable=" + variable.Object + "." + variable.Variable + " : value=" + variable.Get());
#endif
                    variable.Set(val);
                }
            }
        }

        // var:object.variable inc:0.5 .. increments by .5
        if (action.Contains("var") && action.Contains("inc"))
        {
            DecisionVariable variable = GetVar(action, "var");
            if (variable != null)
            {
                // get value of operator
                string val = GetArg(action,"inc");
                if (val != null)
                {
#if DEBUG_DECISION_ENGINE
                    UnityEngine.Debug.Log("Action.Parse(inc:" + action + ") : variable=" + variable.Object + "." + variable.Variable + " : value=" + val);
#endif
                    variable.Inc(val);
                }
            }
        }

        if (action.Contains("var") && action.Contains("dec"))
        {
            DecisionVariable variable = GetVar(action, "var");
            if (variable != null)
            {
                // get value of operator
                string val = GetArg(action,"dec");
                if (val != null)
                {
#if DEBUG_DECISION_ENGINE
                    UnityEngine.Debug.Log("Action.Parse(dec:" + action + ") : variable=" + variable.Object + "." + variable.Variable + " : value=" + val);
#endif
                    variable.Dec(val);
                }
            }
        }

        // var:object interact:MSG:EXAMPLE
        if (action.Contains("var") && action.Contains("interact"))
        {
            string objname = GetArg(action, "var");
            string interaction = GetString(action, "interact");

#if DEBUG_DECISION_ENGINE
            UnityEngine.Debug.Log("Action.Parse(interact:" + action + ") : objname=" + objname + " : interaction=" + interaction);
#endif
            ObjectInteraction objint = ObjectManager.GetInstance().GetBaseObject(objname) as ObjectInteraction;
            if (objint != null)
            {
                InteractionMap map = InteractionMgr.GetInstance().Get(interaction);
                if (map != null)
                {
                    // send interaction
                    InteractMsg imsg = new InteractMsg(objint.gameObject,map,true);
                    objint.PutMessage(imsg);
                }
            }
        }

        if (action.Contains("status:"))
        {
            string status = GetString(action, "status");
            if (status != null)
            {
                InteractStatusMsg ismsg = new InteractStatusMsg(status);
                Brain.GetInstance().PutMessage(ismsg);
            }
        }
		
#if CHANGE_STATE
		if (action.Contains("state:"))
		{
			string state = GetArg(action,"state");
			if ( state != null )
			{
				DecisionState newstate = Parent.FindState(state);
				if ( newstate != null )
				{
					Parent.Current = newstate;
				}
			}
		}
#endif

        // changestate:BRAINSTATE
        if (action.Contains("changestate"))
        {
            string statename = GetArg(action, "changestate");
            if (statename != null)
            {
                ChangeStateMsg msg = new ChangeStateMsg(statename);
                Brain.GetInstance().PutMessage(msg);
            }
        }

        // sound effect
        if (action.Contains("audio:"))
        {
            string audio = GetString(action, "audio");
            if (audio != null)
            {
                Brain.GetInstance().PlayAudio(audio);
            }
        }

        // dialog title:"title" text:"text" timeout:seconds
        if (action.Contains("dialog"))
        {
            string text="none", title="title";
            float time=0.0f;

            if (action.Contains("title"))
            {
                title = GetString(action, "title");
            }
            if (action.Contains("text"))
            {
                text = GetString(action, "text");
            }
            if (action.Contains("timeout"))
            {
                time = Convert.ToSingle(GetArg(action, "timeout"));
            }
            QuickInfoMsg msg = new QuickInfoMsg();
            msg.command = DialogMsg.Cmd.open;
            msg.title = title;
            msg.text = text;
            msg.timeout = time;
            QuickInfoDialog.GetInstance().PutMessage(msg);
        }
    }
	public void ExecuteInteract()
	{
		// set executed
		Executed = true;
		
		// if we have a say tag just say it and return
		if (Say != null && Say != "")
		{
			NluPrompt.GetInstance().SpeechToText(Say);
			
			QuickInfoMsg qimsg = new QuickInfoMsg();
			qimsg.title = "You Say...";
			qimsg.text = Say;
			QuickInfoDialog.GetInstance().PutMessage(qimsg);
		}
		else
		{
			// put the interact message
			InteractionMap map = InteractionMgr.GetInstance().Get(InteractName);
			if (map != null)
			{
				if (Character == null)
				{
					#if DEBUG_PLAYBACK
					UnityEngine.Debug.Log("InteractPlaybackItem.Execute() : no character or character is player, send <" + InteractName + "> to Brain");
					#endif
					Dispatcher.GetInstance().ExecuteCommand(map.item);
					// send to brain
					//Brain.GetInstance().PutMessage(new InteractMsg(null, map,true));
					// log it
					//LogMgr.GetInstance().Add(new InteractLogItem(Time.time,"player",map.item,map.response));
				}
				else
				{
					ObjectInteraction objint = ObjectManager.GetInstance().GetBaseObject(Character.ToLower()) as ObjectInteraction;
					if (objint != null)
					{
						#if DEBUG_PLAYBACK
						UnityEngine.Debug.Log("InteractPlaybackItem.Execute() : Create interaction=<" + InteractName + "> for character=<" + Character + ">");
						#endif
						// do message
						Dispatcher.GetInstance().ExecuteCommand(map.item,Character.ToLower ());
						//objint.PutMessage(new InteractMsg(objint.gameObject, map));
					}
					else
					{
						#if DEBUG_PLAYBACK
						UnityEngine.Debug.Log("InteractPlaybackItem.Execute() : can't find character=<" + Character + ">, send <" + InteractName + "> to Brain");
						#endif
						Dispatcher.GetInstance().ExecuteCommand(map.item);
						// send to brain
						//Brain.GetInstance().PutMessage(new InteractMsg(null, map));
						// log it
						//LogMgr.GetInstance().Add(new InteractLogItem(Time.time, "player", map.item, map.response));
					}
				}
			}
			#if DEBUG_PLAYBACK
			else{
				UnityEngine.Debug.LogError("InteractPlaybackItem.Execute() : can't find interaction=<" + InteractName + "> for character=<" + Character + ">");
				map = InteractionMgr.GetInstance().Get(InteractName);

			}
			#endif
		}
	}
Ejemplo n.º 10
0
    public void ErrorCallback(string data)
    {
        Brain.GetInstance().PlayAudio("BAD:COMMAND:" + (int)UnityEngine.Random.Range(1,4));

        UnityEngine.Debug.Log("NluPrompt.ErrorCallback=" + data);

#if DEBUG_NLU_CMD
        // put up quickinfo with feedback
        QuickInfoMsg msg = new QuickInfoMsg();
        msg.text = "NLU : error=<" + data + ">";
        msg.title = "NLU ERROR";
        msg.h = 300;
        msg.timeout = 0.0f;
        QuickInfoDialog.GetInstance().PutMessage(msg);
#endif

#if DEBUG_CMD_STRINGS
        if (++cnt > 3)
            cnt = 0;
        data = commands[cnt];
#endif
    }
Ejemplo n.º 11
0
    public void Debug(string text)
    {
        UnityEngine.Debug.Log(text);

#if DEBUG_NLU_CMD
        QuickInfoMsg imsg = new QuickInfoMsg();
        imsg.title = "NLU Status, hit F8 for more NLU Debug";
        imsg.command = DialogMsg.Cmd.open;
        imsg.text = text;
        imsg.h = 300;
        imsg.timeout = 0.0f;
        QuickInfoDialog.GetInstance().PutMessage(imsg);
#endif
    }
Ejemplo n.º 12
0
    public void Callback(NluMgr.match_record record)
    {
        if (record == null)
        {
            UnityEngine.Debug.Log("NluPrompt.Callback() : record = null!");
        }

        // make to upper case
        record.sim_command = record.sim_command.ToUpper();

        string text = "<NLU Command> <" + record.sim_command + ">";
        // subject 
        if (record.command_subject != null && record.command_subject != "")
            text += " : s=<" + record.command_subject + ">";
        // params
        foreach (NluMgr.sim_command_param param in record.parameters)
            text += " : p=<" + param.name + "," + param.value + ">";
        // missing params
        foreach (NluMgr.missing_sim_command_param param in record.missing_parameters)
            text += " : m=<" + param.name + ">";
        // readback
        if (record.readback != null && record.readback != "")
            text += " : r=<" + record.readback + ">";
        // feedback
        if (record.feedback != null && record.feedback != "")
            text += " : f=<" + record.feedback + ">";

        Error = "";
                
		InfoDialogMsg idm;
		
#if DEBUG_NLU_CMD
		idm = new InfoDialogMsg();
        idm.command = DialogMsg.Cmd.open;
		idm.text = text;
		InfoDialogLoader.GetInstance().PutMessage(idm);
#endif
#if SHOW_INPUT
		if ( record.input != null )
		{
			idm = new InfoDialogMsg();
        	idm.command = DialogMsg.Cmd.open;
			idm.text = "<NLU input> " + record.input;
			InfoDialogLoader.GetInstance().PutMessage(idm);
		}
#endif
#if SHOW_READBACK
		if ( record.readback != null && record.readback != "null")
		{
			idm = new InfoDialogMsg();
        	idm.command = DialogMsg.Cmd.open;
			idm.text = "<NLU readback> " + record.readback;
			InfoDialogLoader.GetInstance().PutMessage(idm);
		}
#endif		
#if SHOW_FEEDBACK
		if ( record.feedback != null && record.feedback != "null")
		{
			// send to log
			idm = new InfoDialogMsg();
        	idm.command = DialogMsg.Cmd.open;
			idm.text = "<NLU feedback> " + record.feedback;
			InfoDialogLoader.GetInstance().PutMessage(idm);
			
			// pop up dialog
			QuickInfoMsg imsg = new QuickInfoMsg();
        	imsg.title = "NLU Feedback";
        	imsg.command = DialogMsg.Cmd.open;
        	imsg.text = record.feedback;
        	imsg.h = 200;
        	imsg.timeout = 4.0f;
        	QuickInfoDialog.GetInstance().PutMessage(imsg);
		}
#endif

		// I really hate doing this but for now it is the best way to handle our only command with parameters
		if (record.sim_command.Contains("IV:BLOOD") || record.sim_command.Contains("IV:CRYSTAL"))
		{
			OrderFluids(record);
		} 
		else if (record.sim_command == "BAD:COMMAND")
        {
            Brain.GetInstance().PlayAudio("BAD:COMMAND:" + (int)UnityEngine.Random.Range(1, 4));
        } 
        else if (record.command_subject != null)
        {
            // has command subject
            if (ExecuteCommand(record.sim_command, record.command_subject.ToLower()) == false)
            {
                Debug("ExecuteCommand(CMD:" + record.sim_command + ",SUBJECT:" + record.command_subject + ") Failed : debug=" + text + " : Error=" + Error);
            }
        }
        else
        {
            // no command subject, find someone to do this...
            if (ExecuteCommand(record.sim_command) == false)
            {
                Debug("ExecuteCommand(CMD:" + record.sim_command + ", No SUBJECT) Failed : debug=" + text + " : Error=" + Error);
            }
        }

        // NLU response
        if ((record.feedback != null && record.feedback != "") || (record.readback != null && record.readback != ""))
        {
            // put up quickinfo with feedback
            QuickInfoMsg msg = new QuickInfoMsg();
            if (record.feedback != null && record.readback != null)
            {
                response_title = msg.title = "READBACK/FEEDBACK";
                response = msg.text = "SIM_COMMAND <" + record.sim_command + "> : CMD_SUBJECT <" + record.command_subject + "> : READBACK <" + record.readback + "> : FEEDBACK <" + record.feedback + "> : ERROR <" + Error + ">";
            }
            else if (record.feedback != null)
            {
                response_title = msg.title = "FEEDBACK";
                response = msg.text = "SIM_COMMAND <" + record.sim_command + "> : CMD_SUBJECT <" + record.command_subject + "> : FEEDBACK <" + record.feedback + "> : ERROR <" + Error + ">";
            }
            else if (record.readback != null)
            {
                response_title = msg.title = "READBACK";
                response = msg.text = "SIM_COMMAND <" + record.sim_command + "> : CMD_SUBJECT <" + record.command_subject + "> : READBACK <" + record.readback + "> : ERROR <" + Error + ">";
            }
            msg.w = 600;
            msg.h = 200;
            msg.timeout = 0.0f;
            //QuickInfoDialog.GetInstance().PutMessage(msg);
        }

        //InfoDialogLoader idl = InfoDialogLoader.GetInstance();
        //if (idl != null)
        //{
        //    InfoDialogMsg msg = new InfoDialogMsg();
        //    msg.command = DialogMsg.Cmd.open;
        //    msg.text = response;
        //    idl.PutMessage(msg);
        //}

#if DEBUG_CMD_STRINGS
        if (++cnt > 3)
            cnt = 0;
        data = commands[cnt];
#endif
    }
Ejemplo n.º 13
0
    public override void PutMessage(GameMsg msg)
    {
        // handle Meds
        MedAdministerMsg admin = msg as MedAdministerMsg;
        if (admin != null)
        {
            MedAdminister(admin);
        }

#if FIND_CHARACTER_FOR_TASK
        InteractMsg imsg = msg as InteractMsg;
        if (imsg != null && imsg.map != null)
        {
            string debug = "DEBUG";

            // patient can't really do anything so we need find a character
            // to do this interaction (if possible)
            List<ObjectInteraction> objects = ObjectInteractionMgr.GetInstance().GetEligibleObjects(imsg.map.item);
            foreach (ObjectInteraction obj in objects)
            {
                Character character = obj as Character;
                if (character != null)
                {
                    // make sure the available character is not busy and it isn't ME!
                    if (character.IsDone() == true && character.gameObject.name != this.Name)
                    {
                        Debug("Patient.PutMessage(" + imsg.map.item + ") : command sent to [" + character.gameObject.name + "]");
                        InteractionMap map = InteractionMgr.GetInstance().Get(imsg.map.item);
                        character.PutMessage(new InteractMsg(character.gameObject, map));
                        return;
                    }
                    else
                    {
                        debug += " : character[" + character.gameObject.name + "] is busy!";
                    }
                }
            }

            QuickInfoMsg qimsg = new QuickInfoMsg();
            qimsg.command = DialogMsg.Cmd.open;
            qimsg.title = "Nobody Available";
            qimsg.text = "All eligible characters for command are busy right now!! " + debug;
            qimsg.timeout = 4.0f;
            QuickInfoDialog.GetInstance().PutMessage(qimsg);
            return;
        }
#endif
		
        InteractStatusMsg ismsg = msg as InteractStatusMsg;
        if (ismsg != null)
        {
            ComputeBloodSalineEffect(ismsg);
			
			// quick hack to turn on Audio
			// Turning this off so that HearbeatGraph can handle a 3Dlocalized audio beep at the monitor,
			// includig pitch modulation with SAO2 level, which would affect other audio if done here.
//			if ( ismsg.InteractName == "PLACE:EKG:COMPLETE" )
//			{
//				hrTimer = Time.time;
//				doHRAudio = true;
//			}
        }

        base.PutMessage(msg);
    }