| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 | 
							- using System.Collections.Generic;
 
- using Common.Utility.CombatEvent;
 
- using Core.Utility;
 
- using Fort23.Core;
 
- using Fort23.Mono;
 
- using Fort23.UTool;
 
- using GameLogic.Combat.CombatTool;
 
- using UnityEngine;
 
- using Utility;
 
- namespace GameLogic.CombatScenesTool
 
- {
 
-     public class CombatEquipFallManager : Singleton<CombatEquipFallManager>
 
-     {
 
-         private Transform herobagTran;
 
-         public Animator BagAnimator;
 
-         public BetterList<EquipFallObject> allEquipFall = new BetterList<EquipFallObject>();
 
-         public class EquipFallObject : CObject
 
-         {
 
-             private GameObjectPool GameObjectPool;
 
-             private Parabola3DPath Parabola3DPath;
 
-             private float _currTime;
 
-             private int stateIndex;
 
-             private float _addTime;
 
-             public EquipFallObjectMono EquipFallObjectMono;
 
-             public float waitTime;
 
-             public void Init(GameObjectPool GameObjectPool, Parabola3DPath Parabola3DPath, float waitTime = 2f)
 
-             {
 
-                 this.GameObjectPool = GameObjectPool;
 
-                 this.Parabola3DPath = Parabola3DPath;
 
-                 this.waitTime = waitTime;
 
-                 _addTime = 1.0f / Parabola3DPath.totalFlightTime;
 
-                 EquipFallObjectMono = GameObjectPool.own.GetComponent<EquipFallObjectMono>();
 
-                 EquipFallObjectMono.idleObject.SetActive(false);
 
-             }
 
-             public override void Dispose()
 
-             {
 
-             }
 
-             public override void ActiveObj()
 
-             {
 
-             }
 
-             public override void DormancyObj()
 
-             {
 
-                 GObjectPool.Instance.Recycle(GameObjectPool);
 
-                 GameObjectPool = null;
 
-                 CObjectPool.Instance.Recycle(Parabola3DPath);
 
-                 _currTime = 0;
 
-                 stateIndex = 0;
 
-             }
 
-             public void Update(float t)
 
-             {
 
-                 if (stateIndex == 0)
 
-                 {
 
-                     _currTime += t * _addTime * 2;
 
-                     Vector3 pos = Parabola3DPath.GetPositionAtTime(_currTime);
 
-                     GameObjectPool.own.transform.position = pos;
 
-                     if (_currTime > 1)
 
-                     {
 
-                         EquipFallObjectMono.idleObject.SetActive(true);
 
-                         stateIndex = 1;
 
-                         _currTime = 0;
 
-                     }
 
-                 }
 
-                 else if (stateIndex == 1)
 
-                 {
 
-                     _currTime += t;
 
-                     if (_currTime > waitTime)
 
-                     {
 
-                         stateIndex = 2;
 
-                         _currTime = 0;
 
-                     }
 
-                 }
 
-                 else if (stateIndex == 2)
 
-                 {
 
-                     EquipFallObjectMono.idleObject.SetActive(false);
 
-                     _currTime += t;
 
-                     Vector3 pos = CombatEquipFallManager.Instance.GetUIPos();
 
-                     var position = GameObjectPool.own.transform.position;
 
-                     float d = Vector3.SqrMagnitude(position - pos);
 
-                     float addTime = 1.0f / (d / 64);
 
-                     position = Vector3.Lerp(position,
 
-                         pos, addTime * t * 3f);
 
-                     GameObjectPool.own.transform.position = position;
 
-                     if (d < 0.3f)
 
-                     {
 
-                         if (Instance.BagAnimator != null)
 
-                         {
 
-                             Instance.BagAnimator.Play("HeroBags_pick");
 
-                         }
 
-                         CombatEquipFallManager.Instance.allEquipFall.Remove(this);
 
-                         CObjectPool.Instance.Recycle(this);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         public Vector3 GetUIPos()
 
-         {
 
-             if (herobagTran == null)
 
-             {
 
-          
 
-             }
 
-             Vector3 pos = UIManager.Instance.UIWorldToWorld(herobagTran.position);
 
-             return pos;
 
-         }
 
-         public void Init()
 
-         {
 
-             StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
 
-             EventManager.Instance.AddEventListener(CustomEventType.Combat_EquipFall, Combat_EquipFall);
 
-         }
 
-         protected void Combat_EquipFall(IEventData ievetEquia)
 
-         {
 
-             if (ievetEquia == null)
 
-             {
 
-                 return;
 
-             }
 
-             
 
-             Combat_EquipFallEventData combatEquipFallEventData = ievetEquia as Combat_EquipFallEventData;
 
-             Fall(combatEquipFallEventData.fallEquip, combatEquipFallEventData.startPos_WorldPos, combatEquipFallEventData.waitTime);
 
-         }
 
-         public override void Dispose()
 
-         {
 
-             StaticUpdater.Instance.RemoveRenderUpdateCallBack(Update);
 
-             EventManager.Instance.RemoveEventListener(CustomEventType.Combat_EquipFall, Combat_EquipFall);
 
-         }
 
-         public void Fall(string[] allEquip, Vector3 worldPos, float waitTime = 2f)
 
-         {
 
-             if (allEquip == null)
 
-             {
 
-                 return;
 
-             }
 
-             
 
-             for (int i = 0; i < allEquip.Length; i++)
 
-             {
 
-                 GObjectPool.Instance.FetchAsync<GameObjectPool>(allEquip[i], delegate(GameObjectPool pool)
 
-                 {
 
-                     EquipFallObject equipFallObject = CObjectPool.Instance.Fetch<EquipFallObject>();
 
-                     // equipFallObject.GameObjectPool = pool;
 
-                     Parabola3DPath parabolaPath = CObjectPool.Instance.Fetch<Parabola3DPath>();
 
-                     parabolaPath.addY = 3;
 
-                     Vector3 startPos = worldPos;
 
-                     float x = Random.Range(-2f, 2f);
 
-                     float z = Random.Range(-2f, 2f);
 
-                     Vector3 endPos = startPos + new Vector3(x, 0, z);
 
-                     parabolaPath.SetPos(startPos, endPos);
 
-                     pool.own.transform.position = startPos;
 
-                     if (pool == null)
 
-                     {
 
-                         TrailRenderer[]  _trailRenderers= pool.own.transform.GetComponentsInChildren<TrailRenderer>(false);
 
-                         if (_trailRenderers != null)
 
-                         {
 
-                             for (int j = 0; j < _trailRenderers.Length; j++)
 
-                             {
 
-                                 _trailRenderers[i].Clear();
 
-                             }
 
-                         }
 
-                     }
 
-                     // equipFallObject.Parabola3DPath = parabolaPath;
 
-                     equipFallObject.Init(pool, parabolaPath, waitTime);
 
-                     allEquipFall.Add(equipFallObject);
 
-                 });
 
-             }
 
-         }
 
-         public void Update()
 
-         {
 
-             for (int i = 0; i < allEquipFall.Count; i++)
 
-             {
 
-                 allEquipFall[i].Update(Time.deltaTime);
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |