/// #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 { public class PartnerEpiDetailInfoParam { public int EpigraphId; } /// /// UI逻辑处理类 /// /// public partial class PartnerEpiDetailInfoCtrl : UIController { #region 属性 private int _mwId; #endregion protected override void OnEnable(object intent) { var param = intent as PartnerEpiDetailInfoParam; _mwId = param.EpigraphId; AddUIListenres(); UpView(); } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { VM.UpBtn.onClick.Add(OnClickUpBtn); VM.DownBtn.onClick.Add(OnClickDownBtn); VM.GotoBtn.onClick.Add(OnClickGotoBtn); VM.RankUpBtn.onClick.Add(OnClickRankUpBtn); Context.AddListener(EventDefine.EpigraphUpStar, OnEpiUpdate); Context.AddListener(EventDefine.PartnerBinding, UpdateUpDownBtn); Context.AddListener(EventDefine.UpdataItemData, OnItemUpdate); } private void RemoveUIListenres() { VM.UpBtn.onClick.Remove(OnClickUpBtn); VM.DownBtn.onClick.Remove(OnClickDownBtn); VM.GotoBtn.onClick.Remove(OnClickGotoBtn); VM.RankUpBtn.onClick.Remove(OnClickRankUpBtn); Context.RemoveListener(EventDefine.EpigraphUpStar, OnEpiUpdate); Context.RemoveListener(EventDefine.PartnerBinding, UpdateUpDownBtn); Context.RemoveListener(EventDefine.UpdataItemData, OnItemUpdate); } private void OnItemUpdate(int eventId, object args) { UpProgressInfo(); } private void OnEpiUpdate(int eventId, object args) { UpProgressInfo(); UpSkillList(); } private void OnClickDownBtn(EventContext eventContext) { var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId); if (info == null) { Log.Error($"铭文数据不存在tableId:{_mwId}"); return; } //if (PartnersData.Instance.UsePlanId == _planId) //{ EpigraphService.Instance.RequestEpiInset(info.PartnerId, 0); //} //else //{ // if (!PartnersData.Instance.TryGetPlan(_planId, out var plan)) // { // Context.ShowTips(StringDefine.PartnerPlanEmptyTips); // return; // } // var caoId = -1; // var sbId = 0; // foreach (var slot in plan.Slots) // { // if (slot.MwId == _mwId) // { // caoId = slot.CaoId; // sbId = slot.SbId; // break; // } // } // if (sbId == 0 || caoId < 0) // { // Context.ShowTips(StringDefine.EpigraphNotInPlanTips); // return; // } // PartnersService.Instance.RequestUpdatePlanMw(_planId, caoId, sbId, 0); //} Context.ClosePanel(); } private void OnClickUpBtn(EventContext context) { //if (_planId == PartnersData.Instance.UsePlanId) //{ if (!EpigraphData.Instance.TryGetEpigraphAttrByTableId(_mwId, out var attr)) { Context.ShowTips(StringDefine.EpigraphEmptyTips); return; } if (attr.PartnerId > 0) { Context.ShowTips(StringDefine.EpigraphAlreadyUpTips); return; } //if (_partnerId > 0) //{ // if ( // !PartnersData.Instance.TryGetPartnerAttrByTableId( // _partnerId, // out var partnerAttr // ) // ) // { // Context.ShowTips(StringDefine.PartnerEmptyTips); // return; // } // EpigraphService.Instance.RequestEpiInset(_partnerId, _mwId); //} //else //{ EpigraphService.Instance.OpenUpMode(_mwId); //} //} //else //{ // if (!PartnersData.Instance.TryGetPlan(_planId, out var plan)) // { // Context.ShowTips(StringDefine.PartnerPlanEmptyTips); // return; // } // PartnerPlanSlot curSlot = null; // foreach (var slot in plan.Slots) // { // if (slot.MwId == _mwId) // { // curSlot = slot; // break; // } // } // if (curSlot != null) // { // Context.ShowTips(StringDefine.EpigraphAlreadyUpTips); // return; // } // var targetSlot = PartnersData.Instance.GetPlanSlot(_planId, _slotId); // if (targetSlot == null || targetSlot.SbId == 0) // { // Context.ShowTips(StringDefine.PartnerCurSlotNoSbTips); // return; // } // PartnersService.Instance.RequestUpdatePlanMw( // _planId, // _slotId, // targetSlot.SbId, // _mwId // ); //} Context.ClosePanel(); } private void OnClickGotoBtn(EventContext context) { } private void OnClickRankUpBtn(EventContext context) { var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId); if (info == null) { Log.Error($"铭文数据不存在tableId:{_mwId}"); return; } var table = epigraphUpTableRepo.GetEpiragphUp(_mwId, info.StarLv); if (table == null) { Log.Error($"铭文升星表不存在id:{_mwId}, starLv{info.StarLv}"); return; } if (table.LevelUpCost > ItemData.Instance.GetItemNum(_mwId)) { Context.ShowTips(StringDefine.epigraphUpUnenough); return; } EpigraphService.Instance.RequestEpiStarUp(_mwId); } #endregion #region 页面 private void UpView() { UpDescInfo(); UpProgressInfo(); UpSkillList(); } private void UpdateUpDownBtn(int eventId, object args) { ShowUpDownBtn(); } private void ShowUpDownBtn() { //if (_planId == PartnersData.Instance.UsePlanId) //{ if (!EpigraphData.Instance.TryGetEpigraphAttrByTableId(_mwId, out var epi)) { Log.Error($"铭文数据不存在,id:{_mwId}"); return; } VM.Up.selectedIndex = epi.PartnerId > 0 ? 1 : 0; //} //else //{ // if (!PartnersData.Instance.TryGetPlan(_planId, out var plan)) // { // Log.Error($"方案信息不存在,planId:{_planId}"); // return; // } // var isFind = false; // foreach (var slot in plan.Slots) // { // if (slot.MwId == _mwId) // { // isFind = true; // break; // } // } // VM.Up.selectedIndex = isFind ? 1 : 0; //} } private void UpDescInfo() { var table = EpigraphTableRepo.Get(_mwId); if (table == null) { Log.Error($"铭文表不存在id:{_mwId}"); } VM.EpiLabel.Ctrl.SetEpiIcon(_mwId, true); var initSkillId = table.Skill[0]; var skillTable = SkillTableRepo.Get(initSkillId); if (skillTable == null) { Log.Error($"技能表不能存在,技能ID:{initSkillId}"); return; } VM.DescLabel.text = skillTable.Desc; VM.NameLabel.text = table.Name; var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId); if (info != null) { ShowUpDownBtn(); int nextLv = info.StarLv + 1; var nextUpTable = epigraphUpTableRepo.GetEpiragphUp(_mwId, nextLv); VM.HaveState.selectedIndex = nextUpTable != null ? 1 : 2; } else { VM.HaveState.selectedIndex = 0; } if (table.Element > 0) { VM.AttrIcon.visible = true; VM.AttrIcon.url = AddressableDefine.PartnerElementType(((int)table.Element)); } else { VM.AttrIcon.visible = false; } VM.HaveAtrr.selectedIndex = table.Own_attr.Length > 0 ? 0 : 1; if (table.Own_attr.Length > 0) { string str = ""; for (int i = 0; i < table.Own_attr.Length; i += 2) { var attrTable = AttrDescTableRepo.Get(table.Own_attr[i]); if (attrTable == null) continue; var attrValue = table.Own_attr[i + 1]; var val = attrValue > 0 ? attrValue.ToRealFloat().ToString("F2") : "0"; if (i > 0) str += ","; str += $"{attrTable.ShowName}{val}"; } VM.AttrLabel.SetVar("attr", str).FlushVars(); } } private void UpProgressInfo() { var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId); var curlv = info != null ? info.StarLv : 1; var table = epigraphUpTableRepo.GetEpiragphUp(_mwId, curlv); if (table == null) { Log.Error($"铭文升星表不存在id:{_mwId}, starLv:{curlv}"); return; } VM.ChipPbar.max = table.LevelUpCost; VM.ChipPbar.value = ItemData.Instance.GetItemNum(table.PetId); } private void UpSkillList() { var list = new List(); var epiTable = EpigraphTableRepo.Get(_mwId); if (epiTable == null) { Log.Error($"铭文表不存在id:{_mwId}"); return; } for (var i = 2; i < epiTable.Skill.Length; i = i + 2) { var skill = epiTable.Skill[i]; var limit = epiTable.Skill[i + 1]; var skillLimit = new EpigraphSkillLimit() { epiId = _mwId, limitLv = limit, skillId = skill, }; list.Add(skillLimit); } VM.EffectList.BindDatas(list); } #endregion } }