Exemplo n.º 1
0
 /* Called once on every frame */
 private void Update()
 {
     //is another event running?
     if (needToWait(currEvent))
     {
         return;
     }
     foreach (Conversation c in cm.conversation)
     {
         //is this Conversation complete OR are we not in this c's bounds?
         if (c.isDone() || !inConversation(c))
         {
             continue;
         }
         if (currConv != null && currConv != c)
         {
             currConv.changedConversations();
             c.changedConversations();
         }
         EventIM e = c.getNextEvent();
         //can we run this Conversation?
         if (!getState(e))
         {
             continue;
         }
         //move to the next Conversation
         RunGame(c, e);
         done(c, e);
         return; //don't check next conversation(s)
     }
 }
Exemplo n.º 2
0
    /* Called on build */
    private void Start()
    {
        TAG += name + " ";

        //load the events
        int i = 0;

        foreach (Transform child in transform)
        {
            EventIM e = child.GetComponentInChildren <EventIM>();
            if (e.nextEvent != null && e.nextEvent.name == "Response") //response doesn't have next until completed
            {
                e.nextEvent.GetComponent <Response>().setDialog(e.gameObject);
            }
            events.Add(e);
            i++;
        }
        //todo fix the dialog for the response
        jm = gameObject.GetComponent <JumpManager>();
        jm.load(events);

        currEvent = jm.getFirstEvent();
        nextEvent = jm.getNextEvent(currEvent);
        setWants();
    }
Exemplo n.º 3
0
 /* Is this event and the currently playing event of a conversational type? */
 private bool bothAreConversational(EventIM e)
 {
     if (isConversational(e) && isConversational(currEvent))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
 /* Get an event's nextEvent. */
 public EventIM getNextEvent(EventIM e)
 {
     //return e's nextEvent
     for (int i = 0; i < events.Count; i++)
     {
         if (events[i] == e)
         {
             return(next[i]);
         }
     }
     return(null); //likely unreachable
 }
Exemplo n.º 5
0
    /* ********** Accessors: State Changes ********** */
    /* What is the current state to START the event? */
    private bool getState(EventIM e)
    {
        EventSettingValue  esv   = new EventSettingValue();
        AgentStatusManager agent = e.agent.GetComponent <AgentStatusManager>();

        //grabbing author choices from UNITY
        esv.setWantLookedAt(e.wantLookedAt);
        esv.setWantInRange(e.wantInRange);
        //storing the current state of the user
        esv.setCurrPhysical(agent.getPhysicalState());
        return(esv.checkStateMatch());
    }
Exemplo n.º 6
0
    /* Only Response and Wildcards require a recognition from user. */
    private bool neededResponse(EventIM e)
    {
        //assuming that the event is complete TO GET its nextEvent
        switch (e.name)
        {
        case "Response":
        case "Wildcard":
            return(true);

        default:
            return(false);
        }
    }
Exemplo n.º 7
0
    /* Is this event's type a conversational one? */
    private bool isConversational(EventIM e)
    {
        switch (e.name)
        {
        case "Diagonal":
        case "Response":
        case "Wildcard":
            return(true);

        default:
            return(false);
        }
    }
Exemplo n.º 8
0
    /* Does this event require a response (is it a Response/Wildcard)? */
    private bool eventNeedsResponse(EventIM e)
    {
        //of what type is the conversation?
        switch (e.name)
        {
        case "Response":
        case "Wildcard":
            return(true);

        default:
            return(false);
        }
    }
Exemplo n.º 9
0
    /* Is another event playing of this same type? */
    private bool isPlayingSameType(EventIM e)
    {
        int counter = 0;

        foreach (EventIM E in events)
        {
            if (e.name == E.name && !E.isActive())
            {
                counter++;
            }
        }
        if (counter > 0)
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 10
0
 /* Get the currently played event's next event to play. */
 public EventIM getNextEvent()
 {
     if (!currEvent.hasStarted())
     {
         setWants();
         return(currEvent);
     }
     if (neededResponse(currEvent))
     {
         currEvent = currEvent.nextEvent.GetComponent <EventIM>();
         setWants();
         return(currEvent);
     }
     currEvent = jm.getNextEvent(currEvent);
     setWants();
     return(currEvent);
 }
Exemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        //DrawDefaultInspector();
        SerializedObject serializedObject = new SerializedObject(target);

        serializedObject.Update();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("agent"), true);
        EditorGUILayout.LabelField("Add a new event of type: ");
        selected = (EventIM.EventType)EditorGUILayout.EnumPopup(selected);

        serializedObject.ApplyModifiedProperties();

        EventIM eventEditor = (EventIM)target;

        if (GUILayout.Button("Add Event"))
        {
            eventEditor.AddEvent(selected.ToString());
        }
    }
Exemplo n.º 12
0
 /* Does this event need to wait before we can run it? */
 private bool needToWait(EventIM e)
 {
     //is this the first event?
     if (e == null)
     {
         return(false);
     }
     //Debug.Log(TAG + e.IDescription + " is not null");
     //this is a Resp/WC, and we need it to finish first (recognize to know what's next)
     if (eventNeedsResponse(e) && e.isActive())
     {
         return(true);
     }
     //Debug.Log(TAG + e.IDescription + " is not a resp/wc");
     if (!bothAreConversational(e))
     {
         currEvent = currConv.getNextEvent(); //to run concurrently
         e         = currEvent;
         //Debug.Log(TAG + currEvent.name + " should play now");
     }
     //Debug.Log(TAG + e.IDescription + e.hasStarted() + e.isDone());
     return(e.isActive());
 }
Exemplo n.º 13
0
 /* Play the next event concurrently with other active events */
 private void playNextKnown()
 {
     currEvent = jm.getNextEvent(prevEvent); //we already know what it's next was
     setWants();
 }
Exemplo n.º 14
0
 /* User returned this conversation from another conversation */
 public void returnedToConversation()
 {
     leftConv  = false;
     currEvent = prevEvent;
     currEvent.wantToReplay(); //neither started/finished
 }
Exemplo n.º 15
0
 /* Play the next event concurrently with other active events */
 private void playNextFind()
 {
     prevEvent.finish();
     currEvent = prevEvent.nextEvent.GetComponent <EventIM>(); //we had to wait to find next
     setWants();
 }
Exemplo n.º 16
0
    /* Called on every frame */
    private void Update()
    {
        if (finished)
        {
            return;
        }

        //this conversation is active
        if (currEvent.hasStarted())
        {
            started = true;
        }

        if (leftConv)
        {
            prevEvent = currEvent;
            return;
        }

        //this means we are NOT able to play another event
        if (isPlayingSameType(currEvent))
        {
            return;
        }

        prevEvent = currEvent;

        switch (currEvent.name)
        {
        case "Dialog":
            if (nextEvent != null && neededResponse(currEvent))
            {
                currEvent.waitForResponse(); //mark it 'unfinished'
                return;                      //wait...
            }
            if (nextEvent != null && !isConversational(currEvent))
            {
                playNextKnown();     //play the next event without wait
            }
            if (nextEvent == null)
            {
                Debug.Log(TAG + "Error: need next event after Response/Wildcard");
            }
            break;

        case "Response":
        case "Wildcard":
            //Debug.Log(TAG + currEvent.name + " is a Resp/WC");
            if (nextEvent == null)
            {
                Debug.Log(TAG + "Error: need next event after Response/Wildcard");
            }
            if (!currEvent.isDone())
            {
                return;     //wait until nextEvent is known
            }
            else
            {
                playNextFind();     //play the next event when
            }
            break;

        default:
            //not a conversational event (i.e. it can play concurrently)
            if (nextEvent == null)
            {
                Debug.Log(TAG + "Error: need next event after Response/Wildcard");
            }
            if (nextEvent != null)
            {
                playNextKnown();
            }
            else
            {
                //Debug.Log(TAG + "is done");
                finished = true;
            }
            break;
        }
    }
Exemplo n.º 17
0
 /* Save the previous event to restart: restart event */
 private void save(GameObject e)
 {
     prevEventToRepeat = e.GetComponent <EventIM>();
     Debug.Log(TAG + "woof");
 }
Exemplo n.º 18
0
 /* ********** Mutators: Event Sequence Behavior ********** */
 /* Save this conversation/event as the currently played one. */
 private void done(Conversation c, EventIM e)
 {
     currConv  = c;
     currEvent = e;
 }
Exemplo n.º 19
0
    public void RunGame()
    {
        EventIM e = events.ElementAt(eventIndex);

        if (e.name != "Trigger")
        {
            sm = e.agent.GetComponent <AgentStatusManager>();
        }
        if ((sm.isInRange && sm.isLookedAt && !sm.isSpeaking) || e.name == "Trigger")
        {
            memories.Add(eventIndex);
            Debug.Log("Event index playing..." + eventIndex);
            switch (e.name)
            {
            case "Dialog":
                dm = e.agent.GetComponent <DialogManager>();
                dm.Speak(e.GetComponent <Dialog>());
                break;

            case "Animation":
                am = e.agent.GetComponent <AnimationManager>();
                am.PlayAnimation(e.GetComponent <Animate>());
                break;

            case "Response":
                rm.Respond(e.GetComponent <Response>());
                break;

            case "Jump":
                eventIndex = e.GetComponent <Jump>().jumpID - 1;
                break;

            case "Wildcard":
                wm.Wildcard(e.GetComponent <Wildcard>());
                break;

            case "Trigger":
                tm.Trigger(e.GetComponent <Trigger>());
                break;

            case "Wait":
                wwm.Waiting(e.GetComponent <Wait>().waitTime);
                break;

            case "Move":
                mm = e.agent.GetComponent <MoveManager>();
                mm.StartMoving(e.GetComponent <Move>());
                break;

            case "StopMoving":
                mm = e.agent.GetComponent <MoveManager>();
                mm.Stop();
                break;

            case "Emote":
                em = e.agent.GetComponent <EmoteManager>();
                em.EmotionBlendshape(e.GetComponent <Emote>());
                break;

            case "MemoryCheck":
                mcm.CheckMemories(e.GetComponent <MemoryCheck>());
                break;
            }
            eventIndex++;
        }
    }
Exemplo n.º 20
0
    /* Perform the unique actions for each event to run */
    public void RunGame(Conversation c, EventIM e)
    {
        if (e.name != "Trigger")
        {
            //memories.Add(eventIndex);
            Debug.Log(TAG + "Playing Conversation/Event: " + c.name + "/" + e.name);
            switch (e.name)
            {
            case "Dialog":
                dm = e.agent.GetComponent <DialogManager>();
                dm.Speak(e.GetComponent <Dialog>());
                break;

            case "Animation":
                //Animation needs to be fixed...
                //dialog will not play if 105 conditions not met
                //but animation will play...
                am = e.agent.GetComponent <AnimationManager>();
                am.PlayAnimation(e.GetComponent <Animate>());
                break;

            case "Response":
                if (wm != null || wm.isRunning())
                {
                    wm.stop();
                }
                rm.Respond(e.GetComponent <Response>());
                break;

            case "Jump":
                //TODO jump between conversations?
                break;

            case "Wildcard":
                if (rm.isRunning())
                {
                    rm.stopKeywordRecognizer();
                }
                if (wm != null || wm.isRunning())
                {
                    wm.stop();
                }
                wm.Wildcard(e.GetComponent <Wildcard>());
                break;

            case "Trigger":
                tm.Trigger(e.GetComponent <Trigger>());
                break;

            case "Wait":
                wwm.Waiting(e.GetComponent <Wait>());
                break;

            case "Move":
                mm = e.agent.GetComponent <MoveManager>();
                mm.StartMoving(e.GetComponent <Move>());
                break;

            case "StopMoving":
                mm = e.agent.GetComponent <MoveManager>();
                mm.Stop();
                break;

            case "Emote":
                em = e.agent.GetComponent <EmoteManager>();
                em.EmotionBlendshape(e.GetComponent <Emote>());
                break;

            case "MemoryCheck":
                mcm.CheckMemories(e.GetComponent <MemoryCheck>());
                break;
            }
        }
    }