/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using System.Collections.Generic;
using FairyGUI;
using FL.Data;
using FL.Data.Items;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerMwDetailNestedCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres() { }
private void RemoveUIListenres() { }
#endregion
private int _mwId;
public void ShowUI(int id)
{
_mwId = id;
if (_mwId == 0)
{
VM.MwBaseItem.Disable();
VM.IsEmpty.selectedIndex = 1;
return;
}
VM.MwBaseItem.Enable(null);
VM.IsEmpty.selectedIndex = 0;
var table = EpigraphTableRepo.Get(_mwId);
XGame.Framework.Assert.IsNotNull(table, $"铭文表不存在,id:{_mwId}");
VM.NameLabel.text = table.Name;
var attr = EpigraphData.Instance.GetEpigraphAttrByTableId(_mwId);
var star = attr?.StarLv ?? 1;
var upStarTable = epigraphUpTableRepo.GetEpiragphUp(_mwId, star);
VM.SpPbar.max = upStarTable.LevelUpCost;
VM.SpPbar.value = ItemData.Instance.GetItemNum(upStarTable.PetId);
//
ShowStar(star);
//
ShowSkillBaseInfo(table.Skill[0]);
//
if (table.Element > 0)
{
VM.ElementLoader.visible = true;
VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
}
else
{
VM.ElementLoader.visible = false;
}
//
VM.AttrLabel.text = $"+{table.Own_attr[1] / 100f}%";
VM.MwBaseItem.Ctrl.SetEpiIcon(_mwId);
}
private void ShowStar(int star)
{
var starStep = PartnersService.Instance.GetStarStep(star);
var starLv = PartnersService.Instance.GetStarLv(star);
var list = new List();
for (int i = 0; i < starLv; i++)
{
list.Add(starStep);
}
VM.StarList.BindDatas(list);
}
///
/// 基础技能描述
///
///
private void ShowSkillBaseInfo(int skillId)
{
var skillInfo = SkillTableRepo.Get(skillId);
XGame.Framework.Assert.IsNotNull(skillInfo, $"技能表不存在,id{skillId}");
VM.DescLabel.text = skillInfo.Desc;
}
}
}