private static int OnTargetReached(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 1); AIPath aIPath = (AIPath)ToLua.CheckObject(L, 1, typeof(AIPath)); aIPath.OnTargetReached(); result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
// public void CancelMess() // { // Agent agent = (Agent)rvoAgent; // AIPath myAi = GetComponent<AIPath> (); // if (myAi.isSingleSearch) { // List<Agent> neighours = agent.neighbours; // myAi.CancelCurrentPath (); // // } // } public void FindNeighour() { Agent agent = (Agent)rvoAgent; AIPath myAi = GetComponent <AIPath> (); if (myAi.TargetReached) { return; } List <Agent> neighours = agent.neighbours; if (myAi.isSingleSearch) { for (int i = 0; i < neighours.Count; i++) { if (neighours == null || neighours[i] == null || neighours[i].parent == null) { continue; } if (i >= neighours.Count || i < 0) { continue; } AIPath neighourAi = neighours[i].parent.GetComponent <AIPath>(); if (myAi.CheckInLine(myAi.lastTargetPos, neighourAi.GetFeetPosition())) { float ABDist = (myAi.lastTargetPos - myAi.GetFeetPosition()).magnitude; if (ABDist < neighbourDist * 2) { myAi.OnTargetReached(); break; } } } } else { for (int i = 0; i < neighours.Count; i++) { if (neighours == null || neighours[i] == null || neighours[i].parent == null) { continue; } if (i >= neighours.Count || i < 0) { continue; } AIPath neighourAi = neighours[i].parent.GetComponent <AIPath>(); if (neighourAi != null && neighourAi.TargetReached) { //myAi.OnTargetReached(); if (myAi.CheckInLine(myAi.GetFeetPosition(), neighourAi.GetFeetPosition())) { if (myAi.lastTargetPos != Vector3.zero) { Vector3 dir = myAi.lastTargetPos - myAi.GetFeetPosition(); Vector3 up = Vector3.Cross(dir, Vector3.right); if (lastMoveTime + 0.1 > Time.realtimeSinceStartup) { rotateposi *= -1; lastMoveTime = Time.realtimeSinceStartup; } dir = Quaternion.AngleAxis(rotateposi * 90, up) * dir * (maxSpeed); //myAi.endReachedDistance = 3.0f; Move(dir); } } break; } } } }