예제 #1
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;
                }

                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;
                }

                mainModule = gameProcess.MainModule;

                memoryManager = new MemoryManager(gameProcess);
                //codeInjector = new CodeInjector(memoryManager);

                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();
            }
        }