示例#1
0
    public virtual bool CheckValidInteraction( GameMsg msg)
    {
        // don't worry about InteractListMsgs
        if (msg.GetType() == typeof(InteractListMsg))
        {
            //UnityEngine.Debug.LogWarning("Character.CheckValidInteraction(" + msg.GetType() + ") : ignoring type InteractListMsg");
            return true;
        }

        // check InteractMsg
        InteractMsg imsg = msg as InteractMsg;
        if (imsg != null && imsg.map != null )
        {
            // check prereq
            if (imsg.map.prereq != null && imsg.map.prereq.Count() > 0)
            {
                foreach (string item in imsg.map.prereq)
                {
                    if (GetInteractionCount(item) < 1)
                    {
                        HandleInteractionError(imsg, "VOICE:MISSING:PREREQ");
                        return false;
                    }
                }
            }
            // check for exceeding max commands
            if (imsg.map.max != 0)
            {
                if (GetInteractionCount(imsg.map.item) >= imsg.map.max)
                {
                    HandleInteractionError(imsg, "VOICE:EXCEEDED:MAX:INTERACTION");
                    // we're done!
                    return false;
                }
            }
            if (IsValidInteraction(imsg.map.item) == false)
            {
                HandleInteractionError(imsg, "VOICE:WRONG:PERSON");
                // we're done!
                return false;
            }
/* go ahead and queue this, let the dispatcher handle it..
            // check if we're busy
            if (IsDone() == false)
            {
                // Let everyone know we are busy but will get to it later ...
//                HandleInteractionError(imsg, "VOICE:BUSY"); // this happens too often with the scripting system, lets revisit.
                // Queue 
                QueueInteractMsg(imsg);
                return false;
            }	
*/		
        }

        return true;
    }
示例#2
0
    // broadcast
    public void PutMessage(GameMsg msg)
    {
        if (objects == null)
            return;

        foreach (BaseObject obj in objects)
        {
#if DEBUG_OBJECT_MSGS
			InteractMsg imsg = msg as InteractMsg;
            if (imsg != null)
                Debug.Log("ObjectManager.PutMessage(" + imsg.map.item + ") : object=" + obj.ToString());
            else
                Debug.Log("ObjectManager.PutMessage(" + msg.GetType().ToString() + ") : object=" + obj.ToString());
#endif
            //UnityEngine.Debug.Log("ObjectManager.PutMessage(" + msg.GetType() + ") : obj=" + obj.Name);

            if (obj.enabled == true && obj.gameObject.active == true)
            {
#if DEBUG_OBJECT
                UnityEngine.Debug.Log("ObjectManager.PutMessage(" + msg.GetType() + ") : obj=" + obj.Name); 
#endif
                obj.PutMessage(msg);
            }
        }
    }