/// <summary> /// Swap 2 slots with eachother. /// </summary> /// <param name="slot1">Target 1</param> /// <param name="slot2">Target 2</param> /// <exception cref="InvalidSlotException">Thrown if the slot1 or slot2 argument is out of range of possible slots to move.</exception> // Swap slots public void Move(int slot1, int slot2) { if (!cg.IsSlotValid(slot1)) { throw new InvalidSlotException(string.Format("slot1 argument '{0}' is out of range.", slot1)); } if (!cg.IsSlotValid(slot2)) { throw new InvalidSlotException(string.Format("slot2 argument '{0}' is out of range.", slot2)); } cg.ResetMouse(); cg.updateScreen(); if (cg.DoesAddButtonExist()) { cg.LeftClick(661, 180, 25); } else { cg.LeftClick(717, 180, 25); } Point slot1loc = FindSlotLocation(slot1); // Get the location of the target Point slot2loc = FindSlotLocation(slot2); // Get the location of the destination cg.LeftClick(slot1loc.X, slot1loc.Y, 25); // Click the target cg.LeftClick(slot2loc.X, slot2loc.Y, 25); // Click the destination Thread.Sleep(200); ExitMoveMenu(); }
/// <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); } }