Пример #1
0
 /// <summary>
 /// AI checking is determined by looking for the commendation icon of players. Sometimes, this icon is missing. This fixes it.
 /// </summary>
 public void CalibrateAIChecking()
 {
     cg.RightClick(744, 62, 250);
     cg.KeyPress(Keys.Enter);
     Thread.Sleep(250);
     cg.GoBack(1);
     cg.ResetMouse();
 }
Пример #2
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);
            }
Пример #3
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);
            }
            /// <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);
            }
Пример #5
0
 internal override void Return(CustomGame cg)
 {
     cg.GoBack(3);
 }