/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data; using System.Collections.Generic; using XGame.Database; using XGame.Framework.UI; namespace FL.FGUI { /// /// UI逻辑处理类 /// /// public partial class PlayerJobInfoSkillNestedCtrl : UIController { private bool _bHideSkillInfo; // 是否需要隐藏技能信息气泡 private List _passiveSkillDataArray; protected override void OnEnable(object intent) { AddUIListenres(); } protected override void OnDisable() { RemoveUIListenres(); _passiveSkillDataArray?.Clear(); _passiveSkillDataArray = null; } #region UI事件 private void AddUIListenres() { VM.BackBtn.onClick.Add(OnClickBackBtn); VM.PanelEvent.Add(OnCllickPanel); VM.PassiveSkillList.ItemClickEvent += OnClickPassiveSkillItem; } private void RemoveUIListenres() { VM.BackBtn.onClick.Remove(OnClickBackBtn); VM.PanelEvent.Remove(OnCllickPanel); VM.PassiveSkillList.ItemClickEvent -= OnClickPassiveSkillItem; } /// /// 隐藏技能信息气泡框 /// /// private void OnCllickPanel(EventContext context) { if (_bHideSkillInfo) { ShowSkillInfoGroup(false); } _bHideSkillInfo = true; } private void OnClickBackBtn(EventContext context) { Context.ClosePanel(); } #endregion public void ShowUI() { _bHideSkillInfo = true; ShowSkillInfoGroup(false); var jobInfo = careerTableRepo.Get(PlayerData.Instance.JobId); if (jobInfo == null) return; VM.JobNameLabel.text = jobInfo.Name; VM.JobTypeLabel.text = jobInfo.Job_pos; VM.JobDescLabel.text = jobInfo.Desc; ShowSkill(jobInfo.Skill); ShowJobPassiveSkillUI(jobInfo.Passive_skill); LoadJobSpine("info_job_1001_1_SkeletonData"); } /// /// 主动技能 /// /// private void ShowSkill(int[] skillIds) { var skillInfo = SkillTableRepo.Get(skillIds[1]); if (skillInfo == null) return; VM.SkillNameLabel.text = skillInfo.Name; VM.SkillDescLabel.text = skillInfo.Desc; VM.ActiveSkillIcon.icon = skillInfo.Icon; VM.SkillCdLabel.text = (skillInfo.RestTime * 0.001f).ToString("F1"); } /// /// 职业被动技能UI /// private void ShowJobPassiveSkillUI(int[] skillIds) { int index = 0; if (_passiveSkillDataArray == null) _passiveSkillDataArray = new List(); for (int i = 0; i < skillIds.Length; i += 2) { _passiveSkillDataArray.Add(new JobSkillParam() { unlockLv = skillIds[i], skillId = skillIds[i + 1], }); index++; } VM.PassiveSkillList.BindDatas(_passiveSkillDataArray); } /// /// 点击的被动技能项 /// /// private void OnClickPassiveSkillItem(int index) { _bHideSkillInfo = false; ShowSkillInfoGroup(true, index, SkillTableRepo.Get(_passiveSkillDataArray[index].skillId)); } /// /// 显示技能弹窗信息UI /// /// /// private void ShowSkillInfoGroup(bool bShow, int index = 0, SkillTable skillInfo = null) { //Log.Debug($"ShowSkillInfoGroup bShow:{bShow} info:{skillInfo != null} Frame:{Time.frameCount}"); if (bShow && skillInfo != null) { var skillParam = new SkillInfoParam() { bShowRightBubble = index > 1, skillInfo = skillInfo }; if (VM.SkillInfoNested.Active) VM.SkillInfoNested.Ctrl.ShowSkillInfo(skillParam); else VM.SkillInfoNested.Enable(skillParam); VM.PosCtrl.selectedIndex = index; } else { VM.SkillInfoNested.Disable(); } } /// /// 加载主角的spine /// /// private void LoadJobSpine(string spineName) { VM.JobSpine.LoadSpine(spineName, "stand", true); } } }