Ejemplo n.º 1
0
		protected override void OnEventFired(object source, ButtonClickedEventArgs args)
		{
			args.Button.IsInteractable = false;

			UnityAsyncHelper.UnityMainThreadContext.PostAsync(async () =>
			{
				if(SelectedCharacterGuid == null)
				{
					Logger.Error($"Tried to enter the world without any selected character guid.");
					return;
				}

				//We do this before sending the player login BECAUSE of a race condition that can be caused
				//since I actually KNOW this event should disable networking. We should not handle messages in this scene after this point basically.
				//TODO: Don't hardcode this scene.
				OnServerRequestedSceneChange?.Invoke(this, new ServerRequestedSceneChangeEventArgs((PlayableGameScene) 2));

				CharacterSessionEnterResponse enterResponse = await CharacterServiceQueryable.TryEnterSession(SelectedCharacterGuid.EntityId);

				if (Logger.IsDebugEnabled)
					Logger.Debug($"Character Session Entry Response: {enterResponse.ResultCode}.");

				if (!enterResponse.isSuccessful)
					if (Logger.IsErrorEnabled)
						Logger.Error($"Failed to enter CharacterSession for Entity: {SelectedCharacterGuid} Reason: {enterResponse.ResultCode}");

				//TODO: handle character session failure
				CharacterData.UpdateCharacterId(SelectedCharacterGuid.EntityId);

				//TODO: Use the scene manager service.
				//TODO: Don't hardcode scene ids. Don't load scenes directly.
				SceneManager.LoadSceneAsync(GladMMOClientConstants.WORLD_DOWNLOAD_SCENE_NAME).allowSceneActivation = true;
			});
		}
Ejemplo n.º 2
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            //When the button is clicked we should disable interaction
            //then we can load the scene async.
            //We should probably disabled the enter-world button too, but we don't have exclusive control over it.
            args.Button.IsInteractable = false;

            //Don't load it async, because then they may click on Enter World or some wacky
            //stuff and who knows what will happen.
            SceneManager.LoadScene(GladMMOClientConstants.CHARACTER_CREATION_SCENE_NAME);
        }
Ejemplo n.º 3
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            //Do nothing, it's not valid.
            if (String.IsNullOrWhiteSpace(FriendInputText.Text))
            {
                return;
            }

            //Disable the add button temporarily.
            AddFriendButton.IsInteractable = false;

            //Try adding them
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    var responseModel = await SocialService.TryAddFriendAsync(FriendInputText.Text);

                    if (responseModel.isSuccessful)
                    {
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info($"Friend add successful. EntityId: {responseModel.Result.NewFriendEntityGuid}");
                        }

                        //Just publish us gaining a new friend.
                        FriendAddedPublisher.PublishEvent(this, new CharacterFriendAddedEventArgs(responseModel.Result.NewFriendEntityGuid));
                    }
                    else
                    if (Logger.IsWarnEnabled)
                    {
                        Logger.Warn($"Friend add failed. Result Code: {responseModel.ResultCode}");
                    }
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Friend add failed. Exception: {e.ToString()}");
                    }

                    throw;
                }
                finally
                {
                    //Close it either way, even if the add failed.
                    //Then renable it for future use.
                    FriendsAddModalWindow.SetElementActive(false);
                    AddFriendButton.IsInteractable = true;
                    FriendInputText.Text           = "";
                }
            });
        }
Ejemplo n.º 4
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            args.Button.IsInteractable = false;

            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                AutofacScope.Dispose();

                //TODO: Vivox is causing crashes again if another gametick happens so we do a blocking call here.
                SceneManager.LoadScene(GladMMOClientConstants.CHARACTER_SELECTION_SCENE_NAME);
            });
        }
Ejemplo n.º 5
0
 protected override void OnEventFired(object source, ButtonClickedEventArgs args)
 {
     if (!Application.isEditor)
     {
         Application.Quit(0);
     }
     else
     {
         //In the editor, log so it's known to be working
         if (Logger.IsDebugEnabled)
         {
             Logger.Debug($"Quit button pressed.");
         }
     }
 }
Ejemplo n.º 6
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            string name = CharacterNameInput.Text;

            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                CharacterCreationResponseCode responseCode = CharacterCreationResponseCode.Success;

                try
                {
                    responseCode = await RequestCharacterCreation(name);
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to handle character creation request. Reason: {e.Message}");
                    }

                    //For the finally block we need to set error
                    responseCode = CharacterCreationResponseCode.GeneralServerError;

                    throw;
                }
                finally
                {
                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"Character creation request Result: {responseCode}");
                    }

                    //Now, we dispatch an event for the result on the main thread.
                    await new UnityYieldAwaitable();

                    OnCharacterCreationAttempted?.Invoke(this, new CharacterCreationAttemptedEventArgs(name, responseCode));
                }
            });
        }
Ejemplo n.º 7
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            //Do nothing, it's not valid.
            if (String.IsNullOrWhiteSpace(GuildInviteInputText.Text))
            {
                return;
            }

            //Disable the add button temporarily.
            InviteGuildMemberButton.IsInteractable = false;
            string memberToInvite = GuildInviteInputText.Text;

            //Try adding them
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    await RealtimeSocialConnection.SendGuildInviteRequestAsync(new GuildMemberInviteRequestModel(memberToInvite));
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Guild invite failed. Exception: {e.ToString()}");
                    }

                    throw;
                }
                finally
                {
                    //Close it either way, even if the add failed.
                    //Then renable it for future use.
                    GuildInviteModalWindow.SetElementActive(false);
                    InviteGuildMemberButton.IsInteractable = true;
                    GuildInviteInputText.Text = "";
                }
            });
        }
Ejemplo n.º 8
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            //Turn off button temporarily
            args.Button.IsInteractable = false;

            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    await AuthService.TryRegister(UsernameText.Text, PasswordText.Text)
                    .ConfigureAwait(true);

                    //If this didn't fail we should re-enable register, even though they shouldn't really do it again.
                    args.Button.IsInteractable = true;
                }
                catch (ApiException apiException)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Encountered Auth Error: {apiException.Message}\n\nStack: {apiException.StackTrace}");
                    }

                    ErrorPublisher.PublishEvent(this, new GeneralErrorEncounteredEventArgs("Registration Failed", $"Error Code: {(int)apiException.StatusCode} Reason: {apiException.Content}. {apiException.Message}", () => args.Button.IsInteractable = true));
                    throw;
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Encountered Auth Error: {e.Message}\n\nStack: {e.StackTrace}");
                    }

                    ErrorPublisher.PublishEvent(this, new GeneralErrorEncounteredEventArgs("Registration Failed", $"Reason: Unknown Server/Client Error: {e.Message}", () => args.Button.IsInteractable = true));
                    throw;
                }
            });
        }
Ejemplo n.º 9
0
 protected override void OnEventFired(object source, ButtonClickedEventArgs args)
 {
     args.Button.IsInteractable = false;
     SceneManager.LoadSceneAsync(GladMMOClientConstants.TITLE_SCREEN_NAME).allowSceneActivation = true;
 }
Ejemplo n.º 10
0
 protected override void OnEventFired(object source, ButtonClickedEventArgs args)
 {
     args.Button.IsInteractable = false;
 }