73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
|
|
using Cysharp.Threading.Tasks;
|
||
|
|
using AlicizaX.Fsm.Runtime;
|
||
|
|
using AlicizaX.Procedure.Runtime;
|
||
|
|
using AlicizaX.Runtime;
|
||
|
|
|
||
|
|
namespace Unity.Startup.Procedure
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 启动游戏
|
||
|
|
/// </summary>
|
||
|
|
public class ProcedureLauncherState : ProcedureBase
|
||
|
|
{
|
||
|
|
private bool _gameSettingInitFinish;
|
||
|
|
|
||
|
|
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
|
||
|
|
{
|
||
|
|
base.OnEnter(procedureOwner);
|
||
|
|
LauncherUIHandler.Start();
|
||
|
|
InitlizeGameSetting();
|
||
|
|
}
|
||
|
|
|
||
|
|
private async void Start(IFsm<IProcedureManager> procedureOwner)
|
||
|
|
{
|
||
|
|
await UniTask.NextFrame();
|
||
|
|
ChangeState<ProcedureGetGlobalInfoState>(procedureOwner);
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds, float realElapseSeconds)
|
||
|
|
{
|
||
|
|
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
|
||
|
|
if (_gameSettingInitFinish)
|
||
|
|
{
|
||
|
|
Start(procedureOwner);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private void InitlizeGameSetting()
|
||
|
|
{
|
||
|
|
bool isWrited = GameApp.Setting.GetBool(PrefsKey.Setting.WirtedSetting, false);
|
||
|
|
if (!isWrited)
|
||
|
|
{
|
||
|
|
WriteDefaultSetting();
|
||
|
|
}
|
||
|
|
|
||
|
|
InitSoundSettings();
|
||
|
|
_gameSettingInitFinish = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void WriteDefaultSetting()
|
||
|
|
{
|
||
|
|
GameApp.Setting.SetBool(PrefsKey.Setting.WirtedSetting, true);
|
||
|
|
GameApp.Setting.SetInt(PrefsKey.Setting.Language, (int)Language.ChineseSimplified);
|
||
|
|
GameApp.Setting.SetBool(PrefsKey.Setting.MusicMuted, false);
|
||
|
|
GameApp.Setting.SetFloat(PrefsKey.Setting.MusicVolume, 1f);
|
||
|
|
GameApp.Setting.SetBool(PrefsKey.Setting.SoundMuted, false);
|
||
|
|
GameApp.Setting.SetFloat(PrefsKey.Setting.SoundVolume, 1f);
|
||
|
|
GameApp.Setting.SetBool(PrefsKey.Setting.UISoundMuted, false);
|
||
|
|
GameApp.Setting.SetFloat(PrefsKey.Setting.UISoundVolume, 1f);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private void InitSoundSettings()
|
||
|
|
{
|
||
|
|
GameApp.Audio.MusicEnable = !GameApp.Setting.GetBool(PrefsKey.Setting.MusicMuted, false);
|
||
|
|
GameApp.Audio.MusicVolume = GameApp.Setting.GetFloat(PrefsKey.Setting.MusicVolume, 1f);
|
||
|
|
GameApp.Audio.SoundEnable = !GameApp.Setting.GetBool(PrefsKey.Setting.SoundMuted, false);
|
||
|
|
GameApp.Audio.SoundVolume = GameApp.Setting.GetFloat(PrefsKey.Setting.SoundVolume, 1f);
|
||
|
|
GameApp.Audio.UISoundEnable = !GameApp.Setting.GetBool(PrefsKey.Setting.UISoundMuted, false);
|
||
|
|
GameApp.Audio.UISoundVolume = GameApp.Setting.GetFloat(PrefsKey.Setting.UISoundVolume, 1f);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|