示例#1
0
        // event. Click sur le boutton 'Intégrer'
        private void EmbedBtn_Click(object sender, EventArgs e)
        {
            if (GameWindowComboBox.Items.Count > 0)
            {
                BotName     = GameWindowComboBox.SelectedValue.ToString();
                GameProcess = Game.getProcessByWindowTitle(BotName);
                if (GameProcess != null)
                {
                    // suppression du control de choix de la fenêtre du jeu
                    GamePanel.Controls.Remove(SelectWindowGroupBox);

                    // intégration du jeu dans le bot
                    EmbedWindow.SetParent(GameProcess.MainWindowHandle, GamePanel.Handle);
                    EmbedWindow.MoveWindow(GameProcess.MainWindowHandle, -Game.BorderPoint.X, -Game.BorderPoint.Y, GamePanel.Width + Game.BorderSize.Width, GamePanel.Height + Game.BorderSize.Height, true);
                    // changement du nom de la fenêtre/bot
                    this.Text = BotName;
                    // Désactivation du panel du jeu
                    GamePanel.Enabled = false;
                    // Activation des outils du trajet
                    TrajetActionsImageGroupBox.Enabled = true;
                    // Activation de la possibilité de simuler les mouvements d'un trajet
                    SimulateMoveCheckBox.Enabled = true;
                    // Activation de la possibilité de capturer l'écran du jeu
                    ScreenshotToolStripMenuItem.Enabled = true;
                    // Activation de la possibilité de vérouiller/dévérouiller l'interface du jeu
                    LockUnlockGameToolStripMenuItem.Enabled = true;
                    // Activation de la possibilité de la configuration des ressources/IA combat
                    AddResourceBtn.Enabled = true;
                    AddSpellBtn.Enabled    = true;
                    AddTargetBtn.Enabled   = true;
                    // on permet aux threads d'accéder aux controls du BotForm
                    BotForm.CheckForIllegalCrossThreadCalls = false;

                    // initialisation du Log du bot
                    Log = new Log(LogRichTextBox, DebugRichTextBox, BotName);
                    Log.Debug("Game Window : " + BotName);
                    Log.Debug("Game Panel Resolution : " + GamePanel.Width + "x" + GamePanel.Height);

                    // Adaptation des coordonnées des mouvements au Game Panel
                    Core.Move.FitMovesTo(GamePanel.Width, GamePanel.Height);

                    Log.Debug("Move UP Point : " + Core.Move.UP.X + "x" + Core.Move.UP.Y);
                    Log.Debug("Move RIGHT Point : " + Core.Move.RIGHT.X + "x" + Core.Move.RIGHT.Y);
                    Log.Debug("Move DOWN Point : " + Core.Move.DOWN.X + "x" + Core.Move.DOWN.Y);
                    Log.Debug("Move LEFT Point : " + Core.Move.LEFT.X + "x" + Core.Move.LEFT.Y);

                    // Adaptation des coordonnées des pixels à vérifier de la Map au Game Panel
                    Map.FitPixelsToCheckTo(GamePanel.Width, GamePanel.Height);

                    int i = 0;
                    foreach (Point pixel in Map.PixelsToCheck)
                    {
                        Log.Debug("Map Pixel To Check [" + ++i + "] ( X: " + pixel.X + " Y: " + pixel.Y + ")");
                    }
                }
            }
        }
示例#2
0
 // event. FormClosing du formulaire
 private void BotForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (GameProcess == null || MessageBox.Show("Voulez-vous vraiment quitter le bot ?", App.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         if (GameProcess != null)
         {
             // Arret du thread du bot s'il a été démarré
             if (RunBotBtn.Text != "Démarrer")
             {
                 Bot.Stop();
             }
             // remise/réaffichage du jeu sur le bureau
             EmbedWindow.SetParent(GameProcess.MainWindowHandle, IntPtr.Zero); // IntPtr.Zero == NULL (si NULL le parent sera le bureau/desktop)
             EmbedWindow.MoveWindow(GameProcess.MainWindowHandle, Game.DefaultRect.X, Game.DefaultRect.Y, Game.DefaultRect.Width, Game.DefaultRect.Height, true);
         }
     }
     else
     {
         e.Cancel = true;
     }
 }