From ad4fdd79e17be122b6714380818eedfcdbe7e3a9 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期四, 25 四月 2019 14:40:57 +0800
Subject: [PATCH] 382 当前地图坐标点寻路逻辑修改

---
 Fight/MapTransferUtility.cs |  131 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 107 insertions(+), 24 deletions(-)

diff --git a/Fight/MapTransferUtility.cs b/Fight/MapTransferUtility.cs
index 5a4f1e2..083693d 100644
--- a/Fight/MapTransferUtility.cs
+++ b/Fight/MapTransferUtility.cs
@@ -890,32 +890,114 @@
         }
     }
 
-    public void MoveToLocalMapPosition(Vector2 _position)
+    public void MoveToLocalMapPosition(Vector2 pos)
     {
-        var hero = PlayerDatas.Instance.hero;
-        if (GA_Hero.s_MapSwitching || hero == null)
-        {
-            return;
-        }
-
-        MapTransferDoType = E_MapTransferDoType.None;
-        m_DelayMoveToPos = false;
-        m_TempPos = hero.Pos;
-
-        hero.Behaviour.StopHandupAI(true);
-        hero.Behaviour.StopKillUntilDieAI();
-
-        if ((hero.SkillMgr.CurCastSkill != null && !hero.SkillMgr.CurCastSkill.SkillCompelete)
-            || hero.IsRushing)
-        {
-            m_TempPos = _position;
-            m_DelayMoveToPos = true;
-            return;
-        }
-
-        hero.MoveToPosition(new Vector3(_position.x * 0.5f, 0f, _position.y * 0.5f));
-        DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
+        StartCoroutine("_MoveToLocalPos", pos);
     }
+
+    private IEnumerator _MoveToLocalPos(Vector2 pos)
+    {
+        var _hero = PlayerDatas.Instance.hero;
+        if (_hero == null || GA_Hero.s_MapSwitching)
+        {
+            yield break;
+        }
+
+        var _dest = new Vector3(pos.x, 0, pos.y);
+
+        if (PathFinder.WalkAble(_hero.Pos, _dest))
+        {
+            while (true)
+            {
+                Vector3 _nextPos = ClientSceneManager.Instance.GetNext1(_hero.Pos, _dest);
+                if (_nextPos == Vector3.zero)
+                {
+                    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;
+                }
+            }
+
+            _hero.MoveToPosition(_dest);
+            DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
+        }
+        else
+        {
+            while (true)
+            {
+                if (PathFinder.WalkAble(_hero.Pos, _dest))
+                {
+                    break;
+                }
+                var _nextPos = ClientSceneManager.Instance.GetTransPoint(_hero.Pos, _dest);
+                // 濡傛灉鎵惧埌鐨勪笅涓�涓偣
+                if (!PathFinder.WalkAble(_hero.Pos, _nextPos)
+                 || _nextPos == Vector3.zero)
+                {
+                    Debug.LogErrorFormat("绉诲姩鑷砃PC: {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;
+                }
+            }
+
+            _hero.MoveToPosition(_dest);
+            DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
+        }
+    }
+
+    // public void MoveToLocalMapPosition(Vector2 _position)
+    // {
+    //     var hero = PlayerDatas.Instance.hero;
+    //     if (GA_Hero.s_MapSwitching || hero == null)
+    //     {
+    //         return;
+    //     }
+
+    //     MapTransferDoType = E_MapTransferDoType.None;
+    //     m_DelayMoveToPos = false;
+    //     m_TempPos = hero.Pos;
+
+    //     hero.Behaviour.StopHandupAI(true);
+    //     hero.Behaviour.StopKillUntilDieAI();
+
+    //     if ((hero.SkillMgr.CurCastSkill != null && !hero.SkillMgr.CurCastSkill.SkillCompelete)
+    //         || hero.IsRushing)
+    //     {
+    //         m_TempPos = _position;
+    //         m_DelayMoveToPos = true;
+    //         return;
+    //     }
+
+    //     hero.MoveToPosition(new Vector3(_position.x * 0.5f, 0f, _position.y * 0.5f));
+    //     DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true);
+    // }
 
     public void MissionFlyTo(int mapId, int npcId, int extField = 0)
     {
@@ -1273,6 +1355,7 @@
         if (m_SwitchMapFinished)
         {
             StopCoroutine("CoMoveToNPC");
+            StopCoroutine("_MoveToLocalPos");
             NpcID = 0;
             MapTransferDoType = E_MapTransferDoType.None;
             m_DelayMoveToNPC = false;

--
Gitblit v1.8.0