This commit is contained in:
2026-07-07 17:10:00 +08:00
parent f0e2c1f368
commit 052bd75034
2 changed files with 94 additions and 4 deletions
@@ -18,12 +18,12 @@ namespace Assets.MyGame.Scripts.Net.API.GameConfig_SubClass
/// <summary>
/// 经验下限
/// </summary>
public int expMin;
public long expMin;
/// <summary>
/// 经验上限
/// </summary>
public int expMax;
public long expMax;
/// <summary>
/// 奖励金币
+92 -2
View File
@@ -1,5 +1,6 @@
using Assets.Framework.Tool;
using Assets.MyGame.Scripts.Net;
using Assets.MyGame.Scripts.Net.API.GameConfig_SubClass;
using Assets.MyGame.Scripts.Net.APIRequest.Params;
using System.Collections.Generic;
using TMPro;
@@ -67,8 +68,12 @@ public class UserInfoPanel : SubUIBase
GameManager gameManager => GameManager.Instance;
private List<Toggle> _avatarToggles = new List<Toggle>();
private List<Toggle> _avatarFrameToggles = new List<Toggle>();
private string _pendingAvatarName; // 选中的待确认头像名
private string _pendingAvatarFrameName; // 选中的待确认头像框名
private string _pendingAvatarName;
private string _pendingAvatarFrameName;
// 等级奖励预览
private int _previewLevel;
private List<UserLevelConfig> _levelConfigs;
public override void Awake()
{
@@ -88,6 +93,10 @@ public class UserInfoPanel : SubUIBase
// 改个性签名
btn_Change.onClick.AddListener(OnClickSaveSignature);
// 等级预览翻页
btn_LevelNext.onClick.AddListener(OnClickLevelNext);
btn_LevelUp.onClick.AddListener(OnClickLevelUp);
}
protected override void OnShow(object args = null)
@@ -142,6 +151,87 @@ public class UserInfoPanel : SubUIBase
tMPText_OldPhoneNumber.text = MaskPhone(gameManager.user.BaseInfo.mobile);
if (tMPText_PhoneNumberXGMM != null)
tMPText_PhoneNumberXGMM.text = MaskPhone(gameManager.user.BaseInfo.mobile);
// 等级信息
RefreshLevelUI();
}
// ==================== 等级奖励预览 ====================
private void RefreshLevelUI()
{
_levelConfigs = GameManager.Instance?.gameConfig?.userLevelConfigs;
if (_levelConfigs == null || _levelConfigs.Count == 0) return;
var assets = gameManager.user.assets;
int currentLevel = assets.level;
if (tMPText_UserLevel != null)
tMPText_UserLevel.text = $"LV.{currentLevel}";
if (_previewLevel <= 0)
_previewLevel = currentLevel;
UpdateLevelPreview();
}
private void UpdateLevelPreview()
{
if (_levelConfigs == null) return;
var cfg = _levelConfigs.Find(c => c.level == _previewLevel);
if (cfg == null) return;
var assets = gameManager.user.assets;
if (tMPText_Level != null)
tMPText_Level.text = $"{cfg.level}级奖励";
// 进度条
if (slider_UserLevel != null)
{
slider_UserLevel.minValue = cfg.expMin;
slider_UserLevel.maxValue = cfg.expMax;
slider_UserLevel.value = Mathf.Clamp(assets.exp, cfg.expMin, cfg.expMax);
}
// 奖励预览:productList
if (backPackPropItemParent != null && backPackPropItemPrefab != null)
{
for (int i = backPackPropItemParent.childCount - 1; i >= 0; i--)
Destroy(backPackPropItemParent.GetChild(i).gameObject);
if (cfg.productList != null && cfg.productList.Count > 0)
{
foreach (var product in cfg.productList)
{
var obj = Instantiate(backPackPropItemPrefab.gameObject, backPackPropItemParent);
obj.SetActive(true);
var item = obj.GetComponent<BackPackPropItem>();
if (item == null) continue;
item.Init(APIManager.baseURL + product.imageUrl, product.count, (PropEnum)product.type);
}
}
}
}
private void OnClickLevelNext()
{
if (_levelConfigs == null) return;
int maxLevel = _levelConfigs[_levelConfigs.Count - 1].level;
if (_previewLevel < maxLevel)
{
_previewLevel++;
UpdateLevelPreview();
}
}
private void OnClickLevelUp()
{
if (_previewLevel > 1)
{
_previewLevel--;
UpdateLevelPreview();
}
}
// ==================== 头像加载 ====================