/// #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 { /// /// UI逻辑处理类 /// /// public partial class MountUpgradePreviewPanelCtrl : UIController { protected override void OnEnable(object intent) { AddUIListenres(); if (intent != null) { ShowUI(intent as List); } } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { } private void RemoveUIListenres() { } #endregion private void ShowUI(List 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); } } }