123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类 高级坐骑界面
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class MountDevelopPanelCtrl : UIController<MountDevelopPanelVM>
- {
- private int _curAdvancedIndex; // 当前选择的高级坐骑索引
- private List<zuoqiBaseTable> _advancedMountsInfoList; // 高级坐骑信息列表数据
- private void GetAdvanceMountData()
- {
- var dataList = zuoqiBaseTableRepo.GetAll();
- foreach (var item in dataList)
- {
- if (item.Type == 2) // 高级坐骑
- {
- _advancedMountsInfoList.Add(item);
- }
- }
- }
- /// <summary>
- /// 显示高级坐骑界面UI
- /// </summary>
- private void ShowAdvancedMountUI()
- {
- VM.AdvancedMountList.BindDatas(_advancedMountsInfoList);
- }
- /// <summary>
- /// 高级坐骑的升级预览和启用技能按钮状态
- /// </summary>
- /// <param name="bSHow"></param>
- private void ShowAdvancedMountBtn(bool bShow)
- {
- VM.UpgradePreviewBtn.visible = bShow;
- VM.EnableSkillBtn.visible = bShow;
- }
- /// <summary>
- /// 选择的高级坐骑
- /// </summary>
- /// <param name="selectIndex"></param>
- 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);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="bShow"></param>
- private void ShowEnableSkillBtn(bool bShow, bool bEnable = false)
- {
- VM.EnableSkillBtn.visible = bShow;
- if (bShow)
- {
- VM.SkillCtrl.selectedIndex = bEnable ? 1 : 0;
- }
- }
- /// <summary>
- /// 是否显示高级坐骑升级预览
- /// </summary>
- /// <param name="bShow"></param>
- private void ShowUpgradePreviewBtn(bool bShow)
- {
- VM.UpgradePreviewBtn.visible = bShow;
- }
- /// <summary>
- /// 高级坐骑拥有的效果
- /// </summary>
- /// <param name="curLv"></param>
- /// <param name="mountId"></param>
- 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") + "%";
- }
- }
- /// <summary>
- /// 高级坐骑解锁|升级消耗UI
- /// </summary>
- /// <param name="cost"></param>
- private void ShowCostUI(int[] cost)
- {
- var item = ItemService.Instance.GetItemBase(cost[0], cost[1], 0);
- VM.UnlockMountItem.Ctrl.ShowUI(item);
- }
- /// <summary>
- /// 显示高级坐骑的星级
- /// </summary>
- /// <param name="starLv"></param>
- private void ShowAdvanceMountStarUI(int starLv)
- {
- VM.MountStar.GetController("StarLvCtrl").selectedIndex = starLv;
- }
- /// <summary>
- /// 选择某个高级坐骑
- /// </summary>
- /// <param name="index"></param>
- 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;
- }
- }
- }
- /// <summary>
- /// 解锁某个高级坐骑成功
- /// </summary>
- /// <param name="eventId"></param>
- /// <param name="args"></param>
- private void UnlockAdvancedMountSucessful(int eventId, object args)
- {
- ShowSelectAdvancedMount(_curAdvancedIndex);
- }
- /// <summary>
- /// 成功启用某个高级坐骑技能
- /// </summary>
- /// <param name="eventId"></param>
- /// <param name="args"></param>
- private void UseMountSkillSucessful(int eventId, object args)
- {
- ShowEnableSkillBtn(true, _advancedMountsInfoList[_curAdvancedIndex].Id == MountData.Instance.useSkillMountId);
- }
- /// <summary>
- /// 高级坐骑升级成功
- /// </summary>
- /// <param name="eventId"></param>
- /// <param name="args"></param>
- private void UpgradeAdvancedMountSucessful(int eventId, object args)
- {
- ShowSelectAdvancedMount(_curAdvancedIndex);
- }
- }
- }
|