90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
/*-------------------------------------------------------------------------------------
|
|
--- 创建人:
|
|
--- 描 述:
|
|
--- 创建时间: 2023年1月11日
|
|
-------------------------------------------------------------------------------------*/
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Game;
|
|
using TMPro;
|
|
using Axibug.Runtime;
|
|
using Axibug.Event;
|
|
using Axibug;
|
|
|
|
namespace Game
|
|
{
|
|
|
|
/// <summary>
|
|
/// xx 功能界面
|
|
/// </summary>
|
|
public class MainUI : UIBase
|
|
{
|
|
//UIAutoBuild_CtrlDefine
|
|
public TextMeshProUGUI tmpName;
|
|
public TextMeshProUGUI tmp_HP;
|
|
public TextMeshProUGUI tmp_MP;
|
|
//UIAutoBuild_CtrlDefine
|
|
|
|
|
|
public override void Awake()
|
|
{
|
|
//UIAutoBuild_CtrlBind
|
|
|
|
base.Awake();
|
|
Transform tf = transform;
|
|
tmpName = tf.Find("BG/tmpName").GetComponent<TextMeshProUGUI>();
|
|
tmp_HP = tf.Find("BG/tmp_HP").GetComponent<TextMeshProUGUI>();
|
|
tmp_MP = tf.Find("BG/tmp_MP").GetComponent<TextMeshProUGUI>();
|
|
//UIAutoBuild_CtrlBind
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
//UIAutoBuild_EventReg
|
|
//UIAutoBuild_EventReg
|
|
Reflush();
|
|
AppEntry.Event.Subscribe(HPMPChangeEventArgs.EventId, OnHPMPChangeEventArgs);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
//UIAutoBuild_EventUnReg
|
|
//UIAutoBuild_EventUnReg
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
}
|
|
|
|
#region 事件
|
|
|
|
private void OnHPMPChangeEventArgs(object sender, LogicEventArgs e)
|
|
{
|
|
HPMPChangeEventArgs msg = (HPMPChangeEventArgs)e;
|
|
if (msg == null) throw new GameException("OnHPMPChangeEventArgs is null");
|
|
if (msg.RoleID == GamePlayEntry.MainPlayer.Player.RoleID)
|
|
{
|
|
Reflush();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
// 每次显示都执行, 可定义参数
|
|
public override void Show(params object[] _params)
|
|
{
|
|
base.Show(_params);
|
|
|
|
}
|
|
|
|
void Reflush()
|
|
{
|
|
tmp_HP.text = GamePlayEntry.MainPlayer.Player.BaseData.life.curHP + "/" + GamePlayEntry.MainPlayer.Player.BaseData.life.maxHP;
|
|
tmp_MP.text = GamePlayEntry.MainPlayer.Player.BaseData.life.curMP + "/" + GamePlayEntry.MainPlayer.Player.BaseData.life.maxMP;
|
|
}
|
|
|
|
}
|
|
}
|