/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FairyGUI;
using FL.Data;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PlayerTransferSucessPanelCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
ShowUI();
}
protected override void OnDisable()
{
RemoveUIListenres();
VM.JobSpine.url = string.Empty;
}
#region UI事件
private void AddUIListenres()
{
VM.BackBtn.onClick.Add(OnClickBackBtn);
VM.ActiveSkillBtn.onClick.Add(OnClickActiveSkillBtn);
VM.PassiveSkillBtn.onClick.Add(OnClickPassiveSkillBtn);
}
private void RemoveUIListenres()
{
VM.BackBtn.onClick.Remove(OnClickBackBtn);
VM.ActiveSkillBtn.onClick.Remove(OnClickActiveSkillBtn);
VM.PassiveSkillBtn.onClick.Remove(OnClickPassiveSkillBtn);
}
///
/// 点击主动技能
///
///
private void OnClickActiveSkillBtn(EventContext context)
{
OpenPlayerJobInformationPanel();
}
///
/// 点击被动技能
///
///
private void OnClickPassiveSkillBtn(EventContext context)
{
OpenPlayerJobInformationPanel();
}
private void OnClickBackBtn(EventContext context)
{
Context.ClosePanel();
}
#endregion
private void ShowUI()
{
var jobInfo = careerTableRepo.Get(PlayerData.Instance.JobId);
if (jobInfo == null) return;
VM.JobName.text = jobInfo.Name;
ShowSkill(jobInfo.Skill);
ShowPassiveSkill(jobInfo.Passive_skill);
LoadJobSpine("info_job_1001_1_SkeletonData");
}
///
/// 主动技能
///
///
private void ShowSkill(int[] skillIds)
{
bool bShow = skillIds != null && skillIds.Length > 0;
if (bShow) {
VM.AdvanceSkillItem.Enable(null);
}
else
{
VM.AdvanceSkillItem.Disable();
}
if (bShow)
VM.AdvanceSkillItem.Ctrl.ShowUI(skillIds[1]);
}
///
/// 被动技能
///
///
private void ShowPassiveSkill(int[] skillIds)
{
bool bShow = skillIds != null && skillIds.Length > 0;
if (bShow) {
VM.AdvancePassiveSkillItem.Enable(null);
} else
{
VM.AdvancePassiveSkillItem.Disable();
}
if (bShow)
VM.AdvancePassiveSkillItem.Ctrl.ShowUI(skillIds[1]);
}
///
/// 加载主角的spine
///
///
private void LoadJobSpine(string spineName)
{
VM.JobSpine.LoadSpine(spineName, "stand", true);
}
///
/// 打开职业详情界面
///
private void OpenPlayerJobInformationPanel()
{
Context.UI.OpenAsync(UIKeys.PlayerJobInformationPanel);
}
}
}