123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using FL.FGUI;
- using System.Collections.Generic;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUIP
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PlayerJobCareerPreviewPanelCtrl : UIController<PlayerJobCareerPreviewPanelVM>
- {
- private ScrollPane _scrollPanel;
- protected override void OnEnable(object intent)
- {
- _scrollPanel = VM.JobCareerScrollNested.VM.Scroll;
- AddUIListenres();
- ShowUI();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.BackBtn.onClick.Add(OnClickBackBtn);
- VM.ResetBtn.onClick.Add(OnClickResetBtn);
- _scrollPanel.onScroll.Add(OnScrollPaneScroll);
- }
- private void RemoveUIListenres()
- {
- VM.BackBtn.onClick.Remove(OnClickBackBtn);
- VM.ResetBtn.onClick.Remove(OnClickResetBtn);
- _scrollPanel.onScroll.Remove(OnScrollPaneScroll);
- }
- private void OnClickBackBtn(EventContext context)
- {
- Context.ClosePanel();
- }
- private void OnClickResetBtn(EventContext context)
- {
- ConfirmationBoxParam dialogParam = new ConfirmationBoxParam()
- {
- cnt = StringDefine.resetCareer,
- onPromiseCallback = ()=>
- {
- PlayerService.Instance.SendToResetJob();
- Context.ClosePanel();
- }
- };
- Context.UI.OpenAsync(UIKeys.CommonConfirmationBox, dialogParam);
- }
- #endregion
- private void ShowUI()
- {
- var curJobInfo = careerTableRepo.Get(PlayerData.Instance.JobId);
- if (curJobInfo != null)
- {
- var lvList = new HashSet<int>();
- var dataList = careerTableRepo.GetAll();
- var preDataList = new List<careerTable>(); // 前置数据(初始职业和10级转职数据)
- var soldierDataMap = new Dictionary<eAdvanceType, List<careerTable>>();
- var shooterDataMap = new Dictionary<eAdvanceType, List<careerTable>>();
- var magicianDataMap = new Dictionary<eAdvanceType, List<careerTable>>();
- foreach (var item in dataList)
- {
- lvList.Add(item.Unlock);
- if (item.Change_times < 2)
- {
- preDataList.Add(item);
- }
- else
- {
- eAdvanceType advanceType = (eAdvanceType)item.Type;
- if (item.Careertype == (int)eCareerType.Soldier)
- {
- if (soldierDataMap.ContainsKey(advanceType))
- {
- soldierDataMap[advanceType].Add(item);
- }
- else
- {
- soldierDataMap.Add(advanceType, new List<careerTable>() { item });
- }
- }
- else if (item.Careertype == (int)eCareerType.Shooter)
- {
- if (shooterDataMap.ContainsKey(advanceType))
- {
- shooterDataMap[advanceType].Add(item);
- }
- else
- {
- shooterDataMap.Add(advanceType, new List<careerTable>() { item });
- }
- }
- else if (item.Careertype == (int)eCareerType.Magician)
- {
- if (magicianDataMap.ContainsKey(advanceType))
- {
- magicianDataMap[advanceType].Add(item);
- }
- else
- {
- magicianDataMap.Add(advanceType, new List<careerTable>() { item });
- }
- }
- }
- }
- ShowLvTitle(curJobInfo.Unlock, lvList);
- VM.JobCareerScrollNested.Ctrl.ShowUI(curJobInfo, preDataList, soldierDataMap, shooterDataMap, magicianDataMap);
- _scrollPanel.SetPercX(0,false);
- _scrollPanel.SetPercY(0, false);
- }
- }
- /// <summary>
- /// 等级阶段
- /// </summary>
- private void ShowLvTitle(int jobLv, HashSet<int> lvList)
- {
- var jobLvParamList = new List<JobLvParam>();
- foreach (var item in lvList)
- {
- jobLvParamList.Add(new JobLvParam()
- {
- lv = item,
- bJobLv = item == jobLv
- });
- }
- VM.LvList.BindDatas(jobLvParamList);
- }
- /// <summary>
- /// 职业阶段等级UI滚动
- /// </summary>
- private void OnScrollPaneScroll()
- {
- // 获取当前滚动位置
- if (VM.LvList.scrollPane.percX != _scrollPanel.percX)
- VM.LvList.scrollPane.percX = _scrollPanel.percX;
- }
- }
- }
|