예제 #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);
 }
예제 #2
0
 internal override void Navigate(CustomGame cg)
 {
     cg.GoToSettings();
     cg.LeftClick(373, 182, 100);
     cg.KeyPress(Keys.Down);
     Thread.Sleep(100);
 }
예제 #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);
            }
예제 #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);
            }
예제 #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);
            }
 /// <summary>
 /// Changes the custom game's name.
 /// </summary>
 /// <param name="name">Name to change game name to.</param>
 // Changes the game's name
 public void SetGameName(string name)
 {
     if (name.Length < 3)
     {
         throw new ArgumentOutOfRangeException("name", name, "The length of name is too low, needs to be at least 3.");
     }
     if (name.Length > 64)
     {
         throw new ArgumentOutOfRangeException("name", name, "The length of name is too high, needs to be 64 or lower.");
     }
     cg.LeftClick(209, 165); // click on game's name
     cg.TextInput(name);
     cg.KeyPress(Keys.Return);
     Thread.Sleep(500);
 }
예제 #7
0
 /// <summary>
 /// Send message to chat.
 /// </summary>
 /// <param name="text">Text to send.</param>
 public void Chat(string text)
 {
     if (ChatPrefix != null)
     {
         text = ChatPrefix + " " + text;
     }
     //if (!cg.OpenChatIsDefault)
     OpenChat();
     cg.updateScreen();
     // To prevent abuse, make sure that the channel is not general.
     if (!cg.CompareColor(ChatLocation.X, ChatLocation.Y, GeneralChatColor, 20) || !BlockGeneralChat)
     {
         cg.TextInput(text);
     }
     cg.KeyPress(Keys.Return);
     if (cg.OpenChatIsDefault)
     {
         Thread.Sleep(250);
         OpenChat();
     }
     cg.ResetMouse();
 }
예제 #8
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);
            }
예제 #9
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);
                }
            }
예제 #10
0
        internal void SetSettings(CustomGame cg)
        {
            Navigate(cg);

            object[] values = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance).Select(v => v.GetValue(this)).ToArray();

            int waitTime = 10;

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] != null)
                {
                    if (values[i] is bool option)
                    {
                        bool value = (bool)cg.GetHighlightedSettingValue(true);
                        if (option != value)
                        {
                            cg.KeyPress(Keys.Space);
                            Thread.Sleep(waitTime);
                        }
                    }
                    else if (values[i] is int)
                    {
                        var set = CustomGame.GetNumberKeys((int)values[i]);

                        for (int k = 0; k < set.Length; k++)
                        {
                            cg.KeyDown(set[k]);
                            Thread.Sleep(waitTime);
                        }
                        cg.KeyDown(Keys.Enter);
                        Thread.Sleep(waitTime);
                    }
                    else if (values[i] is Enum)
                    {
                        int set    = (int)values[i];
                        int length = Enum.GetNames(values[i].GetType()).Length;

                        cg.KeyPress(Keys.Space);
                        Thread.Sleep(waitTime);
                        for (int a = 0; a < length; a++)
                        {
                            cg.KeyPress(Keys.Up);
                            Thread.Sleep(waitTime);
                        }
                        for (int a = 0; a < set; a++)
                        {
                            cg.KeyPress(Keys.Down);
                            Thread.Sleep(waitTime);
                        }
                        cg.KeyPress(Keys.Space);
                        Thread.Sleep(waitTime);
                    }
                }

                cg.KeyPress(Keys.Down);
                Thread.Sleep(waitTime);
            }

            Return(cg);
        }