From 8fa1381950a514b13f348311e1378820a1607e49 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期五, 28 九月 2018 15:04:20 +0800
Subject: [PATCH] 2046 采集小宝箱点击寻路后没开始采集;
---
Fight/MapTransferUtility.cs | 203 +++++++++++++++++++++++++++++---------------------
1 files changed, 117 insertions(+), 86 deletions(-)
diff --git a/Fight/MapTransferUtility.cs b/Fight/MapTransferUtility.cs
index 5287910..b7f4b80 100644
--- a/Fight/MapTransferUtility.cs
+++ b/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
{
--
Gitblit v1.8.0