示例#1
0
        public InGameMenuWiring(ScriptClient client, InGameMenu inGameMenu, ExitMenu exitMenu, WaitScreen waitScreen, Login.Login login, CharacterList characterList, LeaveGameSender leaveMsgSender)
        {
            inGameMenu.BackToMainMenu += sender =>
            {
                leaveMsgSender.SendLeaveGameMessage();
                waitScreen.Message = "Lade Charakterliste...";
                waitScreen.Open();
                sender.Close();
                characterList.RefreshFromServer();
            };


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


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

            inGameMenu.OnEscape += sender => sender.Close();
        }
        public CloudServiceClientBase(
            ILogger logger,
            IHttpClientFactory clientFactory,
            IHttpPlatformHelperService http_helper,
            IToast toast,
            IAuthHelper authHelper,
            ICloudServiceSettings settings,
            IModelValidator validator) : base(logger, http_helper, clientFactory)
        {
            this.authHelper = authHelper;
            this.toast      = toast;
            this.settings   = settings;
            ApiBaseUrl      = string.IsNullOrWhiteSpace(settings.ApiBaseUrl)
                ? throw new ArgumentNullException(nameof(ApiBaseUrl)) : settings.ApiBaseUrl;
            connection = new ApiConnection(logger, this, http_helper, validator);

            #region SetClients

            Account       = new AccountClient(connection);
            Manage        = new ManageClient(connection);
            AuthMessage   = new AuthMessageClient(connection);
            Version       = new VersionClient(connection);
            ActiveUser    = new ActiveUserClient(connection);
            Accelerate    = new AccelerateClient(connection);
            Script        = new ScriptClient(connection);
            DonateRanking = new DonateRankingClient(connection);

            #endregion
        }
示例#3
0
        public void HandleMessage(ScriptClient sender, PacketReader stream)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            try
            {
                //Get the id of the last active character and the amount of characters that are encoded in the script message.
                int activeCharacterId = stream.ReadInt();
                int characterCount    = stream.ReadByte();

                //Read all characters that are encoded in the message.
                var characters = new List <Character.Character>(characterCount);
                for (int i = 0; i < characterCount; i++)
                {
                    characters.Add(_CharacterVisualsReader.ReadCharacter(stream));
                }


                CharacterListReceived?.Invoke(this, new CharacterListReceivedArgs(characters, activeCharacterId));
            }
            catch (Exception e)
            {
                string msg = $"Something went wrong while handling a script message of type '{SupportedMessage}'";
                _Log.Error(msg);
                throw new ScriptMessageHandlingException(msg, e);
            }
        }
示例#4
0
        public void HandleMessage(ScriptClient sender, PacketReader stream)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            try
            {
                bool success = stream.ReadBit();
                if (success)
                {
                    JoinGameSuccessReceived?.Invoke(this);
                }
                else
                {
                    JoinGameFailedReason reason = (JoinGameFailedReason)stream.ReadByte();
                    JoinGameFailedReceived?.Invoke(this, reason);
                }
            }
            catch (Exception e)
            {
                _Log.Error($"Failed to handle a script message of typ {SupportedMessage}. Exception: {e}");
                JoinGameFailedReceived?.Invoke(this, JoinGameFailedReason.MessageHandlingError);
            }
        }
示例#5
0
        public void HandleMessage(ScriptClient sender, PacketReader stream)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            try
            {
                bool success = stream.ReadBit();
                if (success)
                {
                    CharacterCreationSuccessful?.Invoke(this);
                }
                else
                {
                    CharacterCreationFailure reason = (CharacterCreationFailure)stream.ReadByte();
                    CharacterCreationFailed?.Invoke(this, reason);
                }
            }
            catch (Exception e)
            {
                string msg = $"Something went wrong while handling a '{SupportedMessage}' script message from the server.";
                _Log.Error(msg);
                throw new ScriptMessageHandlingException(msg, e);
            }
        }
示例#6
0
 public Script(
     ScriptOptions options,
     LookupClientProvider dnsClient,
     ILogService log,
     string identifier) :
     base(dnsClient, log, options, identifier)
 {
     _scriptClient = new ScriptClient(log);
 }
        /// <summary>
        /// 获取服务中的所有函数列表
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static List <IItemBox> FromServerGetIItemboxInfos(string url)
        {
            ScriptClient scriptClient = new ScriptClient();

            string json = scriptClient.GetStringAsync(url);


            scriptClient.Dispose();
            scriptClient = null;
            return(JsonConvert.DeserializeObject <List <IItemBox> >(json));
        }
示例#8
0
 public Script(
     ScriptOptions options,
     LookupClientProvider dnsClient,
     ScriptClient client,
     ILogService log,
     ISettingsService settings,
     string identifier) :
     base(dnsClient, log, settings)
 {
     _identifier   = identifier;
     _options      = options;
     _scriptClient = client;
 }
示例#9
0
 public Script(
     ScriptOptions options,
     LookupClientProvider dnsClient,
     ScriptClient client,
     ILogService log,
     DomainParseService domainParseService,
     ISettingsService settings) :
     base(dnsClient, log, settings)
 {
     _options            = options;
     _scriptClient       = client;
     _domainParseService = domainParseService;
 }
示例#10
0
        public Network.GameClient CreateClient()
        {
            //throw new Exception("Why should the base script need to create a script client?");
            ////return new ScriptClient().BaseClient; //;
            ///
            if (_DiContainer == null)
            {
                _DiContainer = _DiBuilder.Build();
            }

            _Client = _DiContainer.Resolve <ScriptClient>();
            return(_Client.BaseClient);
        }
示例#11
0
        public async Task Connect(ConnectionSettings settings)
        {
            if (_session != null)
            {
                throw new InvalidOperationException("Cannot connect because the client is already connected");
            }

            _commonClient       = new CommonClient();
            _hashClient         = new HashClient();
            _listClient         = new ListClient();
            _scriptClient       = new ScriptClient();
            _stringClient       = new StringClient();
            _transactionClient  = new TransactionClient();
            _setClient          = new SetClient();
            _subscriptionClient = new SubscriptionClient();
            _session            = await _commonClient.Connect(settings).ConfigureAwait(false);

            if (!_session.IsOpen)
            {
                throw new IOException("Session could not be opened");
            }

            OnConnected?.Invoke(this);
        }
示例#12
0
 public Script(Target target, ScriptOptions options, ILogService log, string identifier) : base(log, options, identifier)
 {
     _scriptClient = new ScriptClient(log);
 }
示例#13
0
 public Script(Renewal renewal, ScriptOptions options, ScriptClient client)
 {
     _options = options;
     _renewal = renewal;
     _client  = client;
 }
示例#14
0
 public void RunScript()
 {
     ScriptClient.RunScript(ScriptFileLocation, Api);
 }
示例#15
0
 public Script(Target target, ScriptOptions options, DomainParser domainParser, ILookupClientProvider lookupClientProvider, ILogService log, string identifier) : base(domainParser, lookupClientProvider, log, options, identifier)
 {
     _scriptClient = new ScriptClient(log);
 }
示例#16
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);
            };
        }
示例#17
0
 public void RunScript()
 {
     ScriptClient.RunScript(ScriptFileName, Api);
 }
示例#18
0
 public Script(Target target)
 {
     _dnsScriptOptions = target.DnsScriptOptions;
     _scriptClient     = new ScriptClient();
 }
示例#19
0
 public DnsScript(Target target, ILogService log, string identifier) : base(log, identifier)
 {
     _dnsScriptOptions = target.DnsScriptOptions;
     _scriptClient     = new ScriptClient(log);
 }
示例#20
0
        public ArenaControl(ScriptClient client, ChatMenu chatMenu, InGameMenu inGameMenu)
        {
            _Client     = client ?? throw new ArgumentNullException(nameof(client));
            _ChatMenu   = chatMenu ?? throw new ArgumentNullException(nameof(chatMenu));
            _InGameMenu = inGameMenu ?? throw new ArgumentNullException(nameof(inGameMenu));

            _PlayerControls = new KeyDictionary()
            {
                { KeyBind.Jump, Jump },
                {
                    KeyBind.DrawFists, d =>
                    {
                        if (d)
                        {
                            NPCInst.Requests.DrawFists(ScriptClient.Client.Character);
                        }
                    }
                },
                { KeyBind.MoveForward, d => CheckFightMove(d, FightMoves.Fwd) },
                { KeyBind.TurnLeft, d => CheckFightMove(d, FightMoves.Left) },
                { KeyBind.TurnRight, d => CheckFightMove(d, FightMoves.Right) },
                { KeyBind.MoveBack, d => CheckFightMove(d, FightMoves.Parry) },
                { KeyBind.MoveLeft, d => CheckFightMove(d, FightMoves.Left) },
                { KeyBind.MoveRight, d => CheckFightMove(d, FightMoves.Right) },
                { KeyBind.Action, PlayerActionButton },
                { KeyBind.DrawWeapon, DrawWeapon },
                { KeyBind.ScoreBoard, ToggleScoreBoard },
                {
                    KeyBind.ChatAll, d =>
                    {
                        if (d)
                        {
                            _ChatMenu.OpenAllChat();
                        }
                    }
                },
                {
                    KeyBind.ChatTeam, d =>
                    {
                        if (d)
                        {
                            _ChatMenu.OpenTeamChat();
                        }
                    }
                },
                {
                    KeyBind.Inventory, d =>
                    {
                        if (d)
                        {
                            Sumpfkraut.Menus.PlayerInventory.Menu.Open();
                        }
                    }
                },
                { VirtualKeys.P, PrintPosition },
                { VirtualKeys.F2, d => Menus.PlayerList.TogglePlayerList() },
                { VirtualKeys.F3, ToggleG1Camera },
                { VirtualKeys.F5, ToggleScreenInfo },
                { VirtualKeys.N1, DrawMeleeWeapon },
                { VirtualKeys.N2, DrawRangedWeapon },
                { VirtualKeys.RightButton, FreeAim },
                { KeyBind.StatusMenu, OpenStatusMenu }
            };

            _SpectatorControls = new KeyDictionary()
            {
                { VirtualKeys.Shift, down => speedMultiplier = !down ? defaultSpeed : fastSpeed },
                { KeyBind.ChatAll, d => { if (d)
                                          {
                                              _ChatMenu.OpenAllChat();
                                          }
                  } },
                { KeyBind.ChatTeam, d => { if (d)
                                           {
                                               _ChatMenu.OpenTeamChat();
                                           }
                  } },
                { KeyBind.ScoreBoard, ToggleScoreBoard },
                { VirtualKeys.F2, d => Menus.PlayerList.TogglePlayerList() },
                { VirtualKeys.F3, ToggleG1Camera },
                { VirtualKeys.F5, ToggleScreenInfo },
            };
        }