123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using System.Collections.Generic;
- using FairyGUI;
- using FL.Data;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerPartnerBookDetailPanelCtrl
- : UIController<PartnerPartnerBookDetailPanelVM>
- {
- protected override void OnEnable(object intent)
- {
- _curId = (int)intent;
- AddUIListenres();
- InitView();
- UpView();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.LeftBtn.onClick.Add(OnClickLeftBtn);
- VM.RightBtn.onClick.Add(OnClickRightBtn);
- VM.GetBtn.onClick.Add(OnClickGetBtn);
- Context.AddListener(EventDefine.PartnerJibanRwdGet, OnRwdGet);
- Context.AddListener(EventDefine.PartnerJibanRwdGetAll, OnRwdGet);
- }
- private void RemoveUIListenres()
- {
- VM.LeftBtn.onClick.Remove(OnClickLeftBtn);
- VM.RightBtn.onClick.Remove(OnClickRightBtn);
- VM.GetBtn.onClick.Remove(OnClickGetBtn);
- Context.RemoveListener(EventDefine.PartnerJibanRwdGet, OnRwdGet);
- Context.RemoveListener(EventDefine.PartnerJibanRwdGetAll, OnRwdGet);
- }
- private void OnRwdGet(int eventId, object args)
- {
- UpdateList();
- }
- private void OnClickLeftBtn(EventContext context)
- {
- SelectOffset(-1);
- }
- private void OnClickRightBtn(EventContext context)
- {
- SelectOffset(1);
- }
- private void OnClickGetBtn(EventContext context)
- {
- var collectTable = collectTableRepo.Get(_curId);
- var starLv = 0;
- foreach (var id in collectTable.Param)
- {
- if (PartnersData.Instance.TryGetPartnerAttrByTableId(id, out var attr))
- {
- starLv += attr.RisingStarLv;
- }
- }
- var rwdList = collect_rewardTableRepo.GetCollectRwdList(_curId);
- var canGet = false;
- foreach (var item in rwdList)
- {
- if (
- starLv > item.Unlock
- && !PartnersData.Instance.GetJibaIsActive(item.CollectId, item.Level)
- )
- {
- canGet = true;
- break;
- }
- }
- if (canGet)
- {
- PartnersService.Instance.RequestJibanRwdGetAll(_curId);
- }
- else
- {
- Context.ShowTips(StringDefine.PartnerJiBanNoActivatable);
- }
- }
- #endregion
- private bool _initView = false;
- private int _curId;
- private List<int> _list;
- private void InitView()
- {
- if (_initView)
- return;
- _initView = true;
- VM.List.ListType = EGListType.None;
- VM.RwdList.ListType = EGListType.Virtual;
- var tableList = collectTableRepo.GetAllEpiCollectList();
- var list = new List<int>();
- foreach (var item in tableList)
- {
- list.Add(item.Id);
- }
- _list = list;
- }
- private void UpView()
- {
- var table = collectTableRepo.Get(_curId);
- XGame.Framework.Assert.IsNotNull(table, $"羁绊表不存在,id:{_curId}");
- VM.List.BindDatas(table.Param);
- VM.NameLabel.text = table.Name;
- UpdateList();
- }
- private void UpdateList()
- {
- var list = collect_rewardTableRepo.GetCollectRwdList(_curId);
- VM.RwdList.BindDatas(list);
- }
- private void SelectOffset(int offset)
- {
- var index = _list.IndexOf(offset);
- index += offset;
- if (index < 0)
- {
- index += _list.Count;
- }
- else if (index >= _list.Count)
- {
- index -= _list.Count;
- }
- _curId = _list[index];
- UpView();
- }
- }
- }
|