Example #1
0
        private void TryToTalk()
        {
            GameObject talker;

            if ((talker = ClickEvent.OnMouseClickTag(0, "NPC", this.Player.TalkDistance)) != null)
            {
                NpcView view = talker.GetComponent <NpcView>();
                if (view == null)
                {
                    Debug.LogError(talker.name + "不是NPC");
                }
                else
                {
                    this.Player.TalkTo(view.NPC);
                }
            }
        }
Example #2
0
 /// <summary>
 /// 与NPC交谈
 /// </summary>
 private void TalkToNPC()
 {
     if (this.CurrentState == StateID.IdleState || this.CurrentState == StateID.WalkState)
     {
         if (MYXZInputManager.Instance.GetMouseButtonDown(0))
         {
             if (!EventSystem.current.IsPointerOverGameObject()) //如果此时点击的不是UI
             {
                 Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                 RaycastHit hitInfo;
                 if (Physics.Raycast(ray, out hitInfo, this.TalkDistance)) //从鼠标向前发射一条长度为TalkDistance的射线
                 {
                     if (hitInfo.transform.CompareTag("NPC"))              //如果碰到了NPC
                     {
                         this.TalkingNpc = hitInfo.transform.GetComponent <NpcView>();
                         this.TalkingNpc.BeginTalkSignal.Dispatch(); //与此NPC进行交流
                         this.IsTalking = true;                      //Player进入交谈状态
                     }
                 }
             }
         }
     }
 }
 public NpcChatState(FSMSystem fsm, NpcView npcView) : base(fsm)
 {
     StateID       = StateID.ChatState;
     this.mNpcView = npcView;
 }
Example #4
0
 public void OnEnable()
 {
     mNpcView          = target as NpcView;
     mSerializedObject = new SerializedObject(mNpcView);
 }
 public NpcPatrolState(FSMSystem fsm, NpcView npcView) : base(fsm)
 {
     StateID       = StateID.PatrolState;
     this.mNpcView = npcView;
 }
 public NpcIdleState(FSMSystem fsm, NpcView npcView) : base(fsm)
 {
     this.StateID  = StateID.IdleState;
     this.mNpcView = npcView;
 }