少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-16 73e998b35edbc101366c40860269c6f96e78e559
Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
2个文件已修改
101 ■■■■ 已修改文件
Fight/MapTransferUtility.cs 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/Stage/MapEditor/Game/ClientSceneManager.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/MapTransferUtility.cs
@@ -264,27 +264,35 @@
        }
        else
        {
            // 不可达的情况, 这里寻找是否有可以跳跃的点
            Vector3 _jumpPos = ClientSceneManager.Instance.GetCloseTransPoint(_destPostion);
            if (_jumpPos == Vector3.zero)
            while (true)
            {
                Debug.LogErrorFormat("移动至NPC: {0} 时找不到任何跳跃点", npcID);
                yield break;
            }
            float _dis = MathUtility.DistanceSqrtXZ(_hero.Pos, _jumpPos);
            while (_dis > 0.01f)
            {
                _dis = MathUtility.DistanceSqrtXZ(_hero.Pos, _jumpPos);
                _hero.MoveToPosition(_jumpPos);
                yield return null;
            }
            while (!GA_Hero.s_Flying)
            {
                yield return null;
            }
            while (GA_Hero.s_Flying)
            {
                yield return null;
                if (PathFinder.WalkAble(_hero.Pos, _destPostion, _dist))
                {
                    break;
                }
                var _nextPos = ClientSceneManager.Instance.GetTransPoint(_hero.Pos, _destPostion);
                // 如果找到的下一个点
                if (!PathFinder.WalkAble(_hero.Pos, _nextPos)
                 || _nextPos == Vector3.zero)
                {
                    Debug.LogErrorFormat("移动至NPC: {0} 时找不到任何跳跃点", npcID);
                    break;
                }
                float _dis = MathUtility.DistanceSqrtXZ(_hero.Pos, _nextPos);
                while (_dis > 0.01f)
                {
                    _dis = MathUtility.DistanceSqrtXZ(_hero.Pos, _nextPos);
                    _hero.MoveToPosition(_nextPos);
                    yield return null;
                }
                while (!GA_Hero.s_Flying)
                {
                    yield return null;
                }
                while (GA_Hero.s_Flying)
                {
                    yield return null;
                }
            }
            _MoveToNPC(npcID, sid);
        }
Fight/Stage/MapEditor/Game/ClientSceneManager.cs
@@ -250,13 +250,58 @@
        return null;
    }
    private List<MapTrasfer> m_ChkedList = new List<MapTrasfer>();
    public Vector3 GetTransPoint(Vector3 start, Vector3 next)
    {
        m_ChkedList.Clear();
        return GetNext(start, next);
    }
    private Vector3 GetNext(Vector3 start, Vector3 next)
    {
        Vector3 _targetPos = Vector3.zero;
        // 遍历寻找到可移动至目标点的跳跃点
        foreach (var _t in m_MapData.transfers)
        {
            if (m_ChkedList.Contains(_t))
            {
                continue;
            }
            for (int i = 0; i < _t.transferPoints.Length; ++i)
            {
                if (PathFinder.WalkAble(next, _t.transferPoints[i].position))
                {
                    if (i == 0)
                    {
                        _targetPos = _t.transferPoints[_t.transferPoints.Length - 1].position;
                    }
                    else
                    {
                        _targetPos = _t.transferPoints[0].position;
                    }
                    m_ChkedList.Add(_t);
                    break;
                }
            }
            if (_targetPos != Vector3.zero)
            {
                break;
            }
        }
        if (!PathFinder.WalkAble(start, _targetPos))
        {
            return GetNext(start, _targetPos);
        }
        return _targetPos;
    }
    public Vector3 GetCloseTransPoint(Vector3 pos)
    {
        // 遍历找到离给定点最近并且可寻路至的传送点 P
        // 找到 P点的 另一端 P1
        // 判断当前传入的点是否可以寻路至 P1
        // 不行的话重新寻找 可以的话返回 P1 的坐标
        Vector3 _targetPos = Vector3.zero;
        foreach (var _t in m_MapData.transfers)