CTT/Unity/Assets/HotfixView/Event/UI/InitHeadInfoEvent.cs

76 lines
3.2 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using DG.Tweening;
using ET.EventType;
using ET;
using System;
using System.Collections.Generic;
2021-04-11 19:50:39 +08:00
using FairyGUI;
2021-04-08 20:09:59 +08:00
namespace ET
{
public class InitHeadInfoEvent : AEvent_Sync<InitHeadInfo>
{
public override void Run(InitHeadInfo args)
{
var zoneScene = args.zoneScene;
2021-04-08 20:09:59 +08:00
if (!(FUIComponent.Instance.Get(FUIPackage.Common_MainUI) is FUI_MainUI ui))
{
return;
}
float tweenTime = 0.3f;
{
NumericComponent num = zoneScene.GetComponent<UnitComponent>().MyUnit.GetComponent<NumericComponent>();
2021-04-11 19:50:39 +08:00
GProgressBar hpBar = ui.m_mineHeadInfo.m_pBarHp;
2021-04-08 20:09:59 +08:00
hpBar.max = num.Get(NumericType.MaxHp);
DOTween.To(() => (float)hpBar.value, x => hpBar.value = x, num.Get(NumericType.Hp), tweenTime).SetEase(Ease.InOutQuad);
2021-04-11 19:50:39 +08:00
GProgressBar mpBar = ui.m_mineHeadInfo.m_pbarMp;
2021-04-08 20:09:59 +08:00
mpBar.max = num.Get(NumericType.MaxMp);
DOTween.To(() => (float)mpBar.value, x => mpBar.value = x, num.Get(NumericType.Mp), tweenTime).SetEase(Ease.InOutQuad);
int level = (int)num.Get(NumericType.Level);
2021-06-29 11:28:15 +08:00
long maxExp = CharacterUIHelper.GetMaxExpByLevel((zoneScene.GetComponent<GlobalVariable>().JobId + 1) / 2, level);
2021-04-08 20:09:59 +08:00
ui.m_mineHeadInfo.m_txtLevel.text = string.Empty + level;
2021-04-11 19:50:39 +08:00
GProgressBar expBar = ui.m_mineHeadInfo.m_pBarExp;
2021-04-08 20:09:59 +08:00
expBar.max = maxExp;
DOTween.To(() => (float)expBar.value, x => expBar.value = x, num.Get(NumericType.Exp), tweenTime).SetEase(Ease.InOutQuad);
}
//!队友的UI
foreach (var kv in UpdateTeamHeadInfoEvent.TeamMemberHeadInfoDic)
{
Unit unit = zoneScene.GetComponent<UnitComponent>().Get(kv.Key);
2021-04-08 20:09:59 +08:00
if (unit == null)
{
Log.Error($"unit == null where id ={kv.Key}");
return;
}
2021-04-11 19:50:39 +08:00
NumericComponent num = unit.GetComponent<NumericComponent>();
2021-04-08 20:09:59 +08:00
if (unit == null)
{
Log.Error($"num == null where id ={kv.Key}");
return;
}
2021-04-11 19:50:39 +08:00
GProgressBar hpBar = kv.Value.m_pBarHp;
2021-04-08 20:09:59 +08:00
hpBar.max = num.Get(NumericType.MaxHp);
DOTween.To(() => (float)hpBar.value, x => hpBar.value = x, num.Get(NumericType.Hp), tweenTime).SetEase(Ease.InOutQuad);
2021-04-11 19:50:39 +08:00
GProgressBar mpBar = kv.Value.m_pbarMp;
2021-04-08 20:09:59 +08:00
mpBar.max = num.Get(NumericType.MaxMp);
DOTween.To(() => (float)mpBar.value, x => mpBar.value = x, num.Get(NumericType.Mp), tweenTime).SetEase(Ease.InOutQuad);
int level = (int)num.Get(NumericType.Level);
2021-06-29 11:28:15 +08:00
long maxExp = CharacterUIHelper.GetMaxExpByLevel((zoneScene.GetComponent<GlobalVariable>().JobId + 1) / 2, level);
2021-04-08 20:09:59 +08:00
kv.Value.m_txtLevel.text = string.Empty + level;
2021-04-11 19:50:39 +08:00
GProgressBar expBar = kv.Value.m_pBarExp;
2021-04-08 20:09:59 +08:00
expBar.max = maxExp;
DOTween.To(() => (float)expBar.value, x => expBar.value = x, num.Get(NumericType.Exp), tweenTime).SetEase(Ease.InOutQuad);
}
}
}
}