public void OnNPCEnter(GameObject npcTarget, int refNPCTarget)
 {
     // Check Wait InteractionNPC
     if (mOnInteractionNPC != null && !string.IsNullOrEmpty(mNPCRefWait) && npcTarget.name.IndexOf(mNPCRefWait) == 0)
     {
         var action = mOnInteractionNPC;
         mOnInteractionNPC = null;
         mNPCRefWait       = null;
         if (action(refNPCTarget))
         {
             return;
         }
     }
     if (IsScriptMainRunning || mTargetWait != null)
     {
         return;
     }
     if (refNPCTarget >= 0 && refNPCTarget < AutoTileMap_Editor.Instance.MapSelect.NPCData.Count)
     {
         // if(nav.hasPath == false){
         //  return;
         // }
         var npc = AutoTileMap_Editor.Instance.MapSelect.NPCData[refNPCTarget];
         if (npc.RunScript && npc.IdxScript >= 0 && npc.IdxScript < AutoTileMap_Editor.Instance.MapSelect.ScriptData.Count)
         {
             string btTextWait;
             if (npc.nameNpc != null && npc.nameNpc.Length > 0)
             {
                 btTextWait = "Talk to " + npc.nameNpc;
             }
             else
             {
                 btTextWait = "Talk";
             }
             mTargetWait    = npcTarget;
             mIdxScriptWait = npc.IdxScript;
             CreateObjInteractionNPC(npcTarget);
             // Pause target
             int        mapIdx     = AutoTileMap_Editor.Instance.MapIdxSelect;
             ScriptGame s_from_npc = GetScriptGameCache_NPC_Begin(npcTarget, false);
             AddScriptNeedResume(s_from_npc);
             // Lock to NPC
             NpcLookatDCallback.InstanceOf(npcTarget).LookTo(AutoTileMap_Editor.Instance.Agent.transform, null);
             // Stop MainChar
             var nav = AutoTileMap_Editor.Instance.Agent.GetComponent <NavMeshAgentCallback>();
             nav.ResetPath();
             //
             InputFieldHelper.Instance.Show_Menu_BtTalk(btTextWait, () => {
                 ActiveScriptGameWait();
             });
         }
     }
 }
Example #2
0
    private void doNpcFaceTo(ScriptGui.NPCAction npc, Vector3 to)
    {
        GameObject npcOBJ = GetNPCTarget(npc);

        if (npcOBJ != null && npcOBJ.activeSelf)
        {
            mActionWait = npc;
            NpcLookatDCallback.InstanceOf(npcOBJ).LookTo(to, (NpcLookatDCallback n) => {
                mActionWait = null;
                this.NextActionTo(npc.Next, 0);
            });
        }
    }