using System.Drawing; using Fort23.Core; using GameLogic.Bag; using UnityEngine; using Utility.UITool; namespace Fort23.Mono { [UIBinding(prefab = "ShowItemNumberCom")] public partial class ShowItemNumberCom : UIComponent { private float _currentTime; private float _originY; private TimerEntity _timerEntity; private void Init() { } public override void AddEvent() { } public override void DelEvent() { } public override void AddButtonEvent() { } public static async CTask Open(Vector3 pos, ItemInfo itemInfo) { ShowItemNumberCom showItemNumberCom = await UIManager.Instance.CreateGComponent(null, UIManager.Instance.GetLayer(UILayer.Top)); Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(pos); Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p); showItemNumberCom.GObjectPoolInterface.GetComponent().position = p2; showItemNumberCom.ShowTips(itemInfo); return showItemNumberCom; } public void ShowTips(ItemInfo itemInfo) { Vector3 pos = transform.GetComponent().localPosition; Text_Number.text = $"+{itemInfo.count}"; Icon_Item.gameObject.SetActive(true); Text_Number.gameObject.SetActive(true); Icon_Item.icon_name = itemInfo.config.icon; _currentTime = 0; _originY = transform.GetComponent().localPosition.y; _timerEntity = TimerComponent.Instance.AddTimer(20, (() => { Close(); }), 50, () => { _currentTime += 0.02f; float offsetY = _originY + AnimationCurveManager.Instance.AnimationCurveLibrary.JumpY.Evaluate(_currentTime) * 100; transform.localPosition = new Vector3(pos.x, offsetY, pos.z); }); } public override void Close() { UIManager.Instance.DormancyGComponent(this); _timerEntity?.Dispose(); _timerEntity = null; base.Close(); } } }