49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using Vanguard.Auth;
|
|
using Vanguard.UI;
|
|
|
|
namespace Vanguard.App
|
|
{
|
|
public sealed class LoginSceneController : SceneControllerBase
|
|
{
|
|
private AuthService _auth;
|
|
private LoginView _view;
|
|
|
|
private void Start()
|
|
{
|
|
SceneEnvironment.Build(SceneTheme.Login);
|
|
_auth = Resolve<AuthService>();
|
|
var config = Resolve<AppConfig>();
|
|
|
|
var canvas = CreateCanvas("Login Canvas");
|
|
_view = new LoginView(canvas.transform, config, _auth, OnAuthenticated);
|
|
_view.Show("Проверяем сессию…");
|
|
_ = RestoreAsync();
|
|
}
|
|
|
|
private async Task RestoreAsync()
|
|
{
|
|
try
|
|
{
|
|
if (await _auth.TryRestoreAsync())
|
|
{
|
|
await Flow.LoadLobbyAsync();
|
|
return;
|
|
}
|
|
}
|
|
catch (System.Exception exception)
|
|
{
|
|
Debug.LogException(exception);
|
|
}
|
|
|
|
_view.Show("Введите данные игрока.");
|
|
}
|
|
|
|
private void OnAuthenticated()
|
|
{
|
|
_ = Flow.LoadLobbyAsync();
|
|
}
|
|
}
|
|
}
|