2026-06-02 12:55:39 -04:00
|
|
|
|
using Cielonos.Core.UI;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
using Cielonos.MainGame.Characters;
|
2026-06-02 12:55:39 -04:00
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
using SLSUtilities.General;
|
2026-05-10 11:47:55 -04:00
|
|
|
|
using SLSUtilities.UI;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
using UnityEngine;
|
2026-06-12 17:11:39 -04:00
|
|
|
|
using UnityEngine.Localization.Settings;
|
2026-06-02 12:55:39 -04:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Cielonos.MainGame
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MainGameManager : Singleton<MainGameManager>
|
|
|
|
|
|
{
|
2026-06-02 12:55:39 -04:00
|
|
|
|
[SerializeField]
|
|
|
|
|
|
private Player player;
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
|
private MainGameBaseCollection baseCollection;
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
|
private MainGameConfig mainGameConfig;
|
|
|
|
|
|
|
|
|
|
|
|
[Title("Submodules")] public SceneSubmodule sceneSm;
|
|
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
protected override void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Awake();
|
2026-06-02 12:55:39 -04:00
|
|
|
|
sceneSm = new SceneSubmodule(this);
|
2026-06-12 17:11:39 -04:00
|
|
|
|
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("zh-CN");
|
2025-12-22 18:36:29 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2026-03-20 12:07:44 -04:00
|
|
|
|
Application.targetFrameRate = 120;
|
2026-05-10 11:47:55 -04:00
|
|
|
|
|
|
|
|
|
|
// 订阅 UIPageManager 的输入阻塞事件,联动 isCursorLocked
|
|
|
|
|
|
if (UIPageManager.Instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIPageManager.Instance.OnInputBlockChanged += OnUIInputBlockChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-02 12:55:39 -04:00
|
|
|
|
if (sceneSm.IsCityArena)
|
|
|
|
|
|
{
|
|
|
|
|
|
RunManager.Instance.StartNewRun();
|
|
|
|
|
|
sceneSm.cityArenaBeginningProcessor.Process();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (sceneSm.IsFortress)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 基地场景不需要 RunManager,直接锁定鼠标并开启移动输入
|
|
|
|
|
|
if (player != null && player.inputSc != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
player.inputSc.isCursorLocked.Value = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 播放淡入动画(如果有 ScreenFader 的话)
|
|
|
|
|
|
ScreenFader.Instance?.FadeToClear().Play();
|
|
|
|
|
|
}
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
2025-12-23 19:47:06 -05:00
|
|
|
|
|
2026-06-12 17:11:39 -04:00
|
|
|
|
// ESC 统一由 PlayerInputSubcontroller.RegisterFunctionInputs() 处理,
|
|
|
|
|
|
// 不再在此处重复监听,避免双重触发。
|
2026-05-10 11:47:55 -04:00
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (UIPageManager.Instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIPageManager.Instance.OnInputBlockChanged -= OnUIInputBlockChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// UIPageManager 输入阻塞回调。
|
|
|
|
|
|
/// blocked = true:有页面打开 → 解锁鼠标,禁用游戏输入。
|
|
|
|
|
|
/// blocked = false:所有页面关闭 → 锁定鼠标,恢复游戏输入。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnUIInputBlockChanged(bool blocked)
|
|
|
|
|
|
{
|
|
|
|
|
|
player.inputSc.isCursorLocked.Value = !blocked;
|
2025-12-23 19:47:06 -05:00
|
|
|
|
}
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class MainGameManager
|
|
|
|
|
|
{
|
|
|
|
|
|
public static Player Player => Instance.player;
|
2026-05-10 11:47:55 -04:00
|
|
|
|
public static AttributeSubmodule GlobalAttributeSm => Player.globalAttributeSm;
|
2026-02-13 09:22:11 -05:00
|
|
|
|
public static MainGameBaseCollection BaseCollection => Instance.baseCollection;
|
2026-05-10 11:47:55 -04:00
|
|
|
|
public static MainGameConfig Config => Instance.mainGameConfig;
|
|
|
|
|
|
|
|
|
|
|
|
public static string Seed;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|