Beispiel #1
0
    public override void HandleInteractMsg(InteractMsg msg)
    {
        //UnityEngine.Debug.Log("Character.HandleInteractMsg(" + msg.GetType() + ") : target=" + this.Name);

        base.HandleInteractMsg(msg);

        // special case : this handles all messages coming from an interaction list.  
        InteractListMsg imsg = msg as InteractListMsg;
        if (imsg != null)
        {
#if DEBUG_INTERACTIONLIST
            imsg.map.Debug();
#endif
            // handle InteractionList case
            if (imsg.map.list != null)
            {
                InteractionList tmp = InteractionMgr.GetInstance().GetList(imsg.map.list);
                if (tmp != null)
                {
                    // only create a list if the current list is null or we have a list and it is interruptable
                    if (InteractionList == null || (InteractionList != null && InteractionList.Interrupt == true))
                    {
                        // make a copy
                        InteractionList = new InteractionList(imsg.map,tmp);
#if DEBUG_INTERACTIONLIST
                        UnityEngine.Debug.Log("Character.HandleInteractMsg(" + imsg.map.item + ") : Name=" + Name + "List=" + imsg.map.list);
                        InteractionList.Debug();
#endif
                        InteractionList.SetTarget(this);
                        InteractionList.Start();
                    }
                }
            }
        }
        else
        {
            // check to see if we can interrupt the list in progress with this incoming message
            if (InteractionList != null)
            {
#if DEBUG_INTERACTIONLIST
                UnityEngine.Debug.Log("Character.PutMessage(InteractMsg) : InteractionList=" + InteractionList.Name + " : Interrupt=" + InteractionList.Interrupt);
#endif
                if (InteractionList.Interrupt == true)
                    InteractionList = null;
            }
        }

        // handle InteractionList case
        if (msg.map.list != null)
        {
            InteractionList = InteractionMgr.GetInstance().GetList(msg.map.list);
            if (InteractionList != null)
            {
                // make a copy
                InteractionList = new InteractionList(msg.map, InteractionList);

#if DEBUG_INTERACTIONLIST
                UnityEngine.Debug.Log("Provider.HandleInteractMsg(" + msg.map.item + ") : Name=" + Name + "List=" + msg.map.list);
                InteractionList.Debug();
#endif

//  lets not ow that we are script driven              InteractionList.SetTarget(this);
//                InteractionList.Start();
            }
        }

    }