2021-05-01 22:06:12 +08:00
|
|
|
using Cal.DataTable;
|
|
|
|
using FairyGUI;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
{
|
|
|
|
public class StarSoulBagUIAwakeSyatem: AwakeSystem<StarSoulBagUI>
|
|
|
|
{
|
|
|
|
public override void Awake(StarSoulBagUI self)
|
|
|
|
{
|
|
|
|
self.Awake();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class StarSoulBagUIDestroySyatem: DestroySystem<StarSoulBagUI>
|
|
|
|
{
|
|
|
|
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<long> idList;
|
2021-05-02 23:18:14 +08:00
|
|
|
public static event Action<long> clickEvent;
|
2021-05-01 22:06:12 +08:00
|
|
|
public void Awake()
|
|
|
|
{
|
|
|
|
zoneScene = this.ZoneScene();
|
|
|
|
ui = GetParent<FUI_StarSoulBagUI>();
|
|
|
|
if (!this.isInit)
|
|
|
|
{
|
2021-05-02 23:18:14 +08:00
|
|
|
isInit = true;
|
2021-05-01 22:06:12 +08:00
|
|
|
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<StarSoulBag>();
|
|
|
|
ShowSlots();
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowSlots()
|
|
|
|
{
|
|
|
|
idList = ListComponent<long>.Create();
|
|
|
|
idList.List.AddRange(bag.itemDic.Keys);
|
|
|
|
this.ui.m_slotList.numItems = bag.ItemCount;
|
|
|
|
this.ui.m_slotList.RefreshVirtualList();
|
2021-05-02 23:18:14 +08:00
|
|
|
this.ui.m_txtCapity.text = $"{bag.ItemCount}/1000";
|
2021-05-01 22:06:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnItemRender(int index, GObject item)
|
|
|
|
{
|
2021-05-02 23:18:14 +08:00
|
|
|
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;
|
2021-05-03 01:54:31 +08:00
|
|
|
TabHelper.SetTab(btn.self, () =>
|
|
|
|
{
|
|
|
|
TabHelper.OpenStarSoulUI(this.bag, id);
|
|
|
|
},true);
|
|
|
|
btn.self.onRightClick.Set1(context =>
|
2021-05-02 23:18:14 +08:00
|
|
|
{
|
|
|
|
long id = idList.List[index];
|
|
|
|
clickEvent?.Invoke(id);
|
2021-05-03 01:54:31 +08:00
|
|
|
|
|
|
|
string tip = null;
|
|
|
|
tip = data.isUsed? "是否卸载此星魂?" : "是否放置此星魂到装备上?";
|
|
|
|
var tipUi = TipHelper.OpenUI(tip, tipType: TipType.Double);
|
|
|
|
tipUi.m_btnYes.self.onClick.Set(async() =>
|
2021-05-02 23:18:14 +08:00
|
|
|
{
|
2021-05-03 01:54:31 +08:00
|
|
|
var ret = await this.zoneScene.GetComponent<SessionComponent>()
|
|
|
|
.Call<M2C_PutonStarSoulItem>(new C2M_PutonStarSoulItem { itemId = id });
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
2021-05-02 23:18:14 +08:00
|
|
|
{
|
2021-05-03 01:54:31 +08:00
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
2021-05-02 23:18:14 +08:00
|
|
|
});
|
2021-05-01 22:06:12 +08:00
|
|
|
}
|
2021-05-02 01:19:35 +08:00
|
|
|
public void ReFresh()
|
|
|
|
{
|
|
|
|
idList.Dispose();
|
|
|
|
AwakeAsync().Coroutine();
|
|
|
|
}
|
2021-05-01 22:06:12 +08:00
|
|
|
|
|
|
|
public void Destroy()
|
|
|
|
{
|
|
|
|
idList.Dispose();
|
|
|
|
}
|
2021-05-02 01:19:35 +08:00
|
|
|
|
2021-05-01 22:06:12 +08:00
|
|
|
}
|
|
|
|
}
|