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(); }); } } }
public bool WaitInteractionNPC(ScriptGame scriptGame, ScriptGui.MainCharAction data, OnInteractionNPC callBack) { if (IsMainChar_Wait_To_Interaction()) { return(false); } ResetObjInteraction(); mNPCRefWait = eSlotAonTypeObj.Person + "_" + data.IdNpc + "_" + AutoTileMap_Editor.Instance.MapIdxSelect; CreateObjInteractionNPC(mNPCRefWait); mOnInteractionNPC = ( int refNPCTarget) => { ResetObjInteraction(); return(callBack(refNPCTarget)); }; return(true); }