116 lines
2.8 KiB
C#
116 lines
2.8 KiB
C#
using UnityEngine;
|
|
using Vanguard.Api.Contracts;
|
|
using Vanguard.Auth;
|
|
using Vanguard.Battle;
|
|
using Vanguard.Meta;
|
|
using Vanguard.State;
|
|
using Vanguard.UI;
|
|
|
|
namespace Vanguard.App
|
|
{
|
|
public sealed class LobbySceneController : SceneControllerBase
|
|
{
|
|
private AuthService _auth;
|
|
private MetaService _meta;
|
|
private PlayerState _player;
|
|
private MetaView _metaView;
|
|
private OnboardingView _onboarding;
|
|
private QueueView _queue;
|
|
private StoreView _store;
|
|
|
|
private void Start()
|
|
{
|
|
SceneEnvironment.Build(SceneTheme.Lobby);
|
|
|
|
_auth = Resolve<AuthService>();
|
|
_meta = Resolve<MetaService>();
|
|
_player = Resolve<PlayerState>();
|
|
var canvas = CreateCanvas("Lobby Canvas");
|
|
|
|
_metaView = new MetaView(
|
|
canvas.transform,
|
|
_auth,
|
|
_player,
|
|
OnLogout,
|
|
() => _ = Flow.LoadCollectionAsync(),
|
|
() => _ = Flow.LoadDeckBuilderAsync(),
|
|
ShowStore,
|
|
() => _ = Flow.LoadDeckBuilderAsync(),
|
|
ShowOnboarding);
|
|
_onboarding = new OnboardingView(
|
|
canvas.transform, _auth, _meta, OnOnboarded, OnLogout);
|
|
_queue = new QueueView(
|
|
canvas.transform, _meta, _auth, OnQueueBack, OnMatched);
|
|
_store = new StoreView(
|
|
canvas.transform, _meta, _auth, _player, OnStoreBack);
|
|
|
|
ShowDefault();
|
|
}
|
|
|
|
private void ShowDefault()
|
|
{
|
|
var pendingDeck = Flow.ConsumePendingQueueDeck();
|
|
if (pendingDeck != null)
|
|
{
|
|
HideAll();
|
|
_queue.Show(pendingDeck);
|
|
return;
|
|
}
|
|
|
|
HideAll();
|
|
if (_player.OnboardingCompleted)
|
|
_metaView.Show();
|
|
else
|
|
_onboarding.Show();
|
|
}
|
|
|
|
private void ShowOnboarding()
|
|
{
|
|
HideAll();
|
|
_onboarding.Show();
|
|
}
|
|
|
|
private void ShowStore()
|
|
{
|
|
HideAll();
|
|
_store.Show();
|
|
}
|
|
|
|
private void OnStoreBack()
|
|
{
|
|
_store.Hide();
|
|
_metaView.Show();
|
|
}
|
|
|
|
private void OnOnboarded()
|
|
{
|
|
HideAll();
|
|
_metaView.Show();
|
|
}
|
|
|
|
private void OnQueueBack()
|
|
{
|
|
_queue.Hide();
|
|
_metaView.Show();
|
|
}
|
|
|
|
private void OnMatched(MatchConnectionInfo info)
|
|
{
|
|
_ = Flow.LoadBattleAsync(info);
|
|
}
|
|
|
|
private void OnLogout()
|
|
{
|
|
_ = Flow.LoadLoginAsync();
|
|
}
|
|
|
|
private void HideAll()
|
|
{
|
|
_metaView.Hide();
|
|
_onboarding.Hide();
|
|
_queue.Hide();
|
|
_store.Hide();
|
|
}
|
|
}
|
|
}
|