1
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 头像加载 ====================
|
||||
|
||||
Reference in New Issue
Block a user