public SignInCanvasController(IoCResolver resolver, Canvas canvasView) : base(resolver, canvasView) { // resolve resolver.Resolve(out _messager); resolver.Resolve(out _user); ResolveElement(out _usernameInputField, "username_input_field"); ResolveElement(out _passwordInputField, "password_input_field"); ResolveElement(out _signInButton, "sign_in_button"); ResolveElement(out _createAccountButton, "create_account_button"); // initialize _createAccountButton.onClick.AddListener(() => { ShowCanvas = false; _messager.Publish(new CreateAccountSelectedMessage { OnCancelled = () => ShowCanvas = true, OnConfirmed = credentials => { ShowCanvas = true; _usernameInputField.text = credentials.Username; _passwordInputField.text = credentials.Password; } }); }); _signInButton.onClick.AddListener(AttemptSignIn); }
public MainMenuCanvasController(IoCResolver resolver, Canvas canvasView) : base(resolver, canvasView) { // resolve resolver.Resolve(out _messager); resolver.Resolve(out _user); ResolveElement(out _welcomeText, "welcome_text"); ResolveElement(out _hostGameButton, "host_game_button"); ResolveElement(out _joinGameButton, "join_game_button"); ResolveElement(out _exitGameButton, "exit_game_button"); // initialize ShowCanvas = false; _hostGameButton.onClick.AddListener(() => { _messager.Publish(new HostGameClickedMessage()); }); _exitGameButton.onClick.AddListener(() => { _messager.Publish(new ExitMessage()); }); // subscribe _onMainMenuSelected = _messager.Subscribe <MainMenuSelectedMessage>(message => { ShowCanvas = true; _welcomeText.text = String.Format(LanguageStrings.MainMenuWelcome, _user.Username); }); }
public PlayCanvasController(IoCResolver resolver, Canvas canvasView) : base(resolver, canvasView) { // resolve resolver.Resolve(out _messager); ResolveElement(out _rollDiceButton, "roll_dice_button"); ResolveElement(out _exitGameButton, "exit_game_button"); // initialize _rollDiceButton.onClick.AddListener(() => { _messager.Publish(new RollDiceClickedMessage()); }); _exitGameButton.onClick.AddListener(() => { _messager.Publish(new ExitPlayClickedMessage()); }); }
public void RegisterAccount() { // make sure passwords are the same if (_passwordInputField.text != _passwordConfirmationInputField.text) { ShowCanvas = false; _messager.Publish(new ShowPopUpDialogueMessage { MainDialogue = LanguageStrings.PasswordMismatchError, AllowCancel = false, OnConfirmed = () => ShowCanvas = true }); return; } // make sure the password meets the min character requirements if (_passwordInputField.text.Length < GameConstants.MinPasswordCharacterCount) { ShowCanvas = false; _messager.Publish(new ShowPopUpDialogueMessage { MainDialogue = string.Format(LanguageStrings.InsufficientPasswordLength, GameConstants.MinPasswordCharacterCount), AllowCancel = false, OnConfirmed = () => ShowCanvas = true }); return; } // send out our username and password over to serverland var login = new SignInCredentials { Username = _usernameInputField.text, Password = _passwordInputField.text }; // TODO: send the sign in details to the server and get result var error = RegistrationAttemptError.None; // TODO: for now we just user no error if (error == RegistrationAttemptError.None) { ShowCanvas = false; _messager.Publish(new ShowPopUpDialogueMessage { MainDialogue = LanguageStrings.AccountCreationSuccess, AllowCancel = false, OnConfirmed = () => _currentAccountCreationSession.OnConfirmed(login) }); } else { ShowCanvas = false; _messager.Publish(new ShowPopUpDialogueMessage { MainDialogue = error.ToString().ToFormalString(), AllowCancel = false, OnConfirmed = () => ShowCanvas = true }); } }