1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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<ShowItemNumberCom> Open(Vector3 pos, ItemInfo itemInfo)
- {
- ShowItemNumberCom showItemNumberCom = await UIManager.Instance.CreateGComponent<ShowItemNumberCom>(null, UIManager.Instance.GetLayer(UILayer.Top));
- Vector3 p = UIManager.Instance.CurrCustomCameraStack.camera.WorldToScreenPoint(pos);
- Vector3 p2 = UIManager.Instance.UICamera.ScreenToWorldPoint(p);
- showItemNumberCom.GObjectPoolInterface.GetComponent<RectTransform>().position = p2;
- showItemNumberCom.ShowTips(itemInfo);
- return showItemNumberCom;
- }
- public void ShowTips(ItemInfo itemInfo)
- {
- Vector3 pos = transform.GetComponent<RectTransform>().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<RectTransform>().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();
- }
- }
- }
|