/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using System.Collections.Generic;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
public struct AdvancedMountParam
{
public int oldStarLv;
public int curStarLv;
public int attrType;
public int oldAttrValue;
public int curAttrValue;
}
///
/// UI逻辑处理类
///
///
public partial class MountUpgradeSuccessfulPanelCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
ShowUI();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
}
private void RemoveUIListenres()
{
}
#endregion
private void ShowUI()
{
int mountId = MountService.Instance.upgradeMountId;
int oldStarLv = MountService.Instance.mountStarLv;
int curStarLv = MountData.Instance.GetAdvancedMountLv(mountId);
var oldStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + oldStarLv);
if (oldStarInfo == null)
{
XGame.Log.Error($"坐骑表zuoqiStar中不存在id:{mountId * 10000 + oldStarLv}");
return;
}
int[] oldStarOwnAttr = oldStarInfo.LevelOwnAttr;
var curStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + curStarLv);
if (curStarInfo == null)
{
XGame.Log.Error($"坐骑表zuoqiStar中不存在id:{mountId * 10000 + curStarLv}");
return;
}
ShowAttrUI(oldStarLv, curStarLv, oldStarOwnAttr, curStarInfo.LevelOwnAttr);
}
private void ShowAttrUI(int oldStarLv, int curStarLv, int[] oldStarOwnAttr, int[] curStarOwnAttr)
{
var attrDataList = new List();
for (int i = 0; i < curStarOwnAttr.Length; i+=2)
{
attrDataList.Add(new AdvancedMountParam()
{
oldStarLv = oldStarLv,
curStarLv = curStarLv,
attrType = curStarOwnAttr[i],
oldAttrValue = oldStarOwnAttr[i+1],
curAttrValue = curStarOwnAttr[i+1]
});
}
VM.AttrList.BindDatas(attrDataList);
}
}
}