void OnSwipe(SwipeGesture gesture) { searchType = SearchPathType.SwipeToWalk; swipeIndexList.Clear(); swipeIndexListRaw.Clear(); foreach (Vector2 item in gesture.VectorsInProgress) { Vector3 bgPos = CameraHelper.ScreenPosToBackgroundPos(item); int index = m_pathGrid.GetCellIndexClamped(bgPos); if (m_pathGrid.IsBlocked(index)) { continue; } if (swipeIndexListRaw.Count == 0) { swipeIndexListRaw.Add(index); continue; } if (swipeIndexListRaw[swipeIndexListRaw.Count - 1] != index) { swipeIndexListRaw.Add(index); } } swipeIndexList = m_pathGrid.CornerIndexs(swipeIndexListRaw); swipeIndexListIndex = 0; m_navigationAgent.MoveToIndex(swipeIndexList.ToArray()); }
void OnTap(TapGesture gesture) { searchType = SearchPathType.TapToWalk; Vector3 interactPos = CameraHelper.ScreenPosToBackgroundPos(gesture.StartPosition); int index = m_pathGrid.GetCellIndex(interactPos); if (index == SimpleAI.Planning.Node.kInvalidIndex) { return; } int[] indexArray = new int[] { index }; m_navigationAgent.MoveToIndex(indexArray); }