123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- /// #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 MountModelParam
- {
- public int tableId; //序号ID(坐骑id*10000+阶级*100+星级)
- public int unlockStep;
- public bool bLock; // 是否未解锁状态
- public string spineName;
- }
- public struct MountAttrParam
- {
- public EAttributeType attrType;
- public int curVal; // 当前星阶的属性值
- public int nextVal;
- }
- /// <summary>
- /// UI逻辑处理类 通用坐骑升级界面
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class MountDevelopPanelCtrl : UIController<MountDevelopPanelVM>
- {
- private int _mountIndex; // 当前显示的坐骑的索引
- private int _universalId;
- private int _feedCostItemId; // 升星需要的道具id
- private zuoqiInfoTable _curMountInfo;
- private List<MountModelParam> _mountModelList; // 普通坐骑模型列表
- private List<MountAttrParam> _mountBaseAttrList;
- private List<MountAttrParam> _mountSpecialAttrList;
- private Dictionary<int, zuoqiInfoTable> _mountStepMap; // 坐骑星阶数据
- #region 普通坐骑(坐骑升级UI)
- /// <summary>
- /// 通用坐骑数据
- /// </summary>
- private void GetMouuntModelData()
- {
- _universalId = MountData.Instance.universalId;
- _curMountInfo = zuoqiInfoTableRepo.Get(MountData.Instance.universalId);
- XGame.Framework.Assert.IsNotNull(_curMountInfo, $"坐骑表zuoqiInfo信息不存在,id:{MountData.Instance.universalId}");
- var mountBaseInfo = zuoqiBaseTableRepo.Get(_curMountInfo.Zqid);
- if (mountBaseInfo != null)
- {
- ShowMountName(mountBaseInfo.Name);
- }
- _feedCostItemId = _curMountInfo.StarNeed[0];
- ShowFeedCostUI();
- _mountModelList.Clear();
- int starLv = _curMountInfo.Star;
- var cfgInfoList = zuoqiInfoTableRepo.GetAll();
- string lastModelName = string.Empty;
- foreach (var cfgInfo in cfgInfoList)
- {
- if (cfgInfo.Icon != lastModelName)
- {
- lastModelName = cfgInfo.Icon;
- _mountModelList.Add(new MountModelParam()
- {
- tableId = cfgInfo.Id,
- unlockStep = cfgInfo.Step,
- bLock = _curMountInfo.Step < cfgInfo.Step || starLv < cfgInfo.Star,
- spineName = cfgInfo.Picture
- });
- }
- if (cfgInfo.Star == 0 && !_mountStepMap.ContainsKey(cfgInfo.Step))
- {
- _mountStepMap.Add(cfgInfo.Step, cfgInfo);
- }
- }
- }
- /// <summary>
- /// 坐骑升级UI(普通坐骑)
- /// </summary>
- private void ShowUniversalMountsUI()
- {
- ShowSelectMount(_mountIndex);
- ShowMountBaseAttr(_curMountInfo.Star);
- ShowMountSpecialAttr(_curMountInfo.Star);
- VM.ExpBar.max = _curMountInfo.StarNeed[1];
- ShowExp();
- ShowStar();
- }
- /// <summary>
- /// 通用坐骑升星经验进度
- /// </summary>
- private void ShowExp()
- {
- VM.ExpBar.value = MountData.Instance.exp;
- }
- /// <summary>
- /// 通用坐骑的星级
- /// </summary>
- private void ShowStar()
- {
- VM.StarBar.GetController("StarLvCtrl").selectedIndex = _curMountInfo.Star;
- }
- /// <summary>
- /// 升星消耗
- /// </summary>
- private void ShowFeedCostUI()
- {
- VM.FeedCostItem.Ctrl.ShowCostUI(_feedCostItemId, 1);
- }
- /// <summary>
- /// (通用坐骑)特殊属性加成
- /// </summary>
- /// <param name="starLv"></param>
- private void ShowMountSpecialAttr(int starLv)
- {
- VM.SpecialStarLvLabel.text = starLv.ToString();
- var nextInfo = _mountStepMap.ContainsKey(_curMountInfo.Step + 1) ? _mountStepMap[_curMountInfo.Step +1] : null;
- bool bMaxStep = nextInfo == null;
- VM.SpecialAttrItem.Ctrl.OnRefresh(0, new MountAttrParam()
- {
- attrType = (EAttributeType)_curMountInfo.StarSkill[0],
- curVal = _curMountInfo.StarSkill[1],
- nextVal = bMaxStep ? 0 : nextInfo.StarSkill[0]
- });
- }
- /// <summary>
- /// (通用坐骑)基础属性加成UI
- /// </summary>
- /// <param name="starLv"></param>
- private void ShowMountBaseAttr(int starLv)
- {
- VM.BaseStarLvLabel.text = starLv.ToString();
- _mountBaseAttrList.Clear();
- var nextInfo = zuoqiInfoTableRepo.Get(_curMountInfo.Id + 1);
- bool bMax = nextInfo == null;
- int count = _curMountInfo.StepOwnAttr.Length;
- for (int i = 0; i < count; i += 2)
- {
- _mountBaseAttrList.Add(new MountAttrParam()
- {
- attrType = (EAttributeType)_curMountInfo.StepOwnAttr[i],
- curVal = _curMountInfo.StepOwnAttr[i + 1],
- nextVal = bMax ? 0 : nextInfo.StepOwnAttr[i + 1]
- });
- }
- VM.BaseAttrList.BindDatas(_mountBaseAttrList);
- }
- /// <summary>
- /// 显示选择的普通坐骑立绘
- /// </summary>
- private void ShowSelectMount(int selectIndex)
- {
- _mountIndex = selectIndex;
- var param = _mountModelList[_mountIndex];
- if (param.tableId > 0)
- {
- ShowMountPicture(param.spineName);
- ShowRideUI(!param.bLock);
- if (param.bLock)
- {
- ShowUnlockLv(true);
- VM.UnLockModelLabel.text = string.Format(StringDefine.UnlockMountStep, param.unlockStep);
- }
- else
- ShowRideUI(true);
- }
- ShowSwitchMountBtnState();
- }
- /// <summary>
- /// 是否显示解锁条件
- /// </summary>
- /// <param name="bShow"></param>
- private void ShowUnlockLv(bool bShow)
- {
- VM.UnLockModelLabel.visible = bShow;
- }
- /// <summary>
- /// 坐骑的立绘
- /// </summary>
- /// <param name="mountPicture"></param>
- private void ShowMountPicture(string mountPicture, bool bAdvance = false)
- {
- VM.MountPicture.icon = mountPicture;
- if (!bAdvance)
- {
- VM.TrainMountPicture.icon = mountPicture;
- }
- }
- /// <summary>
- /// 普通坐骑上一个/下一个切换按钮的状态
- /// </summary>
- private void ShowSwitchMountBtnState()
- {
- VM.LastBtn.visible = _mountIndex > 0;
- VM.NextBtn.visible = _mountIndex < _mountModelList.Count - 1;
- }
- /// <summary>
- /// 坐骑成功喂养
- /// </summary>
- /// <param name="eventId"></param>
- /// <param name="args"></param>
- private void FeedMountSucessful(int eventId, object args)
- {
- if (_universalId == MountData.Instance.universalId) return;
- GetMouuntModelData();
- ShowUniversalMountsUI();
- }
- #endregion
- }
- }
|