2021-04-10 19:49:32 +08:00
|
|
|
|
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)
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
var zoneScene = args.zoneScene;
|
|
|
|
|
Unit unit = zoneScene.GetComponent<UnitComponent>().Get(args.unitId);
|
2021-04-10 19:49:32 +08:00
|
|
|
|
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:
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if(UpdateTeamHeadInfoEvent.TeamMemberHeadInfoDic.TryGetValue(unit.Id,out FUI_HeadInfoItem headInfoItem))
|
2021-04-10 19:49:32 +08:00
|
|
|
|
{
|
|
|
|
|
list = headInfoItem.m_listBuff;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (list == null) return;
|
|
|
|
|
list.RemoveChildrenToPool();
|
|
|
|
|
BuffComponent buffComponent = unit.GetComponent<BuffComponent>();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (BuffStateInfo buff in buffComponent.buffList.Values)
|
2021-04-10 19:49:32 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
GButton btn = list.AddItemFromPool().asButton;
|
2021-04-16 00:06:30 +08:00
|
|
|
|
btn.icon = UIPackage.GetItemURL(FUIPackage.Skill, buff.iconId);
|
2021-04-10 19:49:32 +08:00
|
|
|
|
btn.onClick.Set(() =>
|
|
|
|
|
{
|
|
|
|
|
TabHelper.OpenBuffUI(buff);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|