예제 #1
0
        public IEnumerator OnUpdate()
        {
            while (true)
            {
                if (_npc.Agent.remainingDistance < 0.1f)
                {
                    if (_reached == false)
                    {
                        StartCoroutine(WaitUntilMeetingEnds());
                        _reached             = true;
                        _npc.Agent.isStopped = true;
                        _animator.SetBool(MeetingBool, true);
                        if (partnerNPC.Animator.GetBool(TalkingBool) == false)
                        {
                            var randomTalkID = Random.Range(0, 3);
                            _animator.SetBool(TalkingBool, true);
                            _animator.SetInteger(TalkID, randomTalkID);
                        }
                        else
                        {
                            _animator.SetBool(ListeningBool, true);
                            _startListeningTime = Time.time;
                        }
                    }
                }

                if (_reached)
                {
                    if (_animator.GetBool(ListeningBool))
                    {
                        if (Time.time - _startListeningTime > _listeningDuration)
                        {
                            Debug.Log($"<color=red> Swith conversation {_npc.name} </color>");
                            var randomTalkID = Random.Range(0, 3);
                            _animator.SetInteger(TalkID, randomTalkID);
                            _animator.SetBool(TalkingBool, true);
                            _animator.SetBool(ListeningBool, false);

                            partnerNPC.Animator.SetBool(TalkingBool, false);
                            partnerNPC.Animator.SetBool(ListeningBool, true);
                            partnerNPC.GetComponent <MeetBehaviour>()._startListeningTime = Time.time;
                            partnerNPC.GetComponent <MeetBehaviour>()._listeningDuration  = Random.Range(4f, 10f);
                        }
                    }
                }

                yield return(null);
            }
        }
예제 #2
0
 private void OnCollisionStay(Collision other)
 {
     if (_npc.GetComponent <TypingBehaviour>() == null)
     {
         _occupied = false;
         // if(_dictionary.
         //     )
         _dictionary.Add(_npc, Time.time);
     }
 }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        _npc = other.gameObject.GetComponent <AgentNPC>();

        if (_npc != null && _occupied == false && _npc.GetComponent <TypingBehaviour>() == null)
        {
            _occupied = true;
            var typingBehaviour = _npc.gameObject.AddComponent <TypingBehaviour>();
            typingBehaviour.targetPosition     = destination;
            typingBehaviour.chairFinalPosition = chairFinalPosition.transform.position;
            typingBehaviour.chair = chair;
            typingBehaviour.mouse = mouse;
            typingBehaviour.correctSittingPosition = chairCorrectPosition.transform.localPosition;
            Debug.Log(typingBehaviour.targetPosition);
            _npc.SetBehaviour(typingBehaviour);
            _collider.enabled = false;
        }
    }