This commit is contained in:
wuwenbo 2025-10-30 16:00:21 +08:00
commit 53df03a955
3 changed files with 30 additions and 11 deletions

View File

@ -57,7 +57,16 @@ namespace TH1_Logic.Steam
if (message.MapData == null) return;
if (LobbyManager.Instance.Lobby.IsLobbyOwner()) return;
LogSystem.LogWarning($"OnReceivedGameStart : {NetData.GetMapDataHash(message.MapData)}");
Main.Instance.NetStartGame(message.MapData);
//客户端开启游戏
//如果loading失败 直接开始游戏并关闭当前页面
if (!UIManager.Instance.ShowLoading())
Main.Instance.NetStartGame(message.MapData);
else
Timer.Instance.TimerRegister(this, ()=> { Main.Instance.NetStartGame(message.MapData); },0.5f,"Multi_ShowLoading");
EventManager.Publish(new HideUIOutsideMultiplay(){});
}

View File

@ -90,5 +90,11 @@ namespace TH1_UI.Controller.Interaction
{
Close();
}
public override bool Close()
{
WindowScript?.OnCloseView();
return base.Close();
}
}
}

View File

@ -62,7 +62,10 @@ namespace TH1_UI.View.Outside
public List<Button> DifficultyButtonList;
private SteamLobbyManager _lobby;
//关闭时执行的委托
public ViDelegateAssisstant.Dele OnBtnCloseClick;
//开始游戏时执行的委托(目前委托内容就是执行controller的Close())
public ViDelegateAssisstant.Dele OnStartGame;
private bool _noRoom = false;
@ -73,7 +76,6 @@ namespace TH1_UI.View.Outside
CloseButton.onClick.AddListener(() =>
{
LeaveRoom();
OnCloseView();
OnBtnCloseClick.Invoke();
UIManager.Instance.GameUI.MainUI.NeedShow = true;
@ -399,8 +401,9 @@ namespace TH1_UI.View.Outside
}
}
ShowLoadingAndStartGame();
OnCloseView();
if(Main.Instance.HasMultiArchive() && ResumeToggle.isOn)
ShowLoadingAndStartGame(true);
else ShowLoadingAndStartGame(false);
}
public void ShowLoadingAndStartGame(bool resume = false)
@ -413,14 +416,14 @@ namespace TH1_UI.View.Outside
Main.Instance.MainMemberStartGame();
else
Main.Instance.MainMemberContinueGame();
//OnstartGame会自动执行controller的Close close会负责触发view的CloseView
OnStartGame?.Invoke();
return;
}
Timer.Instance.TimerRegister(this,Main.Instance.MainMemberStartGame,0.5f,"Multi_ShowLoading");
Timer.Instance.TimerRegister(this, () =>
{
OnStartGame?.Invoke();
},0.5f,"Multi_ShowLoading");
//否则带有延时执行
Timer.Instance.TimerRegister(this,resume ? Main.Instance.MainMemberContinueGame:Main.Instance.MainMemberStartGame,0.5f,"Multi_ShowLoading");
Timer.Instance.TimerRegister(this, ()=> { OnStartGame?.Invoke(); },0.5f,"Multi_ShowLoading");
}
@ -451,13 +454,14 @@ namespace TH1_UI.View.Outside
Main.Instance.MapConfig.AIDiff = difficult;
}
private void OnCloseView()
//在Controller 调用Close的时候会先调用这个closeview
public void OnCloseView()
{
_lobby.OnMembersChangedEvent -= RefreshAll;
_lobby.OnLobbyLeftEvent -= RefreshAll;
}
}
}