From 17c684a98dd8811fd22ced8da1590e08d3bc4831 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期日, 28 四月 2019 10:32:26 +0800
Subject: [PATCH] Merge branch 'master' into ViewOtherPlayer

---
 Fight/MapTransferUtility.cs |  125 ++++++++++++++++++++++-------------------
 1 files changed, 67 insertions(+), 58 deletions(-)

diff --git a/Fight/MapTransferUtility.cs b/Fight/MapTransferUtility.cs
index 083693d..9ac3d90 100644
--- a/Fight/MapTransferUtility.cs
+++ b/Fight/MapTransferUtility.cs
@@ -236,9 +236,10 @@
     {
         public int npcID;
         public int sid;
+        public bool directTransfer;
     }
 
-    public void MoveToNPC(int _npcID, int _sid = 0)
+    public void MoveToNPC(int _npcID, int _sid = 0, bool direct = false)
     {
 #if UNITY_EDITOR
         Debug.LogFormat("鎯宠鍒囨崲鑷崇洰鏍噉pc: {0}", _npcID);
@@ -247,7 +248,8 @@
         var _data = new MoveToData
         {
             npcID = _npcID,
-            sid = _sid
+            sid = _sid,
+            directTransfer = direct
         };
         StartCoroutine("CoMoveToNPC", _data);
     }
@@ -307,80 +309,87 @@
             // 鍒ゆ柇鏄惁鍦ㄥ悓涓�寮犲湴鍥句腑
             if (_npcLocation.mapId != PlayerDatas.Instance.baseData.MapID)
             {
-                int _idx1 = m_TransMapLine.IndexOf(PlayerDatas.Instance.baseData.MapID);
-                int _idx2 = m_TransMapLine.IndexOf(_npcLocation.mapId);
-                bool _valid = true;
-                if (_idx1 == -1)
+                if (data.directTransfer)
                 {
-                    _valid = false;
-                    Debug.LogErrorFormat("瀵绘壘鐨勫湴鍥綢D涓嶅湪绾胯矾涓�: {0}", PlayerDatas.Instance.baseData.MapID);
+                    _MoveToNPC(NpcID, sid);
                 }
-                if (_idx2 == -1)
+                else
                 {
-                    _valid = false;
-                    Debug.LogErrorFormat("瀵绘壘鐨勫湴鍥綢D涓嶅湪绾胯矾涓�: {0}", _npcLocation.mapId);
-                }
-                if (_valid)
-                {
-                    int _nextMapID = -1;
-                    // 椤哄簭
-                    if (_idx2 > _idx1)
+                    int _idx1 = m_TransMapLine.IndexOf(PlayerDatas.Instance.baseData.MapID);
+                    int _idx2 = m_TransMapLine.IndexOf(_npcLocation.mapId);
+                    bool _valid = true;
+                    if (_idx1 == -1)
                     {
-                        _nextMapID = m_TransMapLine[_idx1 + 1];
+                        _valid = false;
+                        Debug.LogErrorFormat("瀵绘壘鐨勫湴鍥綢D涓嶅湪绾胯矾涓�: {0}", PlayerDatas.Instance.baseData.MapID);
                     }
-                    // 閫嗗簭
-                    else
+                    if (_idx2 == -1)
                     {
-                        _nextMapID = m_TransMapLine[_idx1 - 1];
+                        _valid = false;
+                        Debug.LogErrorFormat("瀵绘壘鐨勫湴鍥綢D涓嶅湪绾胯矾涓�: {0}", _npcLocation.mapId);
                     }
-
-                    // 鍏堝鎵句紶閫佺偣
-                    int _transportID = GetNextTransportID(PlayerDatas.Instance.baseData.MapID,
-                                                          _nextMapID);
-                    if (_transportID != -1)
+                    if (_valid)
                     {
-                        if (_curStage)
+                        int _nextMapID = -1;
+                        // 椤哄簭
+                        if (_idx2 > _idx1)
                         {
-                            Vector3 _moveToPos;
-                            if (_curStage.TryGetTransportPosition(_transportID, out _moveToPos))
+                            _nextMapID = m_TransMapLine[_idx1 + 1];
+                        }
+                        // 閫嗗簭
+                        else
+                        {
+                            _nextMapID = m_TransMapLine[_idx1 - 1];
+                        }
+
+                        // 鍏堝鎵句紶閫佺偣
+                        int _transportID = GetNextTransportID(PlayerDatas.Instance.baseData.MapID,
+                                                              _nextMapID);
+                        if (_transportID != -1)
+                        {
+                            if (_curStage)
                             {
-                                while (true)
+                                Vector3 _moveToPos;
+                                if (_curStage.TryGetTransportPosition(_transportID, out _moveToPos))
                                 {
-                                    if (PathFinder.WalkAble(_hero.Pos, _moveToPos))
+                                    while (true)
                                     {
-                                        break;
+                                        if (PathFinder.WalkAble(_hero.Pos, _moveToPos))
+                                        {
+                                            break;
+                                        }
+                                        var _nextPos = ClientSceneManager.Instance.GetTransPoint(_hero.Pos, _moveToPos);
+                                        // 濡傛灉鎵惧埌鐨勪笅涓�涓偣
+                                        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;
+                                        }
                                     }
-                                    var _nextPos = ClientSceneManager.Instance.GetTransPoint(_hero.Pos, _moveToPos);
-                                    // 濡傛灉鎵惧埌鐨勪笅涓�涓偣
-                                    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(_moveToPos);
+                                    yield break;
                                 }
-                                _hero.MoveToPosition(_moveToPos);
-                                yield break;
                             }
                         }
                     }
+                    _MoveToNPC(NpcID, sid);
                 }
-                _MoveToNPC(NpcID, sid);
                 yield break;
             }
             _destPostion = new Vector3(_npcLocation.position.x, 0, _npcLocation.position.y);

--
Gitblit v1.8.0