Example #1
0
    private IEnumerator UpdateEmotionalState(float updateTime)
    {
        while (true)
        {
            var SIPlayerAgent = agent1RPC.GetBeliefValue("ToM(Player, SI(SELF))");
            var SIAgentPlayer = agent1RPC.GetBeliefValue("SI(Player)");

            if (!agent1RPC.GetAllActiveEmotions().Any())
            {
                this.AgentInternalStateText.text = "Mood: " + agent1RPC.Mood + ", Emotions: [], SI(A,P): " + SIAgentPlayer + " SI(P,A): " + SIPlayerAgent;
            }
            else
            {
                var aux = "Mood: " + agent1RPC.Mood + ", Emotions: [";

                StringBuilder builder = new StringBuilder();

                var query = agent1RPC.GetAllActiveEmotions().OrderByDescending(e => e.Intensity);

                foreach (var emt in query)
                {
                    builder.AppendFormat("{0}: {1:N2}, ", emt.Type, emt.Intensity);
                }
                aux += builder.Remove(builder.Length - 2, 2);
                this.AgentInternalStateText.text = aux + "], SI(A,P): " + SIAgentPlayer + " SI(P,A): " + SIPlayerAgent;
            }

            agent1RPC.Update();


            yield return(new WaitForSeconds(updateTime));
        }
    }
Example #2
0
        public void UpdatePerception(RolePlayCharacterAsset rpc)
        {
            string b = rpc.GetBeliefValue("Entity(" + GUID + "," + Prefab + ")");

            if (b == null || !(b.Equals(Quantity.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("Entity(" + GUID + "," + Prefab + ")", Quantity.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("ChopWorkable(" + GUID + ")");
            if (b == null || !(b.Equals(ChopWorkable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("ChopWorkable(" + GUID + ")", ChopWorkable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("HammerWorkable(" + GUID + ")");
            if (b == null || !(b.Equals(HammerWorkable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("HammerWorkable(" + GUID + ")", HammerWorkable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("DigWorkable(" + GUID + ")");
            if (b == null || !(b.Equals(DigWorkable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("DigWorkable(" + GUID + ")", DigWorkable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("MineWorkable(" + GUID + ")");
            if (b == null || !(b.Equals(MineWorkable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("MineWorkable(" + GUID + ")", MineWorkable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("Pickable(" + GUID + ")");
            if (b == null || !(b.Equals(Pickable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("Pickable(" + GUID + ")", Pickable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("PosX(" + GUID + ")");
            if (b == null || !(b.Equals(X.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + GUID + ")", X.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */
            //b = rpc.GetBeliefValue("PosY(" + GUID + ")");
            //if ( b == null || !(b.Equals(Y.ToString())))
            //    rpc.Perceive(EventHelper.PropertyChange("PosY(" + GUID + ")", Y.ToString(), rpc.CharacterName.ToString()));

            b = rpc.GetBeliefValue("PosZ(" + GUID + ")");
            if (b == null || !(b.Equals(Z.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + GUID + ")", Z.ToString(), rpc.CharacterName.ToString()));
            }
        }
Example #3
0
        private void UpdateCoroutine()
        {
            string currentBelief = _rpc.GetBeliefValue(Consts.DIALOGUE_STATE_PROPERTY);

            while (currentBelief != Consts.STATE_SESSION_END)
            {
                _rpc.Update();
                currentBelief = _rpc.GetBeliefValue(Consts.DIALOGUE_STATE_PROPERTY);
                if (_events.Count > 0)
                {
                    SuecaEvent ev;
                    lock (eventsLock)
                    {
                        ev = _events.First();
                        _events.RemoveAt(0);
                    }

                    //wait until event is finished
                    while (!ev.Finished)
                    {
                    }

                    perceive(ev);
                    //Console.WriteLine("Event Name: " + ev.Name);
                    if (ev.Name == Consts.STATE_NEXT_PLAYER)
                    {
                        if (_randomNumberGenerator.Next(0, 10) < 6)
                        {
                            // Sleep randomly until decide
                            Thread.Sleep(_randomNumberGenerator.Next(2000, 5000));
                            if (_events.Count == 0)
                            {
                                //decide only if after sleeping no one has played
                                decide(ev);
                            }
                        }
                    }
                    else
                    {
                        decide(ev);
                    }
                }

                Thread.Sleep(500);
            }
        }
        private IEnumerator UpdateCoroutine()
        {
            _events.Clear();
            while (m_rpc.GetBeliefValue(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER)) != IATConsts.TERMINAL_DIALOGUE_STATE)
            {
                yield return(new WaitForSeconds(0.1f));

                if (_events.Count == 0)
                {
                    m_rpc.Update();
                    continue;
                }



                m_rpc.Perceive(_events);



                var action = m_rpc.Decide().FirstOrDefault();

                _events.Clear();
                m_rpc.Update();

                if (action == null)
                {
                    continue;
                }

                Debug.Log("Action Key: " + action.Key);

                if (canSpeak)
                {
                    switch (action.Key.ToString())
                    {
                    case "Speak":
                        m_activeController.StartCoroutine(HandleSpeak(action));
                        canSpeak = false;
                        break;

                    case "Disconnect":
                        m_activeController.StartCoroutine(newHandleDisconnect());
                        m_dialogController.AddDialogLine(string.Format("- {0} disconnects -", m_rpc.CharacterName));

                        _currentCoroutine = null;
                        Object.Destroy(_body.Body);
                        break;

                    default:
                        Debug.LogWarning("Unknown action: " + action.Key);
                        break;
                    }
                }
            }
        }
Example #5
0
    private IEnumerator UpdateCoroutine()
    {
        string currentBelief = rpc.GetBeliefValue("State(Game)");

        while (currentBelief != "Game(End)" && !isStopped)
        {
            rpc.Update();
            yield return(new WaitForSeconds(0.1f));
        }
        yield return(null);
    }
Example #6
0
        private void PerceivePropertyChanged(RolePlayCharacterAsset rpc)
        {
            /*
             * Update the KB with the new belief if it is different from the current belief
             * */
            string bv = rpc.GetBeliefValue(Name);

            if (bv == null || !bv.Equals(Value.ToString()))
            {
                Debug.WriteLine(Name + ": " + bv + " -> " + Value.ToString());
                rpc.Perceive(EventHelper.PropertyChange(Name, Value, Subject));
            }
        }
Example #7
0
        private IEnumerator UpdateCoroutine()
        {
            while (m_rpc.GetBeliefValue(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER)) != IATConsts.TERMINAL_DIALOGUE_STATE)
            {
                yield return(new WaitForSeconds(1));

                if (_body._speechController.IsPlaying)
                {
                    continue;
                }

                var action = m_rpc.Decide().Shuffle().FirstOrDefault();
                _events.Clear();
                m_rpc.Update();

                if (action == null)
                {
                    continue;
                }

                switch (action.Key.ToString())
                {
                case "Speak":
                    m_activeController.StartCoroutine(HandleSpeak(action));

                    break;

                case "Disconnect":
                    m_activeController.StartCoroutine(HandleDisconnect());
                    m_dialogController.AddDialogLine(string.Format("- {0} disconnects -", m_rpc.CharacterName));

                    _currentCoroutine = null;
                    Object.Destroy(_body.Body);
                    GameObject.FindObjectOfType <SingleCharacterDemo>().Restart();
                    break;

                default:
                    Debug.LogWarning("Unknown action: " + action.Key);
                    break;
                }
            }
        }
Example #8
0
        public void UpdatePerception(RolePlayCharacterAsset rpc)
        {
            string b = rpc.GetBeliefValue("Entity(" + GUID + ")");

            if (b == null || !(b.Equals(Prefab.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("Entity(" + GUID + ")", Prefab.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("Quantity(" + GUID + ")");
            if (b == null || !(b.Equals(Quantity.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("Quantity(" + GUID + ")", Quantity.ToString(), rpc.CharacterName.ToString()));
            }

            //====================================================
            b = rpc.GetBeliefValue("IsCollectable(" + GUID + ")");
            if (b == null || !(b.Equals(IsCollectable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsCollectable(" + GUID + ")", IsCollectable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsCooker(" + GUID + ")");
            if (b == null || !(b.Equals(IsCooker.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsCooker(" + GUID + ")", IsCooker.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsCookable(" + GUID + ")");
            if (b == null || !(b.Equals(IsCookable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsCookable(" + GUID + ")", IsCookable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsEdible(" + GUID + ")");
            if (b == null || !(b.Equals(IsEdible.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsEdible(" + GUID + ")", IsEdible.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsEquippable(" + GUID + ")");
            if (b == null || !(b.Equals(IsEquippable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsEquippable(" + GUID + ")", IsEquippable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsFuel(" + GUID + ")");
            if (b == null || !(b.Equals(IsFuel.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsFuel(" + GUID + ")", IsFuel.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsFueled(" + GUID + ")");
            if (b == null || !(b.Equals(IsFueled.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsFueled(" + GUID + ")", IsFueled.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsGrower(" + GUID + ")");
            if (b == null || !(b.Equals(IsGrower.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsGrower(" + GUID + ")", IsGrower.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsHarvestable(" + GUID + ")");
            if (b == null || !(b.Equals(IsHarvestable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsHarvestable(" + GUID + ")", IsHarvestable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsPickable(" + GUID + ")");
            if (b == null || !(b.Equals(IsPickable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsPickable(" + GUID + ")", IsPickable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsStewer(" + GUID + ")");
            if (b == null || !(b.Equals(IsStewer.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsStewer(" + GUID + ")", IsStewer.ToString(), rpc.CharacterName.ToString()));
            }

            //==================================================
            b = rpc.GetBeliefValue("IsChoppable(" + GUID + ")");
            if (b == null || !(b.Equals(IsChoppable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsChoppable(" + GUID + ")", IsChoppable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsHammerable(" + GUID + ")");
            if (b == null || !(b.Equals(IsHammerable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsHammerable(" + GUID + ")", IsHammerable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsDiggable(" + GUID + ")");
            if (b == null || !(b.Equals(IsDiggable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsDiggable(" + GUID + ")", IsDiggable.ToString(), rpc.CharacterName.ToString()));
            }

            b = rpc.GetBeliefValue("IsMineable(" + GUID + ")");
            if (b == null || !(b.Equals(IsMineable.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("IsMineable(" + GUID + ")", IsMineable.ToString(), rpc.CharacterName.ToString()));
            }

            //===========================================
            b = rpc.GetBeliefValue("PosX(" + GUID + ")");
            if (b == null || !(b.Equals(X.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + GUID + ")", X.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */

            b = rpc.GetBeliefValue("PosZ(" + GUID + ")");
            if (b == null || !(b.Equals(Z.ToString())))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + GUID + ")", Z.ToString(), rpc.CharacterName.ToString()));
            }
        }
Example #9
0
        public void UpdatePerceptions(RolePlayCharacterAsset rpc)
        {
            /*
             * Find every InSight, InInventory, and IsEquipped belief and set them to false
             * */
            CleanBeliefs(rpc);

            /*
             * Update the KB with the new beliefs
             * */
            string bv = rpc.GetBeliefValue("Hunger(" + rpc.CharacterName.ToString() + ")");

            if (bv == null || !bv.Equals(Hunger.ToString()))
            {
                Debug.WriteLine("Hunger: " + bv + " -> " + Hunger.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Hunger(" + rpc.CharacterName.ToString() + ")", Hunger.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Health(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Health.ToString()))
            {
                Debug.WriteLine("Health: " + bv + " -> " + Health.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Health(" + rpc.CharacterName.ToString() + ")", Health.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Sanity(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Sanity.ToString()))
            {
                Debug.WriteLine("Sanity: " + bv + " -> " + Sanity.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Sanity(" + rpc.CharacterName.ToString() + ")", Sanity.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsFreezing(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsFreezing.ToString()))
            {
                Debug.WriteLine("IsFreezing: " + bv + " -> " + IsFreezing.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsFreezing(" + rpc.CharacterName.ToString() + ")", IsFreezing.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsOverheating(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsOverheating.ToString()))
            {
                Debug.WriteLine("IsOverheating: " + bv + " -> " + IsOverheating.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsOverheating(" + rpc.CharacterName.ToString() + ")", IsOverheating.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Moisture(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Moisture.ToString()))
            {
                Debug.WriteLine("Moisture: " + bv + " -> " + Moisture.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Moisture(" + rpc.CharacterName.ToString() + ")", Moisture.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Temperature(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Temperature.ToString()))
            {
                Debug.WriteLine("Temperature: " + bv + " -> " + Temperature.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Temperature(" + rpc.CharacterName.ToString() + ")", Temperature.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsBusy(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsBusy.ToString()))
            {
                Debug.WriteLine("IsBusy: " + bv + " -> " + IsBusy.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsBusy(" + rpc.CharacterName.ToString() + ")", IsBusy.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("PosX(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosX.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + rpc.CharacterName.ToString() + ")", PosX.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */
            //bv = rpc.GetBeliefValue("PosY(" + rpc.CharacterName.ToString() + ")");
            //if (bv == null || !bv.Equals(PosY.ToString()))
            //    rpc.Perceive(EventHelper.PropertyChange("PosY(" + rpc.CharacterName.ToString() + ")", PosY.ToString(), rpc.CharacterName.ToString()));

            bv = rpc.GetBeliefValue("PosZ(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosZ.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + rpc.CharacterName.ToString() + ")", PosZ.ToString(), rpc.CharacterName.ToString()));
            }


            foreach (Item i in Vision)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InSight(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InSight(" + i.GUID + ")", "True", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (Item i in ItemSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InInventory(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InInventory(" + i.GUID + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (EquippedItems i in EquipSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("IsEquipped(" + i.GUID + "," + i.Slot + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("IsEquipped(" + i.GUID + "," + i.Slot + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            rpc.Update();
        }
Example #10
0
        private void UpdateCoroutine()
        {
            string currentBelief = _rpc.GetBeliefValue(Consts.DIALOGUE_STATE_PROPERTY);

            while (currentBelief != Consts.STATE_SESSION_END)
            {
                //showEmotions();
                _rpc.Update();
                currentBelief = _rpc.GetBeliefValue(Consts.DIALOGUE_STATE_PROPERTY);
                if (_events.Count > 0)
                {
                    SuecaEvent ev;
                    lock (eventsLock)
                    {
                        ev = _events.First();
                        _events.RemoveAt(0);
                    }

                    //wait until event is finished
                    while (!ev.Finished)
                    {
                    }

                    if (ev.Name == Consts.STATE_SHUFFLE || ev.Name == Consts.STATE_SESSION_START)
                    {
                        //Console.WriteLine("Resetting Posture");
                        EmotionalSuecaPlayer.SuecaPub.SetPosture("", "neutral");
                    }
                    if (ev.Name == Consts.INIT)
                    {
                        _rpc.CharacterName = (Name)ev.OtherStringInfos[0];
                        _rpc.m_kb.SetPerspective((Name)ev.OtherStringInfos[0]);
                    }
                    if (ev.Name == Consts.STATE_TRICK_END)
                    {
                        Console.WriteLine("\nCLEANING EMOTIONAL POOL\n");
                        _rpc.ResetEmotionalState();
                    }

                    perceive(ev);

                    if (ev.Name == Consts.STATE_NEXT_PLAYER)
                    {
                        if (ev.OtherIntInfos.Length > 0 && !_esp.Talking)
                        {
                            Thread.Sleep(_randomNumberGenerator.Next(0, 2000));
                            EmotionalSuecaPlayer.SuecaPub.GazeAtTarget("player" + ev.OtherIntInfos[0]);
                        }

                        if (_randomNumberGenerator.Next(0, 10) < 6)
                        {
                            // Sleep randomly until decide
                            Thread waitForDeciding = new Thread(this.SleepForNextPlayerEvent);
                            waitForDeciding.Start();
                            while (!_sleepNotify && _events.Count == 0)
                            {
                            }
                            waitForDeciding.Interrupt();
                            _sleepNotify = false;
                            if (_events.Count == 0)
                            {
                                //decide only if after sleeping no one has played
                                decide(ev);
                            }
                        }
                    }
                    else if (ev.Name == Consts.STATE_PLAYSELF)
                    {
                        EmotionalSuecaPlayer.SuecaPub.GazeAtTarget("cardsZone");
                        if (ev.OtherStringInfos.Length > 0)
                        {
                            Thread.Sleep(1000);
                            decide(ev);
                            Thread.Sleep(1000);
                            EmotionalSuecaPlayer.SuecaPub.Play(ev.OtherIntInfos[0], ev.OtherStringInfos[0], ev.OtherStringInfos[1]);
                        }
                    }
                    else if (ev.Name == Consts.STATE_PLAYPARTNER)
                    {
                        Thread.Sleep(1000);
                        decide(ev);

                        if (ev.OtherIntInfos[0] == ((_esp._id + 2) % 4))
                        {
                            string attributionEmotion = getStrongestAttributionEmotion(_rpc.GetAllActiveEmotions());
                            EmotionalSuecaPlayer.SuecaPub.SetPosture("", attributionEmotion);
                        }
                        else
                        {
                            string wellbeingEmotion = getStrongestWellbeingEmotion(_rpc.GetAllActiveEmotions());
                            EmotionalSuecaPlayer.SuecaPub.SetPosture("", wellbeingEmotion);
                        }
                    }
                    else if (ev.Name != Consts.INIT)
                    {
                        decide(ev);
                    }
                }
                Thread.Sleep(100);
            }
        }
Example #11
0
    public IEnumerator UpdateCoroutine()
    {
        while (m_rpc.GetBeliefValue(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER)) != IATConsts.TERMINAL_DIALOGUE_STATE)
        {
            yield return(new WaitForSeconds(1));

            if (_body._speechController.IsPlaying)
            {
                continue;
            }

            var action = m_rpc.Decide().FirstOrDefault();

            if (action == null)
            {
                Debug.Log(RPC.CharacterName.ToString() + " decided: nothing");
            }
            else
            {
                Debug.Log(RPC.CharacterName.ToString() + " decided: " + action.Key);
            }

            _events.Clear();
            m_rpc.Update();
            UpdateEmotionExpression();
            if (action == null)
            {
                continue;
            }



            lastAction = action;
            if (action != null)
            {
                Debug.Log(RPC.CharacterName.ToString() + " decision is:" + action.Name + " towards " + action.Target);

                switch (action.Key.ToString())
                {
                case "Speak":

                    updateHeadController(action.Target.ToString());
                    GameObject.FindGameObjectWithTag(action.Target.ToString())
                    .GetComponentInChildren <HeadLookController>()._target = this._body.gameObject;


                    m_activeController.StartCoroutine(HandleSpeak(action));

                    break;

                case "Disconnect":
                    m_activeController.StartCoroutine(newHandleDisconnect());
                    m_dialogController.AddDialogLine(string.Format("- {0} disconnects -", m_rpc.CharacterName));

                    _currentCoroutine = null;
                    Object.Destroy(_body.Body);
                    break;

                default:
                    Debug.LogWarning("Unknown action: " + action.Key);
                    break;
                }
            }
        }
    }
Example #12
0
 private void UpdateCurrentState()
 {
     CurrentCharacter.Perceive(_events);
     _events.Clear();
     _currentStateName = (Name)CurrentCharacter.GetBeliefValue("DialogueState(Player)");
 }