NPC.TalkTo C# (CSharp) Method

TalkTo() public method

Begins a conversation if possible
public TalkTo ( ) : bool
return bool
    public override bool TalkTo()
    {
        //Begin a conversation.
        string npcname="";
        if ((npc_whoami == 255))
        {
            //006~007~001~You get no response.
            UWHUD.instance.MessageScroll.Add (StringController.instance.GetString (7,1));
        }
        else
        {
            if (npc_whoami==0)
            {//Generic conversation.
                ObjectInteraction objInt=this.GetComponent<ObjectInteraction>();
                npcname= StringController.instance.GetFormattedObjectNameUW(objInt);
                npc_whoami=256+(objInt.item_id -64);
            }
            if (npc_whoami>255)
            {//Generic conversation.
                ObjectInteraction objInt=this.GetComponent<ObjectInteraction>();
                npcname= StringController.instance.GetSimpleObjectNameUW(objInt);
            }
            Conversation cnv =this.GetComponent<Conversation>();
            if (cnv!=null)
            {
                UWCharacter.InteractionMode=UWCharacter.InteractionModeInConversation;//Set converation mode.
                Conversation.CurrentConversation=npc_whoami;
                Conversation.InConversation=true;
                //cnv.WhoAmI=npc_whoami;
                if (npcname=="")
                {
                    UWHUD.instance.NPCName.text= StringController.instance.GetString (7,npc_whoami+16);
                }
                else
                {
                    UWHUD.instance.NPCName.text=npcname;
                }
                UWHUD.instance.PCName.text= GameWorldController.instance.playerUW.CharName;

                StartCoroutine(cnv.main ());//Conversations operate in coroutines to allow interaction
            }
            else
            {
                //You get no response
                UWHUD.instance.MessageScroll.Add (StringController.instance.GetString (7,1));
            }
        }
        return true;
    }

Usage Example

Example #1
0
    public IEnumerator AttendAppointment(NPC actor)
    {
        //make the npc stop listen to the movement of the next npc it wants to talk to and start listening to the next
        if (conversationPartner != null)
        {
            conversationPartner.OnPositionChange -= actor.UpdateDistance;
        }

        Appointment next = actor.appointments.GetNext();

        if (next != null)
        {
            if (next.conversation != null)
            {
                actor.appointments.GetNext().conversationPartner.OnPositionChange += actor.UpdateDistance;
            }
        }


        if (place != null)
        {
            yield return(actor.StartCoroutine(actor.GoTo(place())));
        }
        if (conversation != null)
        {
            yield return(actor.StartCoroutine(actor.TalkTo(conversationPartner, conversation)));
        }
    }