Game_CodeMM/Assets/00_scripts/Events/TurnScripts/TurnManagerSingleton.cs

40 lines
1.6 KiB
C#
Raw Normal View History

2025-11-20 20:02:48 +08:00
using System;
2025-11-20 14:44:09 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnManagerSingleton : MonoBehaviour
{
public static TurnManagerSingleton Instance { get; private set; }
2025-11-20 20:02:48 +08:00
[SerializeField] private TurnManager turnManager;
2025-11-20 14:44:09 +08:00
[SerializeField] private bool needDebugLog = true;
2025-11-21 20:16:36 +08:00
private readonly TurnManagerEvent turnManagerEvent = new TurnManagerEvent();
2025-11-20 14:44:09 +08:00
2025-11-20 20:02:48 +08:00
private void Awake()
{
if (Instance != null && Instance != this) Destroy(gameObject);
Instance = this;
DontDestroyOnLoad(gameObject);
if (turnManager == null) turnManager = GetComponent<TurnManager>();
}
2025-11-20 14:44:09 +08:00
// public void SetDebugLog(bool value) => needDebugLog = value;
public bool GetNeedDebugLog() => needDebugLog;
2025-11-21 20:16:36 +08:00
public TurnManagerEvent GetTurnManagerEvent() => turnManagerEvent;
2025-11-21 02:12:50 +08:00
public void PrintMsg(string msg_from, string msg_title, string msg_content) => print($"[{msg_from}][{msg_title}]: {msg_content}");
2025-11-20 17:20:34 +08:00
public bool GetValueIsNotNull(object value, string errorMessage)
{
if (value != null) return true;
Debug.LogError($"[传值为空]: Variable => [{errorMessage}], Type => [{typeof(object)}]");
return false;
}
2025-11-21 02:12:50 +08:00
public bool CompareManagerState(TurnManager.TurnManagerStateEnum targetState)
2025-11-20 17:20:34 +08:00
{
2025-11-21 02:12:50 +08:00
TurnManager.TurnManagerStateEnum srcState = turnManager.GetTurnManagerState();
2025-11-20 17:20:34 +08:00
if (srcState == targetState) return true;
Debug.LogError($"[流程验证失败]系统正在执行其他流程: {srcState}, 期望流程: {targetState}");
return false;
}
2025-11-20 14:44:09 +08:00
}