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)
|
|||
|
{
|
|||
|
var 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 var headInfoItem))
|
|||
|
{
|
|||
|
list = headInfoItem.m_listBuff;
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
if (list == null) return;
|
|||
|
list.RemoveChildrenToPool();
|
|||
|
BuffComponent buffComponent = unit.GetComponent<BuffComponent>();
|
|||
|
foreach (var buff in buffComponent.buffList.Values)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var 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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|