少年修仙传客户端代码仓库
client_Hale
2018-09-28 8fa1381950a514b13f348311e1378820a1607e49
2046 采集小宝箱点击寻路后没开始采集;

2045 采集小宝箱,角色没有像选择的目标移动
3个文件已修改
206 ■■■■■ 已修改文件
Fight/GameActor/GA_NpcCollect.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/GA_NpcFunc.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/MapTransferUtility.cs 203 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Fight/GameActor/GA_NpcCollect.cs
@@ -345,7 +345,6 @@
        {
            PlayerTaskDatas _model = ModelCenter.Instance.GetModel<PlayerTaskDatas>();
            m_CanCollect = _model.IsGather(NpcConfig.NPCID);
            Debug.LogFormat("Npc: {0} 是否可以采集: {1}", NpcConfig.NPCID, m_CanCollect);
        }
        if (!m_CanCollect)
Fight/GameActor/GA_NpcFunc.cs
@@ -99,7 +99,7 @@
        float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, Pos);
        if (_distSqrt > Mathf.Pow(GeneralConfig.Instance.CloseNpcDist + NpcConfig.ModelRadius + 0.4f, 2))
        {
            MapTransferUtility.Instance.MoveToNPC(NpcConfig.NPCID);
            MapTransferUtility.Instance.MoveToNPC(NpcConfig.NPCID, (int)ServerInstID);
        }
        else
        {
Fight/MapTransferUtility.cs
@@ -18,11 +18,14 @@
        Fight,
    }
    private E_MapTransferDoType m_MapTransferType;
    public E_MapTransferDoType MapTransferDoType {
        get {
    public E_MapTransferDoType MapTransferDoType
    {
        get
        {
            return m_MapTransferType;
        }
        set {
        set
        {
            m_MapTransferType = value;
#if UNITY_EDITOR
            // Debug.LogFormat("设置方式: {0}", m_MapTransferType);
@@ -121,7 +124,8 @@
    #endregion
    #region npc
    public int NpcID {
    public int NpcID
    {
        get; set;
    }
    #endregion
@@ -178,6 +182,20 @@
    public void MoveToNPC(int npcID, int sid = 0)
    {
        if (sid != 0)
        {
            GActor _actor = GAMgr.Instance.GetBySID((uint)sid);
            if (_actor != null)
            {
                NpcID = npcID;
                MapTransferDoType = E_MapTransferDoType.Npc;
                MoveToExistNpc(npcID, _actor);
                return;
            }
        }
        NPCConfig _config = Config.Instance.Get<NPCConfig>(npcID);
        if (_config == null)
@@ -459,111 +477,115 @@
        {
            _npc = GAMgr.Instance.GetCloserNPC(_hero.Pos, npcID);
            // 目标点, 默认为主角坐标, 找不到任务终点的时候不移动
            Vector3 _destPos = _hero.Pos;
            MoveToExistNpc(npcID, _npc);
        }
    }
            // 计算当前坐标与目标角色的坐标差
            //GActor _npc = GAMgr.Instance.GetCloserNPC(_hero.Pos, npcID);
            //// 如果在当前地图找得到已创建出来最近的目标
            //if (_npc != null)
            //{
            //    _destPos = _npc.Pos;
            //}
            //else
            //{
            Vector2 _calculPos = _destPos;
            if (_findLocation)
    private void MoveToExistNpc(int npcID, GActor npc)
    {
        GA_Hero _hero = PlayerDatas.Instance.hero;
        NPCConfig _config = Config.Instance.Get<NPCConfig>(npcID);
        // 目标点, 默认为主角坐标, 找不到任务终点的时候不移动
        Vector3 _destPos = _hero.Pos;
        // 获取NPC位置数据
        GAStaticDefine.NPCLocation _npcLocation;
        var _findLocation = GAStaticDefine.TryGetMapNPCLocation(npcID, out _npcLocation);
        Vector2 _calculPos = _destPos;
        if (_findLocation)
        {
            _calculPos = _npcLocation.position;
        }
        _destPos = new Vector3(_calculPos.x, _hero.Pos.y, _calculPos.y);
        //}
        // 判断距离
        float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPos);
        // 判断是否需要骑马移动
        if (_distSqrt > Mathf.Pow(7, 2))
        {
            DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
        }
        float _chkDist = Mathf.Max(GeneralConfig.Instance.CloseNpcDist + _config.ModelRadius - 0.3f, 0);
        if (_config.NPCType == (int)E_NpcType.OpenWorldMap)
        {
            _chkDist = 1;
        }
        // 针对挖洞对象保持距离为0
        if (npc != null && _config.Dig == 1)
        {
            _chkDist = 0;
        }
        // 大于配置的距离, 移动至
        if (_distSqrt > Mathf.Pow(_chkDist, 2))
        {
            if (_config.NPCType == (int)E_NpcType.Fight)
            {
                _calculPos = _npcLocation.position;
                _hero.MoveToPosition(_destPos, _npcLocation.scope);
            }
            _destPos = new Vector3(_calculPos.x, _hero.Pos.y, _calculPos.y);
            //}
            // 判断距离
            float _distSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPos);
            // 判断是否需要骑马移动
            if (_distSqrt > Mathf.Pow(7, 2))
            else
            {
                DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
                if (npc != null)
                {
                    _destPos = npc.Pos;
                }
                _hero.MoveToPosition(_destPos, _chkDist);
            }
            float _chkDist = Mathf.Max(GeneralConfig.Instance.CloseNpcDist + _config.ModelRadius - 0.3f, 0);
            if (_config.NPCType == (int)E_NpcType.OpenWorldMap)
            if (s_OnHeroStartMoveToNPC != null)
            {
                _chkDist = 1;
                s_OnHeroStartMoveToNPC();
            }
            // 针对挖洞对象保持距离为0
            if (_npc != null && _config.Dig == 1)
            {
                _chkDist = 0;
            }
            // 大于配置的距离, 移动至
            if (_distSqrt > Mathf.Pow(_chkDist, 2))
        }
        // 小于距离则判断目标的类型,执行相应的逻辑
        else
        {
            if (_config != null)
            {
                if (_config.NPCType == (int)E_NpcType.Fight)
                {
                    _hero.MoveToPosition(_destPos, _npcLocation.scope);
                    _hero.Behaviour.StartHandupAI();
                }
                else if (_config.NPCType == (int)E_NpcType.Collect)
                {
                    GA_NpcCollect _collect = npc as GA_NpcCollect;
                    if (_collect != null)
                    {
                        _collect.Arrive();
                    }
                }
                else
                {
                    if (_npc != null)
                    // 如果目标已经在之前搜索中确定了
                    // 没确定其实在这里应该是异常情况
                    if (npc != null)
                    {
                        _destPos = _npc.Pos;
                    }
                        _hero.LockTarget = npc;
                        _hero.SelectTarget = npc;
                    _hero.MoveToPosition(_destPos, _chkDist);
                }
                        NPCInteractProcessor.InvokeEvent((E_NpcType)_config.NPCType, npcID, npc.ServerInstID);
                if (s_OnHeroStartMoveToNPC != null)
                {
                    s_OnHeroStartMoveToNPC();
                }
            }
            // 小于距离则判断目标的类型,执行相应的逻辑
            else
            {
                if (_config != null)
                {
                    if (_config.NPCType == (int)E_NpcType.Fight)
                    {
                        _hero.Behaviour.StartHandupAI();
                    }
                    else if (_config.NPCType == (int)E_NpcType.Collect)
                    {
                        GA_NpcCollect _collect = _npc as GA_NpcCollect;
                        if (_collect != null)
                        Vector3 _npc2heroDir = MathUtility.ForwardXZ(npc.Pos, _hero.Pos);
                        if (_config.AutomaticFace == 1)
                        {
                            _collect.Arrive();
                            npc.Forward = -_npc2heroDir;
                        }
                        _hero.Forward = _npc2heroDir;
                    }
                    // 会有为空的时候, 例如是小飞鞋飞的情况, 这里直接判断与配置的坐标的距离
                    else
                    {
                        // 如果目标已经在之前搜索中确定了
                        // 没确定其实在这里应该是异常情况
                        if (_npc != null)
                        {
                            _hero.LockTarget = _npc;
                            _hero.SelectTarget = _npc;
                            NPCInteractProcessor.InvokeEvent((E_NpcType)_config.NPCType, npcID, _npc.ServerInstID);
                            Vector3 _npc2heroDir = MathUtility.ForwardXZ(_npc.Pos, _hero.Pos);
                            if (_config.AutomaticFace == 1)
                            {
                                _npc.Forward = -_npc2heroDir;
                            }
                            _hero.Forward = _npc2heroDir;
                        }
                        // 会有为空的时候, 例如是小飞鞋飞的情况, 这里直接判断与配置的坐标的距离
                        else
                        {
                        }
                    }
                }
            }
@@ -885,6 +907,15 @@
        }
        else if (_npcConfig.NPCType == (int)E_NpcType.Collect)
        {
            float _chkDist = GeneralConfig.Instance.CloseNpcDist + _npcConfig.ModelRadius + 0.3f;
            if (_chkDistSqrt <= Mathf.Pow(_chkDist, 2))
            {
                if (!UserInputHandler.isTouched
                && (_hero.SkillMgr.CurCastSkill == null || _hero.SkillMgr.CurCastSkill.SkillCompelete))
                {
                    NPCInteractProcessor.InvokeEvent(E_NpcType.Func, NpcID, _npc.ServerInstID);
                }
            }
        }
        else
        {