Skip to content

Commit

Permalink
Send players back to their lobby on match end
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed Jun 8, 2024
1 parent ec3644b commit 5c2c597
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
21 changes: 2 additions & 19 deletions Assets/Prefabs/UI/MenuCanvas.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -4012,23 +4012,21 @@ MonoBehaviour:
defaultMenu: {fileID: 110615194986557832}
galleryMenu: {fileID: 2684392273124228428}
creditsMenu: {fileID: 152431690657796851}
playerSelectMenu: {fileID: 4026824962317560842}
playerSelectMenuDefaultButton: {fileID: 2878829664369250595}
mapSelectMenu: {fileID: 3498704505247766114}
levelSelectManager: {fileID: 0}
playerSelectManager: {fileID: 0}
aIButton: {fileID: 5390649776347757468}
startButton: {fileID: 7502603491603641025}
innputManagerPrefab: {fileID: 0}
mapNames:
- CraterTown
- GrandCanyon
uiSelectSounds:
- {fileID: 8300000, guid: df56b3a96f5835849a7515c4036fdf84, type: 3}
- {fileID: 8300000, guid: 1b1b36f86c6a1de4d856a61793a0854d, type: 3}
- {fileID: 8300000, guid: d72483f8877f2684ba4d61b2e3dee9f3, type: 3}
- {fileID: 8300000, guid: 2fc59430bcd0be5418d8e7a5c9273c9d, type: 3}
- {fileID: 8300000, guid: 998e63f1e44797246a2dc7e0887d770e, type: 3}
uiChooseSounds: {fileID: 11400000, guid: 90b0dc5583765d64f81545c255b0fa3a, type: 2}
loadingScreen: {fileID: 0}
mainMenuCamera: {fileID: 0}
--- !u!82 &5626306360106808345
AudioSource:
Expand Down Expand Up @@ -5552,10 +5550,6 @@ PrefabInstance:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3140668245959627490, guid: 58e54f7d80aca2645ab598618dffc039, type: 3}
propertyPath: m_Navigation.m_SelectOnDown
value:
objectReference: {fileID: 5921977457797426374}
- target: {fileID: 3140668245959627490, guid: 58e54f7d80aca2645ab598618dffc039, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 5
Expand Down Expand Up @@ -6017,17 +6011,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &5921977457797426374 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 4761102662359094921, guid: 58e54f7d80aca2645ab598618dffc039, type: 3}
m_PrefabInstance: {fileID: 1170305583697787471}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!224 &8203241732053331208 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 7055458770637592391, guid: 58e54f7d80aca2645ab598618dffc039, type: 3}
Expand Down
6 changes: 1 addition & 5 deletions Assets/Scenes/Menu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 785370674}
m_IndirectSpecularColor: {r: 0.0583656, g: 0.21644169, b: 0.49412873, a: 1}
m_IndirectSpecularColor: {r: 0.062482566, g: 0.21938902, b: 0.4950583, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -5598,10 +5598,6 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4298729392729991341, guid: cbf30f348674af6ecb2ba42ec2aacaf6, type: 3}
propertyPath: m_Navigation.m_SelectOnDown
value:
objectReference: {fileID: 1776070626}
- target: {fileID: 4298729392729991341, guid: cbf30f348674af6ecb2ba42ec2aacaf6, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 5
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/Gamestate/MatchController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ private void ReturnToMainMenu()
PlayerInputManagerController.Singleton.ChangeInputMaps("Menu");

// Mirror pulls us to the main menu automatically
NetworkManager.singleton.StopHost();
if (isServer)
NetworkManager.singleton.ServerChangeScene(Scenes.Menu);
}
}
31 changes: 29 additions & 2 deletions Assets/Scripts/UI/MainMenu/MainMenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
Expand Down Expand Up @@ -41,6 +42,10 @@ public class MainMenuController : MonoBehaviour
[SerializeField]
private CreditsMenu creditsMenu;
[SerializeField]
private GameObject playerSelectMenu;
[SerializeField]
private Selectable playerSelectMenuDefaultButton;
[SerializeField]
private GameObject mapSelectMenu;
[SerializeField]
private LevelSelectManager levelSelectManager;
Expand All @@ -54,8 +59,6 @@ public class MainMenuController : MonoBehaviour
private Button startButton;
[SerializeField]
private GameObject innputManagerPrefab;
[SerializeField]
private string[] mapNames;
private AudioSource audioSource;
[SerializeField]
private AudioClip[] uiSelectSounds;
Expand Down Expand Up @@ -111,6 +114,30 @@ private void Start()
defaultMenu.SetActive(false);
introRoutine = StartCoroutine(WaitForIntroVideoToEnd());
}

if (NetworkManager.singleton.isNetworkActive)
{
GoBackToLobby();
}
}

private void GoBackToLobby()
{
PlayerInputManagerController.Singleton.RemoveJoinListener();
if (NetworkServer.active)
{
// Hosts should be yeeted back into the lobby menu
mainMenuCamera.GetComponentInChildren<MainMenuMoveCamera>().MoveToPlayerSelect();
SwitchToMenu(playerSelectMenu);
SelectControl(playerSelectMenuDefaultButton);
SetStartButtonState();
playerSelectManager.UpdateLobby();
}
else
{
// Clients should go to their own lobby scene
SceneManager.LoadScene(Scenes.ClientLobby);
}
}

private void StopFirstFrame(VideoPlayer source)
Expand Down

0 comments on commit 5c2c597

Please sign in to comment.