Files
test/Assets/PerfectWorld/Scripts/UI/HUDPlayer.cs
T
NguyenVanDat 777bda9cd9 inffo
2025-10-28 17:51:50 +07:00

42 lines
1.2 KiB
C#

using System;
using CSNetwork.GPDataType;
using TMPro;
using UnityEngine;
namespace BrewMonster
{
public class HUDPlayer : MonoBehaviour
{
public TextMeshProUGUI healthText;
public TextMeshProUGUI manaText;
public TextMeshProUGUI expText;
public TextMeshProUGUI nameText;
public TextMeshProUGUI levelText;
public float neededExp;
private void Awake()
{
EventBus.Subscribe<cmd_self_info_00>(UpdateHostPlayerInfoUI);
EventBus.Subscribe<InfoHostPlayer>(UpdateNameHostPlayer);
EventBus.Subscribe<EXPToUpLevel>(UpdateNeededExp);
}
private void UpdateNeededExp(EXPToUpLevel obj)
{
neededExp = obj.NeededExp;
}
private void UpdateNameHostPlayer(InfoHostPlayer obj)
{
nameText.text = obj.NameHostPlayer;
}
private void UpdateHostPlayerInfoUI(cmd_self_info_00 obj)
{
healthText.text = $"{obj.iHP}/{obj.iMaxHP}";
manaText.text = $"{obj.iMP}/{obj.iMaxMP}";
expText.text = $"{((float)obj.iExp/neededExp)*100}%";
levelText.text = $"{obj.sLevel}";
}
}
}