using Cal.DataTable; using FairyGUI; using System; using System.Collections.Generic; using UnityEngine; namespace ET { public class StarSoulBagUIAwakeSyatem: AwakeSystem { public override void Awake(StarSoulBagUI self) { self.Awake(); } } public class StarSoulBagUIDestroySyatem: DestroySystem { public override void Destroy(StarSoulBagUI self) { self.Destroy(); } } public class StarSoulBagUI: Entity { public FUI_StarSoulBagUI ui; private Scene zoneScene; private StarSoulBag bag; private bool isInit; private EventCallback0 rollOverAction; private ListComponent idList; public static event Action clickEvent; public void Awake() { zoneScene = this.ZoneScene(); ui = GetParent(); if (!this.isInit) { isInit = true; this.ui.m_slotList.SetVirtual(); // this.rollOverAction = this.OnRollOver; this.ui.m_slotList.itemRenderer = OnItemRender; } AwakeAsync().Coroutine(); } private async ETVoid AwakeAsync() { bag = this.zoneScene.GetComponent(); ShowSlots(); await ETTask.CompletedTask; } private void ShowSlots() { idList = ListComponent.Create(); idList.List.AddRange(bag.itemDic.Keys); this.ui.m_slotList.numItems = bag.ItemCount; this.ui.m_slotList.RefreshVirtualList(); this.ui.m_txtCapity.text = $"{bag.ItemCount}/1000"; } private void OnItemRender(int index, GObject item) { FUI_ButtonStarSoulSlot btn = FUI_ButtonStarSoulSlot.GetFormPool(this.zoneScene,item); long id = idList.List[index]; var data = this.bag.Get(id); StarSoulTypeConfig soulTypeConfig = StarSoulTypeConfigCategory.Instance.Get(data.typeId); btn.self.icon = UIPackage.GetItemURL(FUIPackage.Bag,soulTypeConfig.Icon); btn.m_txtLevel .text= data.level + string.Empty; btn.m_txtUsed.text = data.isUsed? "用" : null; btn.self.title = soulTypeConfig.Name; int viceCount = 0; foreach (int i in data.viceAttribute) { if (i != 0) viceCount++; } string str = null; for (int i = 0; i < 4; i++) { if (i < viceCount) { str += TabHelper.YellowStar; } else { str += TabHelper.SliverStar; } } btn.m_txtStar.text = str; Color color= ColorHelper.GetColorByStr(TabHelper.GetQualityColor(data.quality)); btn.m_img.color = color; btn.self.titleColor = color; TabHelper.SetTab(btn.self, () => { TabHelper.OpenStarSoulUI(this.bag, id); },true); btn.self.onRightClick.Set1(context => { long id = idList.List[index]; clickEvent?.Invoke(id); string tip = null; tip = data.isUsed? "是否卸载此星魂?" : "是否放置此星魂到装备上?"; var tipUi = TipHelper.OpenUI(tip, tipType: TipType.Double); tipUi.m_btnYes.self.onClick.Set(async() => { var ret = await this.zoneScene.GetComponent() .Call(new C2M_PutonStarSoulItem { itemId = id }); if (!ret.Message.IsNullOrEmpty()) { TipHelper.OpenUI(ret.Message); return; } }); }); } public void ReFresh() { idList.Dispose(); AwakeAsync().Coroutine(); } public void Destroy() { idList.Dispose(); } } }