先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System;
|
|
using asap.core;
|
|
using game;
|
|
using GameCore;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
|
|
public class AutoRestart
|
|
{
|
|
private CompositeDisposable disposable = new CompositeDisposable();
|
|
private string lastUnloadedActId;
|
|
|
|
public void Init()
|
|
{
|
|
GContext.OnEvent<ActUnloadedEvent>().Subscribe(OnActUnloaded).AddTo(disposable);
|
|
GContext.OnEvent<ActLoadedEvent>().Subscribe(OnActLoaded).AddTo(disposable);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
disposable.Dispose();
|
|
disposable = null;
|
|
}
|
|
|
|
void OnActUnloaded(ActUnloadedEvent evt)
|
|
{
|
|
Debug.Log($"[AutoRestart::OnActUnloaded] {evt.actID}");
|
|
lastUnloadedActId = evt.actID;
|
|
}
|
|
void OnActLoaded(ActLoadedEvent evt)
|
|
{
|
|
var lastUnloadedActId = this.lastUnloadedActId;
|
|
this.lastUnloadedActId = null;
|
|
Debug.Log($"[AutoRestart::OnActLoaded] {evt.act.Id}");
|
|
if (lastUnloadedActId == "BuildAct" && evt.act.Id == "FishingAct")
|
|
{
|
|
Debug.Log($"[AutoRestart::OnActLoaded] Restart");
|
|
|
|
var userService = GContext.container.Resolve<IUserService>();
|
|
var config = GContext.container.Resolve<IConfig>();
|
|
if (userService == null || !userService.IsLogin || config == null)
|
|
return;
|
|
var loginTime = userService.LoginTime;
|
|
var duration = DateTime.UtcNow - loginTime;
|
|
if (duration.TotalDays >= 3 && config.Get("GM", "0") == "0")
|
|
{
|
|
RebootAlert();
|
|
}
|
|
}
|
|
}
|
|
|
|
private async void RebootAlert()
|
|
{
|
|
GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel);
|
|
var noticeConfirmPopupPanel = go.GetComponent<NoticeConfirmPopupPanel>();
|
|
string title = LocalizationMgr.GetText("UI_NoticePopupPanel_3");
|
|
string info = LocalizationMgr.GetText("UI_NoticePopupPanel_4");
|
|
string label = LocalizationMgr.GetText("UI_COMMON_confirm");
|
|
noticeConfirmPopupPanel.Init(1, title, info, onClickLeft: Reboot, onClose: Reboot, btn_left_text: label);
|
|
}
|
|
|
|
private async void Reboot()
|
|
{
|
|
QuitStage.Logout = true;
|
|
await GContext.container.Resolve<IStageService>().SwitchStageAsync("QuitStage");
|
|
}
|
|
} |