87 lines
2.4 KiB
C#
87 lines
2.4 KiB
C#
|
using Games.Events;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
|
|||
|
public class LockPanelCtr : MonoBehaviour, IPointerDownHandler
|
|||
|
{
|
|||
|
private const int _lockID = 25;
|
|||
|
public static LockPanelCtr Instance;
|
|||
|
public GameObject _lockPanel;
|
|||
|
private float _lockStart;
|
|||
|
private float lockCountTime;
|
|||
|
public bool isLock { get; private set; }
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
Instance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void Start()
|
|||
|
{
|
|||
|
// 注:初始状态标志位是false,实际_lockPanel是active
|
|||
|
// 如果后续有切换到false执行的操作,需要额外处理
|
|||
|
_lockPanel.SetActive(false);
|
|||
|
lockCountTime = float.Parse(TableManager.GetSystemParamByID(_lockID).StringValue);
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (!isLock)
|
|||
|
{
|
|||
|
if (Input.touchCount > 0 || Input.anyKey || LoadingWindow._IsLoadingScene
|
|||
|
|| GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level <
|
|||
|
int.Parse(TableManager.GetSystemParamByID(52).StringValue))
|
|||
|
_lockStart = Time.realtimeSinceStartup;
|
|||
|
else if (_lockStart + lockCountTime < Time.realtimeSinceStartup)
|
|||
|
SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
Instance = null;
|
|||
|
}
|
|||
|
|
|||
|
public void OnPointerDown(PointerEventData eventData)
|
|||
|
{
|
|||
|
OnUnLock();
|
|||
|
}
|
|||
|
|
|||
|
public void OnUnLock()
|
|||
|
{
|
|||
|
_lockStart = Time.realtimeSinceStartup;
|
|||
|
SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
private void SetActive(bool isActive)
|
|||
|
{
|
|||
|
if (isActive != isLock)
|
|||
|
{
|
|||
|
if (isActive)
|
|||
|
{
|
|||
|
UIManager.Instance().ShowBlurBackGround(UIInfo.LockPanel.name);
|
|||
|
EventDispatcher.Instance.Dispatch(EventId.OpenLockCtr);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
UIManager.Instance().HideBlurBackGround(UIInfo.LockPanel.name);
|
|||
|
//ShowHidedUI();
|
|||
|
}
|
|||
|
|
|||
|
_lockPanel.SetActive(isActive);
|
|||
|
isLock = isActive;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//有些UI在锁屏的时候因为参数设置的问题被关闭了。
|
|||
|
//这边在解锁的时候重新调用打开UI的接口
|
|||
|
private void ShowHidedUI()
|
|||
|
{
|
|||
|
if (Singleton<ObjManager>.Instance.MainPlayer)
|
|||
|
{
|
|||
|
Singleton<ObjManager>.Instance.MainPlayer.ChangeSceneSpecialOpt();
|
|||
|
Singleton<ObjManager>.Instance.MainPlayer.SpeaiclSceneUIControl();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|