82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using ET.EventType;
|
|
using ET;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using FairyGUI;
|
|
|
|
namespace ET
|
|
{
|
|
public class UpdateTeamHeadInfoEvent : AEvent<UpdateTeamHeadInfo>
|
|
{
|
|
public static Dictionary<long, FUI_HeadInfoItem> TeamMemberHeadInfoDic { get; private set; } = new Dictionary<long, FUI_HeadInfoItem>();
|
|
public override async ETTask Run(UpdateTeamHeadInfo args)
|
|
{
|
|
Team team = args.team;
|
|
TeamMemberHeadInfoDic.Clear();
|
|
|
|
if (!(FUIComponent.Instance.Get(FUIPackage.Common_MainUI) is FUI_MainUI mainUI)) return;
|
|
mainUI.m_HeadInfoList.RemoveChildrenToPool();
|
|
|
|
long myId = GlobalVariable.MyId;
|
|
mainUI.m_mineHeadInfo.m_imgLeader.visible = team.Id == myId;
|
|
foreach (Unit unit in team.GetAll())
|
|
{
|
|
if (unit.Id == myId) continue;
|
|
|
|
GComponent item = mainUI.m_HeadInfoList.AddItemFromPool(FUI_HeadInfoItem.URL).asCom;
|
|
FUI_HeadInfoItem ui = FUI_HeadInfoItem.GetFormPool(args.zoneScene,item);
|
|
ClientUnitCharacter clientUnitCharacter = ClientUnitCharacterComponent.Instance.Get(unit.Id);
|
|
ui.m_txtName.text = clientUnitCharacter.NickName;
|
|
ui.m_btn.onClick.Set(() =>
|
|
{
|
|
GlobalVariable.SelectUnitHeadInfoId = unit.Id;
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.ClickTeamMemberHeadInfo
|
|
{
|
|
|
|
});
|
|
});
|
|
ui.m_imgLeader.visible = unit.IsLeader;
|
|
TeamMemberHeadInfoDic.Add(unit.Id, ui);
|
|
UpdateHeadInfo(unit);
|
|
}
|
|
|
|
await ETTask.CompletedTask;
|
|
}
|
|
|
|
private void UpdateHeadInfo(Unit unit)
|
|
{
|
|
NumericComponent num = unit.GetComponent<NumericComponent>();
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateHeadInfo_ChangeLevel
|
|
{
|
|
unit=unit
|
|
});
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateHeadInfo_ChangeHp
|
|
{
|
|
unit=unit,
|
|
old = 0,
|
|
value = num.GetAsInt(NumericType.Hp)
|
|
});
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateHeadInfo_ChangeMaxHp
|
|
{
|
|
unit = unit,
|
|
old = 0,
|
|
value = num.GetAsInt(NumericType.MaxHp),
|
|
duration = 0.6f
|
|
});
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateHeadInfo_ChangeMp
|
|
{
|
|
unit = unit,
|
|
old = 0,
|
|
value = num.GetAsInt(NumericType.Mp)
|
|
});
|
|
Game.EventSystem.Publish_Sync(new ET.EventType.UpdateHeadInfo_ChangeMaxMp
|
|
{
|
|
unit = unit,
|
|
old = 0,
|
|
value = num.GetAsInt(NumericType.MaxMp),
|
|
duration=0.6f
|
|
});
|
|
}
|
|
}
|
|
}
|