public void OnGUI()
	{
		if(clicked && bodyPart != "None") {
			InfoDialogMsg msg = new InfoDialogMsg();
			msg.text = ("You clicked " + bodyPart);
			msg.command = DialogMsg.Cmd.open;
			InfoDialogLoader.GetInstance().PutMessage(msg);
			clicked = false;
		}
		//GUILayout.Label("Color = " + pickedColor);   
		//GUILayout.Label("Part = " + bodyPart);
	}
    public void PutMessage(InfoDialogMsg msg)
    {
        //Debug.Log("InfoDialogLoader.PutMessage()");

        msg.modal = false;
        msg.xmlName = xmlFile.name;
        msg.className = "InfoDialogGUI";
		msg.AutoClose = AutoClose;
		msg.CloseTime = CloseTime;
		msg.MaxLines = MaxLines;
		msg.Reverse = Reverse;
		msg.Scroll = Scroll;
        GUIManager.GetInstance().LoadDialog(msg);        
    }
	void SendCommandToInfoDialog(string phrase){
		InfoDialogMsg infomsg1 = new InfoDialogMsg();
		infomsg1.command = DialogMsg.Cmd.open;
		infomsg1.title = "<SEMANTICS>";
		infomsg1.text = phrase;
		InfoDialogLoader.GetInstance().PutMessage(infomsg1);
	}
    public virtual void HandleResponse(GameMsg msg)
    {
        InteractMsg interactmsg = msg as InteractMsg;
        if (interactmsg == null || interactmsg.map == null)
            return;
		
        //UnityEngine.Debug.Log("ObjectInteractionMgr.HandleResponse(" + interactmsg.map.item + ") : name=<" + interactmsg.gameObject + "> : sound=<" + interactmsg.map.sound + ">");
        //interactmsg.map.Debug();

        // play audio
        Brain.GetInstance().PlayAudio(interactmsg.map.sound);

        // send interaction to the voice manager
        VoiceMgr.GetInstance().Play(interactmsg);

        // check for a response
        string str = interactmsg.map.response;
        if (str != null && str != "" && str.Length != 0)
        {
            // this translates any snapshot specific text
            string text = Translate(str);

            // check special case, option to display dialog
            if (text.Contains("DIALOGUE:"))
            {
                // remove the tag string
                text = text.Replace("DIALOGUE:", "");

                // load dialog, if ok then return
                if (DialogueTree.GetInstance().GoToDialogue(text, true) == true)
                {
                    return;
                }
            }

            // default to normal dialog
            InfoDialogMsg infomsg1 = new InfoDialogMsg();

            // grab title from map otherwise just use object's prettyname
            if (interactmsg.map.response_title != null && interactmsg.map.response_title != "")
                infomsg1.title = StringMgr.GetInstance().Get(interactmsg.map.response_title);
            else
                infomsg1.title = "response_title";

            if (InfoDialogLoader.GetInstance() != null)
            {
                infomsg1.command = DialogMsg.Cmd.open;
                infomsg1.text = text;
//                InfoDialogLoader.GetInstance().PutMessage(infomsg1);
            }
        }
    }
    public override void PutMessage(GameMsg msg)
    {
        AssessmentMgrDialogMsg dmsg = msg as AssessmentMgrDialogMsg;
        if (dmsg != null)
        {
            if (dmsg.List != null)
                List = dmsg.List;
            if ( dmsg.Report != null )
                Report = dmsg.Report;

            // close info dialog
            InfoDialogMsg idmsg = new InfoDialogMsg();
            idmsg.command = DialogMsg.Cmd.close;
            InfoDialogLoader.GetInstance().PutMessage(idmsg);

            // put up assessment dialog
            if (Screen != null)
            {
                GUIManager.GetInstance().Remove(Screen.Parent);
                Screen = null;
            }

            DialogLoader dl = DialogLoader.GetInstance();
            if (dl != null)
            {
                dl.LoadXML("dialog.assessment");
                GUIScreen dp = Screen = dl.ScreenInfo.FindScreen("AssessmentScreen");
                dp.SetLabelText("titleBarText", "Scenario Assessment");
                GUIContainer guiobj = dp.Find("scrollBox") as GUIContainer;
                if (guiobj != null)
                {
                    GUIReportObject reportObj = new GUIReportObject(Report);
                    reportObj.SetSkin(gSkin);
                    guiobj.Elements.Add(reportObj);
                }
            }        
        }
        //base.PutMessage(msg);
    }
Example #6
0
    private void LoadToDialog(Dialogue dialogue, bool forceVisible)
    {
        activeDialogue = dialogue;
        // Set data to the dialog
        activeDialogueDialog.displayDialogue = dialogue.text;
        activeDialogueDialog.dialogueTitle = dialogue.title;
        if(activeDialogueDialog.options == null)
            activeDialogueDialog.options = new Dialogue.DialogueOption[4];
        activeDialogueDialog.options[0] = dialogue.dialogueOption1;
        activeDialogueDialog.options[1] = dialogue.dialogueOption2;
        activeDialogueDialog.options[2] = dialogue.dialogueOption3;
        activeDialogueDialog.options[3] = dialogue.dialogueOption4;
        activeDialogueDialog.image = dialogue.image;

        if (dialogue.audio != null)
        {
            Brain.GetInstance().PlayVocals(dialogue.audio);
        }

        // Check if no dialogue from NPC and if all valid options have been selected leaving only a "Next" option
        bool check = false;
        if (activeDialogueDialog.displayDialogue.Length == 0)
        {
            foreach (Dialogue.DialogueOption option in activeDialogueDialog.options)
            {
                if (option != null)
                {
                    if ((!option.clearOnVisited || !option.visited) && option.text != "Next")
                    {
                        check = true;
                        break;
                    }
                }
            }
        }
        else
            check = true;
        // If no valid option found, go to "Next" dialogue
        if (!check)
        {
            foreach (Dialogue.DialogueOption option in activeDialogueDialog.options)
            {
                if (option != null && option.text == "Next")
                {
                    GoToDialogue(option.goToID, forceVisible);
                    return;
                }
            }
            // If this failed, the dialogue doesn't have a Next
            EndActiveDialogue();
            return;
        }

        if (forceVisible)
        {
            InfoDialogMsg infomsg1 = new InfoDialogMsg();
            infomsg1.command = DialogMsg.Cmd.close;
            InfoDialogLoader.GetInstance().PutMessage(infomsg1);

            //activeDialogueDialog.SetModal(true);
            activeDialogueDialog.SetVisible(true);
        }
    }
Example #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
    }
Example #8
0
    public void SpeechToText(string command)
    {
        // send txt to Nlu
        UnityEngine.Debug.Log("Say <" + command + ">");
		
#if DEBUG_NLU_CMD
		InfoDialogMsg idm = new InfoDialogMsg();
       	idm.command = DialogMsg.Cmd.open;
		idm.text = "Say <" + command + ">";
		InfoDialogLoader.GetInstance().PutMessage(idm);
#endif		

        // send to Nlu
        NluMgr.GetInstance().Utterance(command, "nurse");
    }
Example #9
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
    }
    override public void PutMessage(GameMsg msg)
    {
        Debug.Log("ObjectInteraction:PutMessage() : " + msg.ToString());

        if (IsActive() == false)
            return;

        InteractMsg imsg = msg as InteractMsg;
        if (imsg != null)
        {
            // default msg, create an interaction
            InteractionMgr.GetInstance().SendInteractionMap("", imsg.map);
        }

        InteractDialogMsg dialogmsg = msg as InteractDialogMsg;
        if (dialogmsg != null)
        {
            if (dialogmsg.command == DialogMsg.Cmd.open && dialogmsg.items != null)
            {
                // close info dialog
                InfoDialogMsg dmsg = new InfoDialogMsg();
                dmsg.command = DialogMsg.Cmd.close;
                InfoDialog.GetInstance().PutMessage(dmsg);

                //print(dialogmsg.items[0].response);
                // copy new items
                items = dialogmsg.items;

                // set game object
                interactObject = dialogmsg.baseobj;

#if BRAIN_DEBUG
                if (interactObject != null)
                    Debug.Log("InteractDialog : interactObject = " + interactObject.name);
                else
                    Debug.Log("InteractDialog : no object");
#endif
				
				//menuLocation = interactObject.Name;
				baseXML = dialogmsg.baseXML;

                // set position
                x = dialogmsg.x;
                y = dialogmsg.y;

                // set visible
                SetVisible(true);
            }
        }
        base.PutMessage(msg);
    }