74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Hallucinate.UI
|
|
{
|
|
public class LobbyController : BaseUIController
|
|
{
|
|
private VisualElement _joinContainer;
|
|
private VisualElement _createContainer;
|
|
private VisualElement _loungeContainer;
|
|
|
|
private Button _backBtn;
|
|
private Button _createFinalBtn;
|
|
private Button _startGameBtn;
|
|
|
|
private Toggle _hostReady;
|
|
private Toggle _guestReady;
|
|
|
|
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
|
{
|
|
base.Initialize(uxmlRoot, manager);
|
|
|
|
_joinContainer = root.Q<VisualElement>("JoinContainer");
|
|
_createContainer = root.Q<VisualElement>("CreateContainer");
|
|
_loungeContainer = root.Q<VisualElement>("LoungeContainer");
|
|
|
|
_backBtn = root.Q<Button>("BackToMenuBtn");
|
|
_createFinalBtn = root.Q<Button>("CreateRoomFinalBtn");
|
|
_startGameBtn = root.Q<Button>("StartGameBtn");
|
|
|
|
_hostReady = root.Q<Toggle>("HostReady");
|
|
_guestReady = root.Q<Toggle>("GuestReady");
|
|
|
|
_backBtn.clicked += () => uiManager.Pop();
|
|
_createFinalBtn.clicked += () => ShowLounge();
|
|
|
|
_hostReady.RegisterValueChangedCallback(evt => UpdateStartButton());
|
|
_guestReady.RegisterValueChangedCallback(evt => UpdateStartButton());
|
|
|
|
UpdateStartButton();
|
|
}
|
|
|
|
public void ShowJoin()
|
|
{
|
|
_joinContainer.style.display = DisplayStyle.Flex;
|
|
_createContainer.style.display = DisplayStyle.None;
|
|
_loungeContainer.style.display = DisplayStyle.None;
|
|
}
|
|
|
|
public void ShowCreate()
|
|
{
|
|
_joinContainer.style.display = DisplayStyle.None;
|
|
_createContainer.style.display = DisplayStyle.Flex;
|
|
_loungeContainer.style.display = DisplayStyle.None;
|
|
}
|
|
|
|
public void ShowLounge()
|
|
{
|
|
_joinContainer.style.display = DisplayStyle.None;
|
|
_createContainer.style.display = DisplayStyle.None;
|
|
_loungeContainer.style.display = DisplayStyle.Flex;
|
|
}
|
|
|
|
private void UpdateStartButton()
|
|
{
|
|
if (_startGameBtn != null)
|
|
{
|
|
_startGameBtn.SetEnabled(_hostReady.value && _guestReady.value);
|
|
}
|
|
}
|
|
}
|
|
}
|