Example #1
0
 internal override void Navigate(CustomGame cg)
 {
     cg.NavigateToModesMenu();
     cg.LeftClick(98, 177);
     cg.KeyPress(Keys.Down, Keys.Up, Keys.Up);
     Thread.Sleep(100);
 }
Example #2
0
 internal override void Navigate(CustomGame cg)
 {
     cg.GoToSettings();
     cg.LeftClick(373, 182, 100);
     cg.KeyPress(Keys.Down);
     Thread.Sleep(100);
 }
Example #3
0
            internal override void Navigate(CustomGame cg)
            {
                cg.NavigateToModesMenu();
                Point point = cg.GetModeLocation(Gamemode.Skirmish, cg.CurrentEvent);

                cg.LeftClick(point.X, point.Y, 250);
                cg.KeyPress(Keys.Left);
                Thread.Sleep(100);
            }
Example #4
0
            internal override void Navigate(CustomGame cg)
            {
                cg.NavigateToModesMenu();
                Point point = cg.GetModeLocation(Gamemode.TeamDeathmatch, cg.CurrentOverwatchEvent);

                cg.LeftClick(point.X, point.Y, 250);
                cg.KeyPress(Keys.Down, Keys.Up);
                Thread.Sleep(100);
            }
Example #5
0
            internal override void Navigate(CustomGame cg)
            {
                cg.NavigateToModesMenu();
                Point point = cg.GetModeLocation(Gamemode.JunkensteinsRevenge, cg.CurrentEvent);

                Console.WriteLine(point);
                cg.LeftClick(point.X, point.Y, 250);
                cg.KeyPress(Keys.Left);
                Thread.Sleep(100);
            }
Example #6
0
            /// <summary>
            /// Toggles maps in Overwatch.
            /// </summary>
            /// <param name="modesEnabled">The modes enabled in the overwatch game.</param>
            /// <param name="currentOverwatchEvent">The current Overwatch event.</param>
            /// <param name="ta">Determines if all maps should be enabled, disabled or neither before toggling.</param>
            /// <param name="maps">Maps that should be toggled.</param>
            public void ToggleMap(ModesEnabled modesEnabled, Event currentOverwatchEvent, ToggleAction ta, params Map[] maps)
            {
                cg.GoToSettings();

                cg.LeftClick(103, 300, 1000); // Clicks "Maps" button (SETTINGS/MAPS/)

                // Click Disable All or Enable All in custom games if ta doesnt equal ToggleAction.None.
                if (ta == ToggleAction.DisableAll)
                {
                    cg.LeftClick(640, 125, 250);
                }
                else if (ta == ToggleAction.EnableAll)
                {
                    cg.LeftClick(600, 125, 250);
                }

                // Get the modes enabled state in a bool in alphabetical order.
                bool[] enabledModes = new bool[]
                {
                    modesEnabled.Assault,
                    modesEnabled.AssaultEscort,
                    modesEnabled.CaptureTheFlag,
                    modesEnabled.Control,
                    modesEnabled.Deathmatch,
                    modesEnabled.Elimination,
                    modesEnabled.Escort,
                    modesEnabled.JunkensteinsRevenge,
                    modesEnabled.Lucioball,
                    modesEnabled.MeisSnowballOffensive,
                    modesEnabled.Skirmish,
                    modesEnabled.TeamDeathmatch,
                    modesEnabled.YetiHunter
                };

                List <int> selectMap = new List <int>();
                int        mapcount  = 0;

                // For each enabled mode...
                for (int i = 0; i < enabledModes.Length; i++)
                {
                    if (enabledModes[i])
                    {
                        Gamemode   emi         = (Gamemode)i; //enabledmodesindex
                        List <Map> allowedmaps = GetMapsInGamemode(emi, currentOverwatchEvent);
                        // ...And for each map...
                        for (int mi = 0; mi < maps.Length; mi++)
                        {
                            // ...Check if the maps mode equals the enabledModes index and check if the map is in allowed maps...
                            if (maps[mi].GameMode == emi && allowedmaps.Contains(maps[mi]))
                            {
                                // ...then add the map index to the selectmap list. 1, 5, 10 will toggle the first map in overwatch, the fifth, then the tenth...
                                selectMap.Add(mapcount + allowedmaps.IndexOf(maps[mi]) + 1);
                            }
                        }
                        // ...then finally add the number of maps in the mode to the mapcount.
                        mapcount += allowedmaps.Count;
                    }
                }
                mapcount++;

                // Toggle maps
                for (int i = 0; i < mapcount; i++)
                {
                    for (int mi = 0; mi < selectMap.Count; mi++)
                    {
                        if (selectMap[mi] == i)
                        {
                            cg.KeyPress(Keys.Space);
                            Thread.Sleep(1);
                        }
                    }
                    cg.KeyPress(Keys.Down);
                    Thread.Sleep(1);
                }

                cg.GoBack(2, 0);
            }
Example #7
0
            /// <summary>
            /// Add AI to the game.
            /// </summary>
            /// <param name="hero">Hero type to add.</param>
            /// <param name="difficulty">Difficulty of hero.</param>
            /// <param name="team">Team that AI joins.</param>
            /// <param name="count">Amount of AI that is added. Set to -1 for max. Default is -1</param>
            /// <returns></returns>
            public bool AddAI(AIHero hero, Difficulty difficulty, BotTeam team, int count = -1)
            {
                cg.updateScreen();

                // Find the maximum amount of bots that can be placed on a team, and store it in the maxBots variable

                if (cg.DoesAddButtonExist())

                /*
                 * If the blue shade of the "Move" button is there, that means that the Add AI button is there.
                 * If the Add AI button is missing, we can't add AI, so return false. If it is there, add the bots.
                 * The AI button will be missing if the server is full
                 */
                {
                    // Open AddAI menu.
                    cg.Cursor = new Point(835, 182);
                    cg.WaitForUpdate(835, 182, 20, 2000);
                    cg.LeftClick(835, 182, 500);

                    List <Keys> press = new List <Keys>();

                    if (hero != AIHero.Recommended)
                    {
                        press.Add(Keys.Space);
                        int heroid = (int)hero;
                        for (int i = 0; i < heroid; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);

                    if (difficulty != Difficulty.Easy)
                    {
                        press.Add(Keys.Space);
                        int difficultyID = (int)difficulty;
                        for (int i = 0; i < difficultyID; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);
                    press.Add(Keys.Down);

                    if (team != BotTeam.Both)
                    {
                        press.Add(Keys.Space);
                        int teamID = (int)team;
                        for (int i = 0; i < teamID; i++)
                        {
                            press.Add(Keys.Down);
                        }
                        press.Add(Keys.Space);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                        press.Add(Keys.Down);
                    }

                    if (count > 0)
                    {
                        press.Add(Keys.Up);
                        for (int i = 0; i < 12; i++)
                        {
                            press.Add(Keys.Left);
                        }
                        for (int i = 0; i < count; i++)
                        {
                            press.Add(Keys.Right);
                        }
                        press.Add(Keys.Down);
                    }

                    press.Add(Keys.Down);
                    press.Add(Keys.Space);

                    cg.KeyPress(press.ToArray());

                    cg.ResetMouse();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            /// <summary>
            /// Loads a preset saved in Overwatch, 0 being the first saved preset.
            /// </summary>
            /// <param name="preset">Preset to load.</param>
            /// <param name="maxWaitTime">Maximum time to wait for the preset to show up.</param>
            // Loads a preset in Overwatch Custom Games
            public bool LoadPreset(int preset, int maxWaitTime = 5000)
            {
                if (preset < 0)
                {
                    throw new ArgumentOutOfRangeException("preset", preset, "Argument preset must be equal or greater than 0.");
                }

                Point presetLocation = GetPresetLocation(preset);

                cg.GoToSettings();
                cg.LeftClick(103, 183, 2000); // Clicks "Preset" button

                Stopwatch wait = new Stopwatch();

                wait.Start();

                if (numPresets == null)
                {
                    while (true)
                    {
                        cg.updateScreen();

                        if (cg.CompareColor(presetLocation.X, presetLocation.Y, new int[] { 126, 128, 134 }, 40))
                        {
                            break;
                        }
                        else if (wait.ElapsedMilliseconds >= maxWaitTime)
                        {
                            cg.GoBack(2);
                            cg.ResetMouse();
                            return(false);
                        }

                        Thread.Sleep(100);
                    }
                }
                else
                {
                    Point finalPresetLocation = GetPresetLocation(numPresets);
                    while (true)
                    {
                        cg.updateScreen();

                        if (cg.CompareColor(finalPresetLocation.X, finalPresetLocation.Y, new int[] { 126, 128, 134 }, 40))
                        {
                            break;
                        }
                        else if (wait.ElapsedMilliseconds >= maxWaitTime)
                        {
                            cg.GoBack(2);
                            cg.ResetMouse();
                            return(false);
                        }

                        Thread.Sleep(100);
                    }
                }

                Thread.Sleep(250);

                cg.LeftClick(presetLocation.X, presetLocation.Y); // Clicks the preset
                cg.LeftClick(480, 327);                           // Clicks confirm

                // Go back to lobby
                cg.GoBack(2);
                cg.ResetMouse();
                return(true);
            }
Example #9
0
            /// <summary>
            /// Loads a preset saved in Overwatch, 0 being the first saved preset.
            /// </summary>
            /// <param name="preset">Preset to load.</param>
            // Loads a preset in Overwatch Custom Games
            public void LoadPreset(int preset)
            {
                if (preset < 0)
                {
                    throw new ArgumentOutOfRangeException("preset", preset, "Argument preset must be greater than 0.");
                }

                int x = 0;
                int y = 155;

                // Number of presets in a row is 4.
                while (preset > 3)
                {
                    preset = preset - 4;
                    y      = y + 33; // Increment row by 1. Space between rows is 33 pixels.
                }
                if (preset == 0)
                {
                    x = 146;              // Column 1
                }
                else if (preset == 1)
                {
                    x = 294;                   // Column 2
                }
                else if (preset == 2)
                {
                    x = 440;                   // Column 3
                }
                else if (preset == 3)
                {
                    x = 590;                   // Column 4
                }
                cg.GoToSettings();
                cg.LeftClick(103, 183, 2000); // Clicks "Preset" button

                cg.updateScreen();
                while (cg.CompareColor(91, 174, new int[] { 188, 143, 77 }, 10))
                {
                    cg.updateScreen(); Thread.Sleep(100);
                }
                cg.LeftClick(x, y);     // Clicks the preset
                cg.LeftClick(480, 327); // Clicks confirm

                // Go back to lobby
                cg.GoBack(2);
            }
 // Selects an option in the slot menu.
 internal bool SelectMenuOption(Point point)
 {
     cg.Cursor = point; // Select the option
     Thread.Sleep(100);
     // <image url="$(ProjectDir)\ImageComments\Interact.cs\OptionSelect.png" scale="0.7" />
     cg.updateScreen();
     if (cg.CompareColor(point.X, point.Y, new int[] { 83, 133, 155 }, 20)) // Detects if the blue color of the selected option is there, clicks then returns true
     {
         cg.LeftClick(point.X, point.Y, 0);
         cg.ResetMouse();
         return(true);
     }
     return(false);
 }
Example #11
0
 internal void OpenChat()
 {
     cg.LeftClick(105, 504, 100);
 }