123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PlayerJobInfoSkillNestedCtrl : UIController<PlayerJobInfoSkillNestedVM>
- {
- private bool _bHideSkillInfo; // 是否需要隐藏技能信息气泡
- private List<JobSkillParam> _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;
- }
- /// <summary>
- /// 隐藏技能信息气泡框
- /// </summary>
- /// <param name="context"></param>
- 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");
- }
- /// <summary>
- /// 主动技能
- /// </summary>
- /// <param name="skillIds"></param>
- 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");
- }
- /// <summary>
- /// 职业被动技能UI
- /// </summary>
- private void ShowJobPassiveSkillUI(int[] skillIds)
- {
- int index = 0;
- if (_passiveSkillDataArray == null) _passiveSkillDataArray = new List<JobSkillParam>();
- 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);
- }
- /// <summary>
- /// 点击的被动技能项
- /// </summary>
- /// <param name="index"></param>
- private void OnClickPassiveSkillItem(int index)
- {
- _bHideSkillInfo = false;
- ShowSkillInfoGroup(true, index, SkillTableRepo.Get(_passiveSkillDataArray[index].skillId));
- }
- /// <summary>
- /// 显示技能弹窗信息UI
- /// </summary>
- /// <param name="Show"></param>
- /// <param name="bPassive"></param>
- 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();
- }
- }
- /// <summary>
- /// 加载主角的spine
- /// </summary>
- /// <param name="spineName"></param>
- private void LoadJobSpine(string spineName)
- {
- VM.JobSpine.LoadSpine(spineName, "stand", true);
- }
- }
- }
|