/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FL.Data;
using System.Collections.Generic;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类 高级坐骑界面
///
///
public partial class MountDevelopPanelCtrl : UIController
{
private int _curAdvancedIndex; // 当前选择的高级坐骑索引
private List _advancedMountsInfoList; // 高级坐骑信息列表数据
private void GetAdvanceMountData()
{
var dataList = zuoqiBaseTableRepo.GetAll();
foreach (var item in dataList)
{
if (item.Type == 2) // 高级坐骑
{
_advancedMountsInfoList.Add(item);
}
}
}
///
/// 显示高级坐骑界面UI
///
private void ShowAdvancedMountUI()
{
VM.AdvancedMountList.BindDatas(_advancedMountsInfoList);
}
///
/// 高级坐骑的升级预览和启用技能按钮状态
///
///
private void ShowAdvancedMountBtn(bool bShow)
{
VM.UpgradePreviewBtn.visible = bShow;
VM.EnableSkillBtn.visible = bShow;
}
///
/// 选择的高级坐骑
///
///
private void ShowSelectAdvancedMount(int selectIndex)
{
_curAdvancedIndex = selectIndex;
var advancedMountInfo = _advancedMountsInfoList[selectIndex];
if (advancedMountInfo != null)
{
bool bUnlock = MountData.Instance.IsUnLock(advancedMountInfo.Id);
int lv = MountData.Instance.GetAdvancedMountLv(advancedMountInfo.Id);
ShowAttrUI(lv, advancedMountInfo.Id, bUnlock);
if (bUnlock)
{
ShowRideUI(true, advancedMountInfo.Id == MountData.Instance.mountModelId);
ShowEnableSkillBtn(true, advancedMountInfo.Id == MountData.Instance.useSkillMountId);
}
if (lv > 0) ShowMountStar(true);
ShowAdvanceMountStarUI(lv);
}
}
///
///
///
///
private void ShowEnableSkillBtn(bool bShow, bool bEnable = false)
{
VM.EnableSkillBtn.visible = bShow;
if (bShow)
{
VM.SkillCtrl.selectedIndex = bEnable ? 1 : 0;
}
}
///
/// 是否显示高级坐骑升级预览
///
///
private void ShowUpgradePreviewBtn(bool bShow)
{
VM.UpgradePreviewBtn.visible = bShow;
}
///
/// 高级坐骑拥有的效果
///
///
///
private void ShowAttrUI(int curLv, int mountId, bool bUnlock)
{
int attrType = 0;
int attrVal = 0;
if (curLv == 0)
{
var mountBaseInfo = zuoqiBaseTableRepo.Get(mountId);
XGame.Framework.Assert.IsNotNull(mountBaseInfo,$"坐骑表zuoqiBase中不存在id:{mountId}");
ShowCostUI(mountBaseInfo.Unlock);
attrType = mountBaseInfo.StarOwnAttr[0];
if (mountBaseInfo.StarOwnAttr.Length > 1)
attrVal = mountBaseInfo.StarOwnAttr[1];
}
else
{
//1000*坐骑id+等级
var mountStarInfo = zuoqiStarTableRepo.Get(mountId*1000 + curLv);
XGame.Framework.Assert.IsNotNull(mountStarInfo, $"坐骑表zuoqiStar中不存在id:{mountId * 1000 + curLv}");
ShowCostUI(mountStarInfo.StarUpCost);
attrType = mountStarInfo.LevelOwnAttr[0];
if (mountStarInfo.LevelOwnAttr.Length > 1)
attrVal = mountStarInfo.LevelOwnAttr[1];
}
ShowCurAtrrDesc(attrType, attrVal);
var nextMountStarInfo = zuoqiStarTableRepo.Get(mountId * 1000 + curLv+1);
if (nextMountStarInfo?.LevelOwnAttr?.Length > 1)
{
VM.NextMountAttrDescLabel.text = TableUtils.ToRealDouble(nextMountStarInfo.LevelOwnAttr[1]).ToString("F3") + "%";
}
VM.AdvanceMountStateCtrl.selectedIndex = bUnlock ? (nextMountStarInfo == null ? 2 : 1) : 0;
if (bUnlock)ShowUpgradePreviewBtn(nextMountStarInfo != null);
}
private void ShowCurAtrrDesc(int attrType, int attrValue)
{
var attributeInfo = AttrDescTableRepo.Get(attrType);
if (attributeInfo != null)
{
VM.MountAttrDescLabel.text = attributeInfo.ShowName + TableUtils.ToRealDouble(attrValue).ToString("F3") + "%";
}
}
///
/// 高级坐骑解锁|升级消耗UI
///
///
private void ShowCostUI(int[] cost)
{
var item = ItemService.Instance.GetItemBase(cost[0], cost[1], 0);
VM.UnlockMountItem.Ctrl.ShowUI(item);
}
///
/// 显示高级坐骑的星级
///
///
private void ShowAdvanceMountStarUI(int starLv)
{
VM.MountStar.GetController("StarLvCtrl").selectedIndex = starLv;
}
///
/// 选择某个高级坐骑
///
///
private void ClickAdvancedMountItem(int index)
{
ShowSelectAdvancedMount(index);
var mountItemList = VM.AdvancedMountList.GetChildren();
for (int i = 0; i < mountItemList.Length; i++)
{
if (mountItemList[i] == null)
{
(mountItemList[i].asCom).GetController("SelectCtrl").selectedIndex = i == index ? 1 : 0;
}
}
}
///
/// 解锁某个高级坐骑成功
///
///
///
private void UnlockAdvancedMountSucessful(int eventId, object args)
{
ShowSelectAdvancedMount(_curAdvancedIndex);
}
///
/// 成功启用某个高级坐骑技能
///
///
///
private void UseMountSkillSucessful(int eventId, object args)
{
ShowEnableSkillBtn(true, _advancedMountsInfoList[_curAdvancedIndex].Id == MountData.Instance.useSkillMountId);
}
///
/// 高级坐骑升级成功
///
///
///
private void UpgradeAdvancedMountSucessful(int eventId, object args)
{
ShowSelectAdvancedMount(_curAdvancedIndex);
}
}
}