43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TurnManagerSingleton : MonoBehaviour
|
|
{
|
|
public static TurnManagerSingleton Instance { get; private set; }
|
|
[SerializeField] private TurnManager turnManager;
|
|
[SerializeField] private TurnCardManager cardManager;
|
|
[SerializeField] private bool needDebugLog = true;
|
|
// private readonly TurnManagerEvent turnManagerEvent = new TurnManagerEvent();
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this) Destroy(gameObject);
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
if (turnManager == null) turnManager = GetComponent<TurnManager>();
|
|
if (cardManager == null) cardManager = GetComponent<TurnCardManager>();
|
|
}
|
|
|
|
public bool GetNeedDebugLog() => needDebugLog;
|
|
public void PrintMsg(string msg_from, string msg_title, string msg_content) => print($"[{msg_from}][{msg_title}]: {msg_content}");
|
|
public Card TakeOutOneCard() => turnManager.TakeOutOneCard();
|
|
public bool SetCardManagerLockOneCardBeingUsed(bool isLock) => cardManager.SetLockOneCardBeingUsed(isLock);
|
|
public bool GetCardManagerLockOneCardBeingUsed() => cardManager.GetLockOneCardBeingUsed();
|
|
|
|
public bool GetValueIsNotNull(object value, string errorMessage)
|
|
{
|
|
if (value != null) return true;
|
|
Debug.LogError($"[传值为空]: Variable => [{errorMessage}], Type => [{typeof(object)}]");
|
|
return false;
|
|
}
|
|
|
|
public bool CompareManagerState(TurnManager.TurnManagerStateEnum targetState)
|
|
{
|
|
TurnManager.TurnManagerStateEnum srcState = turnManager.GetTurnManagerState();
|
|
if (srcState == targetState) return true;
|
|
Debug.LogError($"[流程验证失败]系统正在执行其他流程: {srcState}, 期望流程: {targetState}");
|
|
return false;
|
|
}
|
|
} |