123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class MountUpgradePreviewPanelCtrl : UIController<MountUpgradePreviewPanelVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- if (intent != null)
- {
- ShowUI(intent as List<UpgradePreviewParam>);
- }
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- }
- private void RemoveUIListenres()
- {
- }
- #endregion
- private void ShowUI(List<UpgradePreviewParam> upgradePreviewList)
- {
- if (upgradePreviewList.Count > 0)
- {
- int mountId = upgradePreviewList[0].mountId;
- int curLv = MountData.Instance.GetAdvancedMountLv(mountId);
- int nextSkillId = 0;
- for (int i = 0; i < upgradePreviewList.Count; i++)
- {
- if (upgradePreviewList[i].level > curLv)
- {
- nextSkillId = upgradePreviewList[i].skillId;
- ShowUnlockStarUI(upgradePreviewList[i].level);
- break;
- }
- }
- //10000*坐骑id+1
- var curStarInfo = zuoqiStarTableRepo.Get(mountId * 10000 + curLv);
- if (curStarInfo == null)
- {
- XGame.Log.Error($"坐骑zuoqiStar表不存在id:{mountId * 10000 + curLv}");
- return;
- }
- ShowCurSkillUI(curStarInfo.StarSkill);
- ShowNextSkillUI(nextSkillId);
- }
- }
- private void ShowCurSkillUI(int skillId)
- {
- var curSkillInfo = SkillTableRepo.Get(skillId);
- if (curSkillInfo == null)
- {
- XGame.Log.Error($"技能表不存在skillId:{skillId}");
- return;
- }
- VM.SkillNameLabel.text = curSkillInfo.Name;
- VM.SkillDescLabel.text = curSkillInfo.Desc;
- }
- private void ShowNextSkillUI(int skillId)
- {
- var skillInfo = SkillTableRepo.Get(skillId);
- if (skillInfo == null)
- {
- XGame.Log.Error($"技能表不存在skillId:{skillId}");
- return;
- }
- VM.NextSkillNameLabel.text = skillInfo.Name;
- VM.NextSkillDescLabel.text = skillInfo.Desc;
- }
- private void ShowUnlockStarUI(int starLevel)
- {
- int starNum = starLevel == 0 ? 0 : starLevel % MountData.MaxStarNum;
- if (starLevel > 0 && starNum == 0)
- starNum = MountData.MaxStarNum;
- // 获取星星的色阶
- int starStep = Mathf.FloorToInt((starLevel - 1) / MountData.MaxStarNum) + 1;
- int[] array = Enumerable.Repeat(starStep, starNum).ToArray();
- VM.UnLockStar.BindDatas(array);
- }
- }
- }
|