2025-01-23 19:06:48 +08:00
|
|
|
using Cysharp.Threading.Tasks;
|
2025-04-28 19:45:45 +08:00
|
|
|
using AlicizaX;
|
2025-01-23 19:06:48 +08:00
|
|
|
|
|
|
|
|
namespace Unity.Startup.Procedure
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动游戏
|
|
|
|
|
/// </summary>
|
2025-04-28 19:45:45 +08:00
|
|
|
public class ProcedureLauncherState : StateBase<UpdateProcedureState>
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
|
|
|
|
private bool _gameSettingInitFinish;
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
protected override async void OnEnter()
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
await UniTask.Delay(1000);
|
|
|
|
|
LauncherUIHandler.Start().Forget();
|
2025-01-23 19:06:48 +08:00
|
|
|
InitlizeGameSetting();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
|
|
|
|
|
private async void Start()
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
|
|
|
|
await UniTask.NextFrame();
|
2025-04-28 19:45:45 +08:00
|
|
|
SwitchState(UpdateProcedureState.ProcedureGetGlobalInfoState);
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
protected override void OnUpdate(float deltaTime)
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
base.OnUpdate(deltaTime);
|
2025-01-23 19:06:48 +08:00
|
|
|
if (_gameSettingInitFinish)
|
|
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
Start();
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitlizeGameSetting()
|
|
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
bool isWrited = Utility.PlayerPrefsX.GetBool(PrefsKey.Setting.WirtedSetting, false);
|
2025-01-23 19:06:48 +08:00
|
|
|
if (!isWrited)
|
|
|
|
|
{
|
|
|
|
|
WriteDefaultSetting();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InitSoundSettings();
|
|
|
|
|
_gameSettingInitFinish = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WriteDefaultSetting()
|
|
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
Utility.PlayerPrefsX.SetBool(PrefsKey.Setting.WirtedSetting, true);
|
|
|
|
|
Utility.PlayerPrefsX.SetBool(PrefsKey.Setting.MusicMuted, false);
|
|
|
|
|
Utility.PlayerPrefsX.SetFloat(PrefsKey.Setting.MusicVolume, 1f);
|
|
|
|
|
Utility.PlayerPrefsX.SetBool(PrefsKey.Setting.SoundMuted, false);
|
|
|
|
|
Utility.PlayerPrefsX.SetFloat(PrefsKey.Setting.SoundVolume, 1f);
|
|
|
|
|
Utility.PlayerPrefsX.SetBool(PrefsKey.Setting.UISoundMuted, false);
|
|
|
|
|
Utility.PlayerPrefsX.SetFloat(PrefsKey.Setting.UISoundVolume, 1f);
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitSoundSettings()
|
|
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
GameApp.Audio.MusicEnable = !Utility.PlayerPrefsX.GetBool(PrefsKey.Setting.MusicMuted, false);
|
|
|
|
|
GameApp.Audio.MusicVolume = Utility.PlayerPrefsX.GetFloat(PrefsKey.Setting.MusicVolume, 1f);
|
|
|
|
|
GameApp.Audio.SoundEnable = !Utility.PlayerPrefsX.GetBool(PrefsKey.Setting.SoundMuted, false);
|
|
|
|
|
GameApp.Audio.SoundVolume = Utility.PlayerPrefsX.GetFloat(PrefsKey.Setting.SoundVolume, 1f);
|
|
|
|
|
GameApp.Audio.UISoundEnable = !Utility.PlayerPrefsX.GetBool(PrefsKey.Setting.UISoundMuted, false);
|
|
|
|
|
GameApp.Audio.UISoundVolume = Utility.PlayerPrefsX.GetFloat(PrefsKey.Setting.UISoundVolume, 1f);
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-04-28 19:45:45 +08:00
|
|
|
}
|