Пример #1
0
        public CharCreationMenuEventWiring(
            CharCreationMenu charCreationMenu,
            MainMenu mainMenu,
            CharacterCreation characterCreation,
            WaitScreen waitScreen,
            CharacterList characterList,
            ErrorScreenManager errorScreenManager)
        {
            charCreationMenu.CharacterCreationCompleted += (sender, args) =>
            {
                sender.Close();
                characterCreation.StartCharacterCreation(args.CharCreationInfo);
                waitScreen.Message = "Charaktererstellung läuft...";
                waitScreen.Open();
            };

            characterCreation.CharacterCreationFailed += (sender, args) =>
            {
                charCreationMenu.SetHelpText(args.ReasonText);
                waitScreen.Close();
                errorScreenManager.ShowError(args.ReasonText, charCreationMenu.Open);
            };

            characterCreation.CharacterCreationSuccessful += sender =>
            {
                waitScreen.Message = "Lade Charakterliste...";
                waitScreen.Open();
                characterList.RefreshFromServer();
            };

            charCreationMenu.OnEscape += sender =>
            {
                sender.Close();
                mainMenu.Open();
            };
        }
Пример #2
0
        public LoginMenuWiring(
            LoginMenu loginMenu,
            WaitScreen waitScreen,
            Login.Login login,
            IEnumerable <IClosableMenu> closableMenus,
            CharacterList characterList,
            AccountCreationMenu accountCreationMenu,
            ErrorScreenManager errorScreenManager)
        {
            var menus = closableMenus.ToArray();

            //Login credentials have been entered. Switch to the waiting screen and try to login an the server.
            loginMenu.CredentialsEntered += (sender, args) =>
            {
                //Missing parts of the login information, show an error message.
                if (string.IsNullOrWhiteSpace(args.UserName) || string.IsNullOrWhiteSpace(args.Password))
                {
                    errorScreenManager.ShowError("Accountname und Password eingeben!", loginMenu.Open);
                    return;
                }

                waitScreen.Message = "Login läuft...";
                waitScreen.Open();
                loginMenu.Close();
                login.StartLogin(args.UserName, args.Password);
            };

            //Login got denied for some reason. Show an error message and the go back to the login screen.
            login.LoginDenied += (sender, args) =>
            {
                waitScreen.Close();
                errorScreenManager.ShowError($"Login fehlgeschlagen: {args.ReasonText}", loginMenu.Open);
            };

            //Login successful. Go to the main menu.
            login.LoginAcknowledged += (sender, args) =>
            {
                waitScreen.Message = "Lade Charakterliste...";
                waitScreen.Open();
                characterList.RefreshFromServer();
            };

            //Open the account creation menu.
            loginMenu.CreateAccountSelected += sender =>
            {
                accountCreationMenu.Open();
                loginMenu.Close();
            };


            login.LoggedOut += sender =>
            {
                //CGameManager.ExitSession();
                //Close all menus on logout(its somewhat of a cleanup).
                foreach (var closableMenu in menus)
                {
                    closableMenu.Close();
                }
                loginMenu.Open();
            };
        }
Пример #3
0
        public MainMenuEventWiring(
            MainMenu mainMenu,
            CharCreationMenu charCreationMenu,
            ExitMenu exitMenu,
            ScriptClient client,
            LoginMenu loginMenu,
            Login.Login login,
            WaitScreen waitScreen,
            CharacterSelectionMenu selectionMenu,
            JoinGameSender joinGameSender,
            CharacterList characterList,
            ErrorScreenManager errorScreenManager)
        {
            mainMenu.CharacterCreationSelected += sender =>
            {
                sender.Close();
                charCreationMenu.Open();
            };

            mainMenu.JoinGameSelected += sender =>
            {
                if (!characterList.TryGetActiveCharacter(out Character.Character character))
                {
                    mainMenu.Close();
                    errorScreenManager.ShowError("Kein Character gewählt!", mainMenu.Open);
                    return;
                }

                joinGameSender.StartJoinGame(character);
                waitScreen.Message = "Trete Spiel bei...";
                waitScreen.Open();
                mainMenu.Close();

                //client.SendSpectateMessage();
            };

            mainMenu.BackToLoginSelected += sender =>
            {
                sender.Close();
                waitScreen.Message = "Logout läuft...";
                waitScreen.Open();
                login.StartLogout();
            };

            mainMenu.CharacterSelectionSelected += sender =>
            {
                selectionMenu.Open();
                sender.Close();
            };

            mainMenu.ExitGameSelected += sender =>
            {
                sender.Close();
                exitMenu.Open();
            };

            joinGameSender.JoinGameRequestSuccessful += sender =>
            {
                //The server accepted the join request, close the ui, from here on the server does most of the controlling.
                waitScreen.Close();
            };

            joinGameSender.JoinGameFailed += (sender, args) =>
            {
                //Something went wrong show an error message to the player and then return to the main menu.
                waitScreen.Close();
                errorScreenManager.ShowError(args.ReasonText, mainMenu.Open);
            };
        }