Files
ichni_Official/Assets/Scripts/Manager/GameManager.cs
SoulliesOfficial 7c60c40d6b 同步
2026-06-05 04:45:57 -04:00

105 lines
3.5 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Ichni.RhythmGame;
using Ichni.RhythmGame.UI;
using Sirenix.OdinInspector;
using SLSUtilities.General;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
namespace Ichni
{
public partial class GameManager : Singleton<GameManager>, ISongTimeProvider
{
[FormerlySerializedAs("audioManager")] public SongPlayer songPlayer;
public CameraManager cameraManager;
[FormerlySerializedAs("inputManager")] public NoteJudgeManager noteJudgeManager;
public BackgroundSetter backgroundSetter;
public BackgroundController backgroundController;
public VariablesContainer variablesContainer;
public ProjectLoader projectLoader;
public PlayingRecorder playingRecorder;
public BeatmapContainer beatmapContainer;
public CommandScripts commandScripts;
public ProjectInformation projectInformation;
public SongInformation songInformation;
public List<TimeDurationSubmodule> timeDurations;
public AnimationManager animationManager;
public TrackManager trackManager;
public NoteManager noteManager;
public BasePrefabsCollection basePrefabs;
public Dictionary<string, CustomPrefabsCollection> customPrefabs;
public List<IHaveTransformSubmodule> activeTransformSubmodules = new List<IHaveTransformSubmodule>();
public List<IHaveColorSubmodule> activeColorSubmodules = new List<IHaveColorSubmodule>();
public List<IHaveDirtyMarkSubmodule> activeDirtyMarkSubmodules = new List<IHaveDirtyMarkSubmodule>();
public ElementUpdateScheduler updateScheduler;
[Title("UI")]
public Canvas judgeHintCanvas;
public GameUICanvas gameUICanvas;
public GameLoadingCanvas gameLoadingCanvas;
public SummaryPageCanvas summaryPageCanvas;
public float SongTime => songPlayer.isStarting ? 0 :
songPlayer.songTimeSegment - songInformation.offset - (SettingsManager.instance.gameSettings.beatmapOffset / 1000f);
public bool IsPlaying => songPlayer != null && songPlayer.isPlaying;
public bool isDebugging;
protected override void Awake()
{
base.Awake();
CoreServices.TimeProvider = this;
timeDurations = new List<TimeDurationSubmodule>();
playingRecorder = new PlayingRecorder();
updateScheduler = new ElementUpdateScheduler();
CoreServices.UpdateScheduler = updateScheduler;
}
private void Start()
{
basePrefabs.PrepareAudios();
projectLoader.TestLoad();
}
private void Update()
{
updateScheduler.TickEarly(SongTime);
}
private void LateUpdate()
{
updateScheduler.TickLate();
}
}
public partial class GameManager
{
public static void RestartGame()
{
SceneManager.LoadScene("GameScene");
Time.timeScale = 1f; // 确保重启时时间缩放恢复正常
}
public static void ReturnToMenu()
{
//InformationTransistor.instance.isReturnedFromGame = true;
SceneManager.LoadScene("MenuScene");
Time.timeScale = 1f; // 确保返回时时间缩放恢复正常
}
}
}