Exemple #1
0
 /// <summary>
 /// Pauses the game.
 /// </summary>
 public void Pause()
 {
     cg.updateScreen();
     // Check if the pause text is there. If not, toggle pause.
     if (cg.CompareColor(441, 268, new int[] { 187, 138, 79 }, 10) == false)
     {
         TogglePause();
     }
 }
Exemple #2
0
            internal Point FindSlotLocation(int slot)
            {
                cg.updateScreen();
                int offset     = 0;
                int xoffset    = 0;
                int queuecount = cg.QueueCount;

                if (slot > 11 && slot <= Queueid)
                {
                    offset = cg.FindOffset();                               // If there is players in the queue, the spectator slots move down. Find the offset in pixels to spectator.
                }
                if (slot - Queueid >= queuecount)
                {
                    return(new Point());                              // If there is no one in the queue and the slot selected is a queue value, return invalid
                }
                if (slot > 11)
                {
                    xoffset = -100;            // If there is more than 6 players in the queue, a scrollbar appears offsetting the slot's x location by a few pixels.
                }
                if (slot > Queueid)
                {
                    slot = slot - 6;                 // selecting a person in the queue where spectator slots are normally at. Not 17 because that is set when returning 891, 24
                }
                if (slot != Queueid)
                {
                    return(new Point(playerLoc[slot, 0] + xoffset, playerLoc[slot, 1] + offset));                 // Blue, Red, Spectators, and all of queue except for the first slot.
                }
                else
                {
                    return(new Point(playerLoc[12, 0] + xoffset, 248)); // Queue 1 location
                }
            }
            /// <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);
            }
Exemple #4
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();
 }
Exemple #5
0
            /// <summary>
            /// Gets a list of players who died.
            /// </summary>
            /// <param name="noUpdate"></param>
            /// <returns>List of players who are dead.</returns>
            public List <int> PlayersDead(bool noUpdate = false)
            {
                // Returns which players that are dead by checking the killed marker locations for a red 'X'.
                // <image url="$(ProjectDir)\ImageComments\GetInfo.cs\DeadPlayers.png" scale="1.3" />

                if (!noUpdate)
                {
                    cg.updateScreen();
                }
                List <int> playersDead = new List <int>();

                for (int i = 0; i < 12; i++)
                {
                    if (cg.CompareColor(KilledPlayerMarkerLocations[i], 98, CALData.DeadPlayerColor, CALData.DeadPlayerFade) &&
                        !HasHealthBar(i, true))
                    {
                        playersDead.Add(i);
                    }
                }
                return(playersDead);
            }
Exemple #6
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);
            }
 /// <summary>
 /// Determines if the game is paused.
 /// </summary>
 public bool IsPaused()
 {
     cg.updateScreen();
     // Check if the pause text is there.
     return(cg.CompareColor(441, 268, new int[] { 187, 138, 79 }, 10));
 }