12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using System.Collections.Generic;
- using FairyGUI;
- using FL.Data;
- using XGame;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerSbBaseItemCtrl : UIController<PartnerSbBaseItemVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres() { }
- private void RemoveUIListenres() { }
- #endregion
- public void ShowUI(int sbId, bool showOther)
- {
- if (sbId <= 0)
- {
- VM.PartnerImg.visible = false;
- VM.QualityImg.icon = AddressableDefine.SbEmptyDi();
- VM.ShowOther.selectedIndex = 1;
- VM.LevelTxt.visible = false;
- return;
- }
- var table = PartnerTableRepo.Get(sbId);
- if (table == null)
- {
- Log.Error($"圣兵表不存在id:{sbId}");
- return;
- }
- VM.PartnerImg.visible = true;
- VM.ElementLoader.url = AddressableDefine.SbElementTypeRhombus((int)table.Element);
- VM.QualityImg.icon = AddressableDefine.SbPzDi((int)table.Quality);
- VM.PartnerImg.icon = table.Icon;
- VM.ShowOther.selectedIndex = showOther ? 0 : 1;
- var partnerData = PartnersData.Instance.GetPartnerAttrByTableId(sbId);
- VM.Have.selectedIndex = partnerData != null ? 0 : 1;
- if(partnerData != null)
- {
- var level = partnerData?.Level ?? 1;
- VM.LevelTxt.text = $"LV.{level}";
- if (showOther)
- {
- var starLv = partnerData?.RisingStarLv == null ? 1 : partnerData.RisingStarLv;
- ShowStar(starLv);
- var starTable = partnerStarUpTableRepo.GetPartnerStarTable(sbId, starLv);
- if (starTable == null)
- {
- Log.Error($"圣兵升星表不存在,id:{sbId},starLv:{starLv}");
- return;
- }
- VM.SpPbar.max = starTable.StarUpCost;
- VM.SpPbar.value = ItemData.Instance.GetItemNum(starTable.PetId);
- }
- }
- }
- private void ShowStar(int starLv)
- {
- var curNum = PartnersService.Instance.GetStarLv(starLv);
- var curStep = PartnersService.Instance.GetStarStep(starLv);
- var list = new List<int>();
- for (int i = 0; i < curNum; i++)
- {
- list.Add(curStep);
- }
- VM.StarList.BindDatas(list);
- }
- }
- }
|