123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- using System.Collections.Generic;
- using CombatLibrary.CombatLibrary.CombatCore.Utility;
- using Common.Utility.CombatEvent;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Bag;
- using GameLogic.Combat.CombatTool;
- using GameLogic.Combat.CombatType;
- using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
- using UnityEngine;
- using UnityEngine.UI;
- using Utility.UITool;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "ShowItemMoveToTargetPanel")]
- public partial class ShowItemMoveToTargetPanel : UIPanel
- {
- protected List<ImageMove> allImageMove = new List<ImageMove>();
- public static async CTask OpenShowItemMoveToTargetPanel()
- {
- ShowItemMoveToTargetPanel showItemMoveToTargetPanel =
- await UIManager.Instance.LoadAndOpenPanel<ShowItemMoveToTargetPanel>(null, UILayer.Middle,
- isFocus: false);
- }
- private void Init()
- {
- }
- protected override void AddEvent()
- {
- StaticUpdater.Instance.AddRenderUpdateCallBack(RenderUpdateCallBack);
- EventManager.Instance.AddEventListener(CustomEventType.Combat_ItemShow, Combat_ItemShow);
- }
- protected override void DelEvent()
- {
- StaticUpdater.Instance.RemoveRenderUpdateCallBack(RenderUpdateCallBack);
- EventManager.Instance.RemoveEventListener(CustomEventType.Combat_ItemShow, Combat_ItemShow);
- }
- public override void AddButtonEvent()
- {
- }
- protected void Combat_ItemShow(IEventData iEventData)
- {
- Vector2 target = moveTarget.GetComponent<RectTransform>().anchoredPosition;
- CombatItemShowEventData combatItemShowEventData = iEventData as CombatItemShowEventData;
- bool isExp = combatItemShowEventData.isExp;
- if (isExp)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.expPoint.position;
- target = transform.worldToLocalMatrix * pos;
- }
- else
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.Icon_HeroExp.transform.position;
- target = transform.worldToLocalMatrix * pos;
- }
- Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(
- combatItemShowEventData.startPos_WorldPos);
- Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
- Vector3 startPos = transform.worldToLocalMatrix * p2;
- int maxCount = combatItemShowEventData.count;
- int addValue = combatItemShowEventData.addValue / maxCount;
- int finishVale = combatItemShowEventData.addValue % maxCount;
- ShowPanel(startPos, target, maxCount, combatItemShowEventData.showName, isExp,
- delegate(ImageMove imageMove)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- if (mainUIPanel == null)
- {
- return;
- }
- int currAddValue = addValue;
- if (imageMove.GroupIndex == maxCount - 1)
- {
- currAddValue += finishVale;
- }
- if (isExp)
- {
- if (mainUIPanel != null)
- {
- ParticleSystemPool particleSystemPool =
- GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_exp,
- "fx_ui_exp");
- particleSystemPool.transform.SetParent(mainUIPanel.expPoint.transform);
- particleSystemPool.transform.localPosition = Vector3.zero;
- particleSystemPool.transform.localScale = Vector3.one;
- LevelBattleCombatType levelBattleCombatType =
- CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;
- if (levelBattleCombatType != null)
- {
- levelBattleCombatType.exp += currAddValue;
- }
- // particleSystemPool.transform.
- }
- }
- else
- {
- if (mainUIPanel != null)
- {
- ParticleSystemPool particleSystemPool =
- GObjectPool.Instance.FetchAsyncForGameObject<ParticleSystemPool>(mainUIPanel.fx_ui_coin,
- "fx_ui_coin");
- particleSystemPool.transform.SetParent(mainUIPanel.Icon_HeroExp.transform);
- particleSystemPool.transform.localPosition = Vector3.zero;
- particleSystemPool.transform.localScale = Vector3.one;
- BagController.Instance.AddHeroExp(currAddValue);
- // particleSystemPool.transform.
- }
- }
- }, SetTargetPoint);
- }
- private void SetTargetPoint(ImageMove imageMove)
- {
- if (imageMove.isExp)
- {
- MainUIPanel mainUIPanel = UIManager.Instance.GetComponent<MainUIPanel>();
- Vector3 pos = mainUIPanel.expPoint.position;
- Vector3 target = transform.worldToLocalMatrix * pos;
- CurveInfo curveInfo = imageMove.currAcur.CurveInfos[1];
- curveInfo.t = target.x;
- curveInfo.v = target.y;
- imageMove.currAcur.CurveInfos[1] = curveInfo;
- }
- }
- protected void RenderUpdateCallBack()
- {
- for (int i = 0; i < allImageMove.Count; i++)
- {
- ImageMove imageMove = allImageMove[i];
- if (imageMove.Update())
- {
- GObjectPool.Instance.Recycle(imageMove.GameObjectPool);
- allImageMove.RemoveAt(i);
- i--;
- }
- }
- if (allImageMove.Count <= 0)
- {
- moveTarget.gameObject.SetActive(false);
- }
- }
- public ImageMove AddACurve(Vector2 startPos, Vector2 target, string itemConfig, bool isExp,
- System.Action<ImageMove> finishCallBack, System.Action<ImageMove> targetPointSet)
- {
- ACurve aCurve = new ACurve();
- CurveInfo curveInfo = new CurveInfo();
- // Vector3 p = startPos + (startPos - target).normalized * 30;
- Vector3 moveTargetPos = startPos + new Vector2(Random.Range(-50, 50),
- Random.Range(-50, 50));
- Vector2 newStartPos = moveTargetPos;
- curveInfo.t = newStartPos.x;
- curveInfo.v = newStartPos.y;
- curveInfo.BSLt = 0;
- // float x = Random.Range(-10, 10) * 30;
- Vector2 normal = (newStartPos - target).normalized;
- int x = Random.Range(0, 100) < 50 ? 1 : -1;
- normal = new Vector2(normal.y, -normal.x) * x * 300 + newStartPos;
- normal = (normal - target).normalized * 500;
- curveInfo.it = normal.x + curveInfo.t;
- curveInfo.ot = normal.y + curveInfo.v;
- CurveInfo curveInfo2 = new CurveInfo();
- curveInfo2.t = target.x;
- curveInfo2.v = target.y;
- Vector3 normal2 = (newStartPos - target).normalized;
- curveInfo2.it = normal2.x + curveInfo2.t;
- curveInfo2.ot = normal2.y + curveInfo2.v + 10;
- curveInfo2.BSLt = 1;
- aCurve.CurveInfos = new List<CurveInfo>();
- aCurve.CurveInfos.Add(curveInfo);
- aCurve.CurveInfos.Add(curveInfo2);
- aCurve.CurveType = CurveType.BSL;
- ImageMove currImageMove = CObjectPool.Instance.Fetch<ImageMove>();
- currImageMove.finishCallBack = finishCallBack;
- currImageMove.targetPointSet = targetPointSet;
- currImageMove.isExp = isExp;
- currImageMove.SizeCurve = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_moveSize;
- currImageMove.moveSpeed = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_moveSpped;
- // currImageMove.ShowSizeCurve = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_showSize;
- // currImageMove.showSizeSpeed = 10;
- GameObjectPool gameObjectPool =
- GObjectPool.Instance.FetchAsyncForGameObject<GameObjectPool>(moveIcon.gameObject, "moveIcon");
- gameObjectPool.own.transform.SetParent(transform);
- gameObjectPool.own.SetActive(false);
- gameObjectPool.own.transform.localScale = Vector3.zero;
- currImageMove.GameObjectPool = gameObjectPool;
- MyImage myImage = gameObjectPool.own.GetComponent<MyImage>();
- // myImage.onSpriteAlter = delegate { myImage.SetNativeSize(); };
- myImage.icon_name = itemConfig;
-
- currImageMove.transform = gameObjectPool.own.GetComponent<RectTransform>();
- currImageMove.transform.sizeDelta = new Vector2(50, 65);
- currImageMove.moveStartPos = startPos;
- currImageMove.transform.anchoredPosition = currImageMove.moveStartPos;
- currImageMove.yanChi = Random.Range(0, 0.5f);
- currImageMove.speed = AnimationCurveManager.Instance.AnimationCurveLibrary.uiMoveSpeed;
- currImageMove.currAcur = aCurve;
- allImageMove.Add(currImageMove);
- return currImageMove;
- }
- public void ShowPanel(Vector2 startPos, Vector2 target, int count, string showName, bool isExp,
- System.Action<ImageMove> finishCallBack = null, System.Action<ImageMove> targetPointSet = null)
- {
- if (target.x == -5000)
- {
- target = moveTarget.GetComponent<RectTransform>().anchoredPosition;
- }
- for (int i = 0; i < count; i++)
- {
- ImageMove imageMove = AddACurve(startPos, target, showName, isExp, finishCallBack, targetPointSet);
- imageMove.GroupIndex = i;
- }
- }
- }
- }
|