56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using ET.EventType;
|
|
using FairyGUI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ET
|
|
{
|
|
public class AddBuffEvent : AEvent<RefreshBuff>
|
|
{
|
|
public override async ETTask Run(RefreshBuff args)
|
|
{
|
|
Unit unit = UnitComponent.Instance.Get(args.unitId);
|
|
if (!unit)
|
|
{
|
|
Log.Error($"unit is null where id is {args.unitId}");
|
|
return;
|
|
}
|
|
GList list = null;
|
|
switch (unit.UnitType)
|
|
{
|
|
case UnitType.Player:
|
|
list = MainUI.ui.m_listBuff;
|
|
break;
|
|
case UnitType.TeamMember:
|
|
if(UpdateTeamHeadInfoEvent.TeamMemberHeadInfoDic.TryGetValue(unit.Id,out FUI_HeadInfoItem headInfoItem))
|
|
{
|
|
list = headInfoItem.m_listBuff;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (list == null) return;
|
|
list.RemoveChildrenToPool();
|
|
BuffComponent buffComponent = unit.GetComponent<BuffComponent>();
|
|
foreach (BuffStateInfo buff in buffComponent.buffList.Values)
|
|
{
|
|
try
|
|
{
|
|
GButton btn = list.AddItemFromPool().asButton;
|
|
btn.icon = UIPackage.GetItemURL(FUIPackage.Bag, buff.iconId.ToString());
|
|
btn.onClick.Set(() =>
|
|
{
|
|
TabHelper.OpenBuffUI(buff);
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Log.Error(e);
|
|
}
|
|
}
|
|
await ETTask.CompletedTask;
|
|
}
|
|
}
|
|
}
|