Example #1
0
        private static void Main(string[] args)
        {
            var gameClient = GameClientFactory.CreateClient();

            gameClient.Events.OnGameUpdate += () =>
            {
                Console.WriteLine("OnUpdate Just Triggered");
            };
        }
Example #2
0
        public async Task ManagersGetById()
        {
            var email = "*****@*****.**";

            var client  = GameClientFactory.Create(this.Fixture.Server.CreateClient());
            var manager = await client.GetManagerAsync(email);

            Assert.Equal("*****@*****.**", manager.Email);
            Assert.Equal("Fred Flintstone", manager.Name);
        }
    public ClientMatchController(Match match, UserInput userInput)
    {
        m_match      = match;
        m_inputCtrl  = new InputController(userInput, 0);
        m_gameClient = GameClientFactory.Create();

        var initialData = new PlayersProvider();
        var players     = initialData.GetPlayers(match);

        m_match.SetPlayers(players);
    }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            GameClient[] clients = GameClientFactory.GetActiveGameClients();
            if (clients.Length > 0)
            {
                game             = clients[0];
                statuslabel.Text = "attached";
                enablestuff(true);

                game.Initialized += Game_Initialized;
            }
            else
            {
                statuslabel.Text = "failed to attach";
            }
        }
Example #5
0
        public async Task <PasswordOAuthContext> Login(IAuthRequestData <PasswordAuthData> authRequest)
        {
            var factory = new GameClientFactory(_baseUri);
            var request = factory.CreateRequest("/token");

            request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            request.AddParameter("grant_type", "password");
            request.AddParameter("username", authRequest.RequestData.Usename);
            request.AddParameter("password", authRequest.RequestData.Password);

            var client = new GameClientFactory(_baseUri).CreateClient();

            client.AddHandler("application/json", CustomJsonDeserializer.Default);
            client.AddHandler("text/javascript", CustomJsonDeserializer.Default);
            IRestResponse <OAuthPasswordResponseData> stringToken = null;

            try
            {
                stringToken = await client.ExecutePostTaskAsync <OAuthPasswordResponseData>(request);
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
            }

            if (stringToken.ErrorException != null)
            {
                ExceptionHandlerHelper.HandleHttpRequestException(stringToken.ErrorException);
            }
            if (
                new HttpStatusCode[]
            {
                HttpStatusCode.BadRequest, HttpStatusCode.Forbidden, HttpStatusCode.Unauthorized, HttpStatusCode.BadGateway, HttpStatusCode.InternalServerError
            }.Contains(stringToken.StatusCode))
            {
                HandleNotSuccessRequest(authRequest.RequestData, stringToken);
            }

            return(new PasswordOAuthContext()
            {
                Context = new OAuth2AuthorizationRequestHeaderAuthenticator(stringToken.Data.AccessToken, stringToken.Data.TokenType),
                OAuthToken = stringToken.Data.AccessToken,
                BaseUri = _baseUri
            });
        }
Example #6
0
        /// <summary>
        /// Tries to identify the game client version.
        /// </summary>
        /// <param name="process"></param>
        private void Identify(Process process)
        {
            GameClient gameClient = GameClientFactory.GetGameClient(process, false);

            if (gameClient != null)
            {
                lblStatus.Text       = "You were successfully identified as:" + Environment.NewLine + gameClient.FormattedName;
                label1.Text          = resources.GetString("lblIntroContent.Text");
                radioButton1.Visible = radioButton2.Visible = false;
            }
            else
            {
                md5                  = LEGORacersAPI.Toolbox.GetMD5Hash(process.MainModule.FileName);
                lblStatus.Text       = "Your game could not be identified.";
                label1.Text          = Resources.Resource1.checkfail;
                radioButton1.Visible = radioButton2.Visible = true;
            }
            gameClientDirectory = Path.GetDirectoryName(process.MainModule.FileName);
            btnNext.Enabled     = true;
        }
        /// <summary>
        /// Tries to identify the game client version.
        /// </summary>
        /// <param name="process"></param>
        private void Identify(Process process)
        {
            GameClient gameClient = GameClientFactory.GetGameClient(process, false);

            if (gameClient != null)
            {
                lblStatus.Text = "You were successfully identified as:" + Environment.NewLine + gameClient.FormattedName;

                btnNext.Enabled = true;

                gameClientDirectory = Path.GetDirectoryName(process.MainModule.FileName);
            }
            else
            {
                string md5hash = LEGORacersAPI.Toolbox.GetMD5Hash(process.MainModule.FileName);

                Clipboard.SetText(md5hash);
                MessageBox.Show("We had some trouble to identify you. Your game client files MD5 hash was copied to your clipboard.", "Couldn't find your client");
                lblStatus.Text = "You were not identified.";
            }
        }
Example #8
0
        public async Task ManagersRegister()
        {
            var client = GameClientFactory.Create(this.Fixture.Server.CreateClient());

            throw new NotImplementedException();
        }
Example #9
0
        private void ClientForm_Load(object sender, EventArgs e)
        {
            try
            {
                engineInitialized = false;

                sentLastUsedPowerUp = true;
                powerUpsUsed        = new int[5];

                for (int i = 0; i < 5; i++)
                {
                    powerUpsUsed[i] = 0;
                }

                if (Properties.Settings.Default.ForceVersion != "Auto")
                {
                    gameClient = GameClientFactory.GetGameClient(gameProcess, Properties.Settings.Default.ForceVersion);
                }
                else
                {
                    gameClient = GameClientFactory.GetGameClient(gameProcess);
                }

                gameClient.Initialized += gameClient_Initialized;

                participants = new List <Participant>();

                // Set the amount of players to zero
                playerCount = 0;

                // Create a new Player object that is going to hold the local Player information
                participant = new Participant()
                {
                    Nickname = "Player"
                };

                if (!Toolbox.IsAdministrator())
                {
                    throw new Win32Exception();
                }

                for (int i = 0; i < dataGridPlayers.Columns.Count; i++)
                {
                    dataGridPlayers.Columns[i].Visible = false;
                }

                SetStatus("Not Connected");

                clientState = ClientState.Disconnected;

                // Creates and starts a new thread that will be responsible for updating the client

                thread = new Thread(UpdateClient);
                thread.Start();
            }
            catch (Win32Exception)
            {
                // The Client was (probably) not started with Administrator rights
                MessageBox.Show("Error while finding LEGO Racers process. Please restart the application with Administrator rights.", "Error");

                Close();
            }
            catch (Exception exc)
            {
                // An unknown error occured
                ErrorHandler.ShowDialog("Failed to initialize", "The Client failed to initialize.", exc);

                Close();
            }
        }