| | |
| | | |
| | | private List<MapTrasfer> m_ChkedList = new List<MapTrasfer>(); |
| | | private List<MapTrasfer> m_ChkedList1 = new List<MapTrasfer>(); |
| | | |
| | | private int count = 0; |
| | | public Vector3 GetTransPoint(Vector3 start, Vector3 next) |
| | | { |
| | | count = 0; |
| | | m_ChkedList.Clear(); |
| | | |
| | | return GetNext(start, next); |
| | |
| | | |
| | | private Vector3 GetNext(Vector3 start, Vector3 next) |
| | | { |
| | | count += 1; |
| | | if (count > 20 || next == Vector3.zero) |
| | | { |
| | | return Vector3.zero; |
| | | } |
| | | Vector3 _targetPos = Vector3.zero; |
| | | // 遍历寻找到可移动至目标点的跳跃点 |
| | | foreach (var _t in m_MapData.transfers) |
| | |
| | | |
| | | for (int i = 0; i < _t.transferPoints.Length; ++i) |
| | | { |
| | | if (PathFinder.WalkAble(next, _t.transferPoints[i].position)) |
| | | var _tp = _t.transferPoints[i]; |
| | | if (PathFinder.WalkAble(next, _tp.position)) |
| | | { |
| | | if (i == 0) |
| | | { |
| | |
| | | { |
| | | _targetPos = _t.transferPoints[0].position; |
| | | } |
| | | |
| | | m_ChkedList.Add(_t); |
| | | break; |
| | | |
| | | if (PathFinder.WalkAble(start, _targetPos)) |
| | | { |
| | | return _targetPos; |
| | | } |
| | | else |
| | | { |
| | | _targetPos = GetNext(start, _targetPos); |
| | | } |
| | | } |
| | | } |
| | | if (_targetPos != Vector3.zero) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!PathFinder.WalkAble(start, _targetPos)) |
| | | { |
| | | return GetNext(start, _targetPos); |
| | | } |
| | | |
| | | return _targetPos; |