From d2ff47a31afe4167a78eb76e44cabdb1025c16fc Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期四, 25 四月 2019 21:54:26 +0800
Subject: [PATCH] 382 自动拾取前端掉落物
---
Fight/ClientDropItemUtility.cs | 29 ++++++++++++++
Fight/Actor/AI/HeroAI_Base.cs | 39 ++++++++++++++-----
2 files changed, 57 insertions(+), 11 deletions(-)
diff --git a/Fight/Actor/AI/HeroAI_Base.cs b/Fight/Actor/AI/HeroAI_Base.cs
index 7fc2776..37ec38c 100644
--- a/Fight/Actor/AI/HeroAI_Base.cs
+++ b/Fight/Actor/AI/HeroAI_Base.cs
@@ -219,10 +219,11 @@
{
GA_Hero _hero = PlayerDatas.Instance.hero;
DropItemManager.DropObject _obj = null;
- if (DropItemManager.HandupTryGetHeroItem(out _obj))
- {
- bool _needPickupSelf = true;
+ bool _needPickupSelf = true;
+ Vector3 _destPosition = _hero.Pos;
+ if (_needPickupSelf = DropItemManager.HandupTryGetHeroItem(out _obj))
+ {
// 鏈夋帀钀界墿
// 鏄惁鏄己鍒跺畧鎶や笉鑳芥嬀鍙栫殑
if (_obj.ownerType != 7)
@@ -263,16 +264,32 @@
if (_needPickupSelf)
{
- _hero.StopRush();
- Vector3 _targetPosition = _obj.dropItem.transform.position;
- float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _targetPosition);
- if (_chkDistSqrt > 0.5f)
- {
- _hero.MoveToPosition(_targetPosition);
- }
- return true;
+ _destPosition = _obj.dropItem.transform.position;
}
}
+
+ if (!_needPickupSelf)
+ {
+ DropItem _item = null;
+ if (_needPickupSelf = ClientDropItemUtility.Instance.TryGetDropItem(out _item))
+ {
+ if (_needPickupSelf)
+ {
+ _destPosition = _item.transform.position;
+ }
+ }
+ }
+
+ if (_needPickupSelf)
+ {
+ _hero.StopRush();
+ float _chkDistSqrt = MathUtility.DistanceSqrtXZ(_hero.Pos, _destPosition);
+ if (_chkDistSqrt > 0.5f)
+ {
+ _hero.MoveToPosition(_destPosition);
+ }
+ return true;
+ }
return false;
}
diff --git a/Fight/ClientDropItemUtility.cs b/Fight/ClientDropItemUtility.cs
index d415362..a15b772 100644
--- a/Fight/ClientDropItemUtility.cs
+++ b/Fight/ClientDropItemUtility.cs
@@ -14,6 +14,35 @@
private List<DropItem> m_DropItemList = new List<DropItem>();
+ public bool TryGetDropItem(out DropItem item)
+ {
+ var _hero = PlayerDatas.Instance.hero;
+
+ if (_hero == null || m_DropItemList.Count == 0)
+ {
+ item = null;
+ return false;
+ }
+
+ m_DropItemList.Sort((i1, i2) =>
+ {
+ var _d1 = MathUtility.DistanceSqrtXZ(_hero.Pos, i1.transform.position);
+ var _d2 = MathUtility.DistanceSqrtXZ(_hero.Pos, i2.transform.position);
+ if (_d2 > _d1)
+ {
+ return -1;
+ }
+ else if (_d2 < _d1)
+ {
+ return 1;
+ }
+ return 0;
+ });
+
+ item = m_DropItemList[0];
+ return true;
+ }
+
public void Update()
{
var _hero = PlayerDatas.Instance.hero;
--
Gitblit v1.8.0