12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using System;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PlayerPassiveSkillListItemCtrl : UIController<PlayerPassiveSkillListItemVM>
- {
- private int _index;
- private int _passiveSkillId;
- private Action<int, int> _callback;//点击被动技能图标的回调函数
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- _callback = null;
- _passiveSkillId = 0;
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.PassiveSkillBtn.onClick.Add(OnClickBtn);
- }
- private void RemoveUIListenres()
- {
- VM.PassiveSkillBtn.onClick.Remove(OnClickBtn);
- }
- private void OnClickBtn(EventContext context)
- {
- if (_callback != null)
- {
- _callback(_passiveSkillId,_index);
- }
- }
- #endregion
- public void OnRefresh(int index, JobSkillParam skillParam)
- {
- _index = index;
- //使用默认值来判断结构体是否被初始化
- bool bEmpty = skillParam.Equals(default(JobSkillParam));
- VM.Ctrl.selectedIndex = bEmpty ? 0 : 1;
- if (bEmpty)
- {
- _callback = null;
- _passiveSkillId = 0;
- return;
- }
- _passiveSkillId = skillParam.skillId;
- _callback = skillParam.onclickSkillIcon;
- var skillInfo = SkillTableRepo.Get(skillParam.skillId);
- if (skillInfo != null)
- {
- VM.PassiveSkillBtn.icon = skillInfo.Icon;
- }
- }
- }
- }
|