132 lines
4.4 KiB
C#
132 lines
4.4 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>();
|
|
|
|
[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();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
basePrefabs.PrepareAudios();
|
|
projectLoader.TestLoad();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!songPlayer.isUpdating) return;
|
|
|
|
foreach (var timeDuration in timeDurations)
|
|
{
|
|
timeDuration?.DetectAndSwitchActiveState(SongTime);
|
|
}
|
|
|
|
animationManager.ManualUpdate(SongTime);
|
|
trackManager.ManualUpdate(SongTime);
|
|
noteManager.ManualUpdate(SongTime);
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (songPlayer.isUpdating)
|
|
{
|
|
trackManager.ManualLateUpdate(SongTime);
|
|
noteManager.ManualLateUpdate(SongTime);
|
|
|
|
for (int i = 0; i < activeColorSubmodules.Count; i++)
|
|
{
|
|
activeColorSubmodules[i].UpdateColor(true);
|
|
}
|
|
|
|
for (int i = 0; i < activeTransformSubmodules.Count; i++)
|
|
{
|
|
activeTransformSubmodules[i].UpdateTransform(true);
|
|
}
|
|
}
|
|
|
|
if (songPlayer.isStarting || songPlayer.isPlaying)
|
|
{
|
|
for (int i = 0; i < activeDirtyMarkSubmodules.Count; i++)
|
|
{
|
|
activeDirtyMarkSubmodules[i]?.dirtyMarkSubmodule?.ExecuteDeferredRefresh();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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; // 确保返回时时间缩放恢复正常
|
|
}
|
|
}
|
|
} |