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 allImageMove = new List(); List _imageMoveContainers = new List(); public static async CTask OpenShowItemMoveToTargetPanel() { ShowItemMoveToTargetPanel showItemMoveToTargetPanel = await UIManager.Instance.LoadAndOpenPanel(null, UILayer.Bottom, isFocus: false); return showItemMoveToTargetPanel; } public async override CTask Show() { await base.Show(); Ui.sizeDelta = transform.sizeDelta; // Combat.sizeDelta = transform.sizeDelta; } private void Init() { } protected override void AddEvent() { StaticUpdater.Instance.AddRenderUpdateCallBack(RenderUpdateCallBack); } protected override void DelEvent() { StaticUpdater.Instance.RemoveRenderUpdateCallBack(RenderUpdateCallBack); } public override void AddButtonEvent() { } 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); } } private async CTask AddACurve(Vector2 startPos, Vector2 target, string itemConfig, object data, CombatItemShowEventData.ShowType showType, System.Action finishCallBack, System.Action 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(); aCurve.CurveInfos.Add(curveInfo); aCurve.CurveInfos.Add(curveInfo2); aCurve.CurveType = CurveType.BSL; ImageMove currImageMove = CObjectPool.Instance.Fetch(); currImageMove.finishCallBack = finishCallBack; currImageMove.targetPointSet = targetPointSet; currImageMove.data = data; currImageMove.moveSpeed = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_moveSpped; // currImageMove.ShowSizeCurve = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_showSize; // currImageMove.showSizeSpeed = 10; GameObjectPool gameObjectPool; MyImage myImage; currImageMove.speed = AnimationCurveManager.Instance.AnimationCurveLibrary.uiMoveSpeed; gameObjectPool = GObjectPool.Instance.FetchAsyncForGameObject(moveIcon.gameObject, "moveIcon"); myImage = gameObjectPool.own.GetComponent(); myImage.icon_name = itemConfig; // currImageMove.speed = AnimationCurveManager.Instance.AnimationCurveLibrary.uiMoveSpeed; // gameObjectPool = // GObjectPool.Instance.FetchAsyncForGameObject(moveIcon.gameObject, "moveIcon"); // myImage = gameObjectPool.own.GetComponent(); // myImage.icon_name = itemConfig; currImageMove.SizeCurve = AnimationCurveManager.Instance.AnimationCurveLibrary.ui_moveSize; // gameObjectPool.own.transform.SetParent(Ui); gameObjectPool.own.SetActive(false); gameObjectPool.own.transform.localScale = Vector3.zero; currImageMove.GameObjectPool = gameObjectPool; currImageMove.transform = gameObjectPool.own.GetComponent(); currImageMove.transform.sizeDelta = new Vector2(50, 65); currImageMove.moveStartPos = startPos; currImageMove.transform.anchoredPosition = currImageMove.moveStartPos; currImageMove.yanChi = Random.Range(0, 0.5f); currImageMove.currAcur = aCurve; allImageMove.Add(currImageMove); return currImageMove; } public async void ShowPanel(Vector2 startPos, Vector2 target, int count, string showName, CombatItemShowEventData.ShowType showType, System.Action finishCallBack = null, System.Action targetPointSet = null, object data = null, System.Action initCallBack = null) { if (target.x == -5000) { target = moveTarget.GetComponent().anchoredPosition; } for (int i = 0; i < count; i++) { ImageMove imageMove = await AddACurve(startPos, target, showName, data, showType, finishCallBack, targetPointSet); imageMove.GroupIndex = i; initCallBack?.Invoke(imageMove); } } } }