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

74 lines
3.0 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;
namespace ET
{
public class InitHeadInfoEvent : AEvent_Sync<InitHeadInfo>
{
public override void Run(InitHeadInfo args)
{
if (!(FUIComponent.Instance.Get(FUIPackage.Common_MainUI) is FUI_MainUI ui))
{
return;
}
float tweenTime = 0.3f;
{
var num = UnitComponent.MyUnit.GetComponent<NumericComponent>();
var hpBar = ui.m_mineHeadInfo.m_pBarHp;
hpBar.max = num.Get(NumericType.MaxHp);
DOTween.To(() => (float)hpBar.value, x => hpBar.value = x, num.Get(NumericType.Hp), tweenTime).SetEase(Ease.InOutQuad);
var mpBar = ui.m_mineHeadInfo.m_pbarMp;
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);
long maxExp = UpdateHeadInfo_ChangeMaxExpEvent.GetMaxExpByLevel((GlobalVariable.JobId + 1) / 2, level);
ui.m_mineHeadInfo.m_txtLevel.text = string.Empty + level;
var expBar = ui.m_mineHeadInfo.m_pBarExp;
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)
{
var unit = UnitComponent.Instance.Get(kv.Key);
if (unit == null)
{
Log.Error($"unit == null where id ={kv.Key}");
return;
}
var num = unit.GetComponent<NumericComponent>();
if (unit == null)
{
Log.Error($"num == null where id ={kv.Key}");
return;
}
var hpBar = kv.Value.m_pBarHp;
hpBar.max = num.Get(NumericType.MaxHp);
DOTween.To(() => (float)hpBar.value, x => hpBar.value = x, num.Get(NumericType.Hp), tweenTime).SetEase(Ease.InOutQuad);
var mpBar = kv.Value.m_pbarMp;
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);
long maxExp = UpdateHeadInfo_ChangeMaxExpEvent.GetMaxExpByLevel((GlobalVariable.JobId + 1) / 2, level);
kv.Value.m_txtLevel.text = string.Empty + level;
var expBar = kv.Value.m_pBarExp;
expBar.max = maxExp;
DOTween.To(() => (float)expBar.value, x => expBar.value = x, num.Get(NumericType.Exp), tweenTime).SetEase(Ease.InOutQuad);
}
}
}
}