51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TurnSingleton : MonoBehaviour
|
|
{
|
|
public static TurnSingleton Instance { get; private set; }
|
|
[SerializeField] private bool needDebugLog = true;
|
|
|
|
public void SetDebugLog(bool value) => needDebugLog = value;
|
|
public bool GetNeedDebugLog() => needDebugLog;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
public bool VerificationRequestsMethods(RequestsMethods method, List<RequestsMethods> verificationList)
|
|
{
|
|
if (verificationList == null)
|
|
{
|
|
Debug.LogError($"[消息回调失败]未校验的请求类型: {method}");
|
|
return false;
|
|
}
|
|
|
|
if (verificationList.Contains(method)) return true;
|
|
Debug.LogError($"[消息回调失败]不允许的请求类型: {method}");
|
|
return false;
|
|
}
|
|
|
|
public bool VerificationSystemStatus(TURN_OS_STATE srcState, TURN_OS_STATE targetState)
|
|
{
|
|
if (srcState == targetState) return true;
|
|
Debug.LogError($"[流程验证失败]系统正在执行其他流程: {srcState}, 期望流程: {targetState}");
|
|
return false;
|
|
}
|
|
|
|
public bool VerificationActionStatus(TURN_ACTION_STATE srcAction, TURN_ACTION_STATE targetAction)
|
|
{
|
|
if (srcAction == targetAction) return true;
|
|
Debug.LogWarning($"[动作验证失败]系统正在执行其他动作: {srcAction}, 期望动作: {targetAction}");
|
|
return false;
|
|
}
|
|
} |