/// #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 { /// /// UI逻辑处理类 /// /// public partial class PartnerPartnerBaseItemCtrl : UIController { private List _starIconList; 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 id, bool showOther) { if (id <= 0) { VM.PartnerImg.visible = false; VM.QualityImg.icon = AddressableDefine.PartnerEmptyDi(); VM.ShowOther.selectedIndex = 1; VM.LevelTxt.visible = false; return; } var table = PartnerTableRepo.Get(id); if (table == null) { Log.Error($"圣兵表不存在id:{id}"); return; } VM.PartnerImg.visible = true; VM.QualityImg.icon = AddressableDefine.PartnerQualityFrame((int)table.Quality); VM.PartnerImg.icon = table.Icon; var partnerData = PartnersData.Instance.GetPartnerAttrByTableId(id); var level = partnerData?.Level ?? 0; bool bShowLevel = level > 0; VM.LevelTxt.visible = bShowLevel; if (bShowLevel) { VM.LevelTxt.text = $"LV.{level}"; } VM.ShowOther.selectedIndex = showOther ? 0 : 1; if (showOther) { var starLv = partnerData?.RisingStarLv == null ? 0 : partnerData.RisingStarLv; VM.StarRating.Enable(null); VM.StarRating.Ctrl.ShowStarUI(starLv); var starTable = partnerStarUpTableRepo.GetPartnerStarTable(id, starLv); if (starTable == null) { Log.Error($"圣兵升星表不存在,id:{id},starLv:{starLv}"); return; } VM.SpPbar.GetChild("icon").asLoader.url = AddressableDefine.PartnerSpProgressDi( (int)table.Quality ); VM.SpPbar.max = starTable.StarUpCost; VM.SpPbar.value = ItemData.Instance.GetItemNum(starTable.PetId); } else { VM.StarRating.Disable(); } } } }