using cfg.FunctionLockCfg;
using Cysharp.Threading.Tasks;
using Framework;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace Gameplay.FunctionLock
{
public sealed class FunctionLock : MonoBehaviour
{
///
/// 解锁动画触发参数名
///
private const string ANIM_TRIGGER_NAME = "Unlock";
///
/// 动画时长
///
private const float ANIM_TIME = 3f;
///
/// 功能锁id
///
public int FunctionLockCfgId;
///
/// 功能按钮
///
public Button ButtonFunction;
#region UI
///
/// 功能锁根节点
///
private GameObject Root;
///
/// 解锁动画
///
private Animator animator;
///
/// 解锁描述
///
private TMP_Text textContent;
///
/// 锁按钮
///
private Button buttonLock;
#endregion
///
/// 解锁配置
///
private DataFunctionLock cfg;
///
/// 是否正在播放解锁动画
///
private bool isPlayingAnim;
///
/// UI名
///
public string UIName
{
get
{
if (null == cfg)
return string.Empty;
return cfg.UIName;
}
}
///
/// 是否解锁
///
public bool IsUnlock
{
get
{
#if !FUNCTION_LOCK
return true; // 未启用功能锁,永远处于解锁状态
#endif
if (null == cfg)
return false;
return FunctionLockManager.Instance.IsUnlock(cfg.ServerFlag);
}
}
private void Awake()
{
Root = gameObject;
animator = Root.transform.Find("Lock").GetComponent();
textContent = Root.transform.Find("Lock/TextContent")?.GetComponent();
buttonLock = Root.transform.Find("Lock")?.GetComponent