예제 #1
0
    private List <Tuple <AIHero, Difficulty> > InitBots()
    {
        List <Tuple <AIHero, Difficulty> > bots = new List <Tuple <AIHero, Difficulty> >();

        try
        {
            var botsNode = (YamlSequenceNode)_mapping.Children[new YamlScalarNode("Bots")];
            foreach (YamlMappingNode bot in botsNode)
            {
                string heroString = (string)bot.Children[new YamlScalarNode("Hero")];
                AIHero hero       = StringToHero(heroString);

                string     difficultyString = (string)bot.Children[new YamlScalarNode("Difficulty")];
                Difficulty difficulty       = StringToDifficulty(difficultyString);

                Tuple <AIHero, Difficulty> botTuple = new Tuple <AIHero, Difficulty>(hero, difficulty);
                bots.Add(botTuple);
            }
        }
        catch (KeyNotFoundException)
        {
            Console.WriteLine("No valid bot config found. No bots will be added. See example bot config in cfg.yaml.");
        }


        return(bots);
    }
예제 #2
0
파일: Map.cs 프로젝트: mendiromania/Legends
        public Vector2 GetSpawnPosition(AIHero player)
        {
            int teamSize  = player.Team.Size;
            int teamIndex = player.TeamNo - 1;

            return(player.Team.Id == TeamId.BLUE ? BlueSpawns[teamSize][teamIndex] : PurpleSpawns[teamSize][teamIndex]);
        }
예제 #3
0
 public Champion(AIHero player)
 {
     this.Player = player;
 }
예제 #4
0
            bool EditAI(int slot, object setToHero, object setToDifficulty, bool x)
            {
                // Make sure there is a player or AI in selected slot, or if they are a valid slot to select in queue.
                if (cg.PlayerSlots.Contains(slot) || (slot >= Queueid && slot - (Queueid) < cg.QueueCount))
                {
                    // Click the slot of the selected slot.
                    var slotlocation = cg.Interact.FindSlotLocation(slot);
                    cg.LeftClick(slotlocation.X, slotlocation.Y);
                    // Check if Edit AI window has opened by checking if the confirm button exists.
                    cg.updateScreen();
                    if (cg.CompareColor(447, 354, CALData.ConfirmColor, 20))
                    {
                        var sim = new List <Keys>();
                        // Set hero if setToHero does not equal null.
                        if (setToHero != null)
                        {
                            AIHero selectHero = (AIHero)setToHero;
                            // Open hero menu
                            sim.Add(Keys.Space);
                            // <image url="$(ProjectDir)\ImageComments\AI.cs\EditAIHero.png" scale="0.5" />
                            // Select the topmost hero option
                            for (int i = 0; i < Enum.GetNames(typeof(AIHero)).Length; i++)
                            {
                                sim.Add(Keys.Up);
                            }
                            // Select the hero in selectHero.
                            for (int i = 0; i < (int)selectHero; i++)
                            {
                                sim.Add(Keys.Down);
                            }
                            sim.Add(Keys.Space);
                            sim.Add(Keys.Down);
                        }
                        sim.Add(Keys.Down); // Select difficulty option
                        // Set difficulty if setToDifficulty does not equal null.
                        if (setToDifficulty != null)
                        {
                            Difficulty selectDifficulty = (Difficulty)setToDifficulty;
                            // Open difficulty menu
                            sim.Add(Keys.Space);
                            // <image url="$(ProjectDir)\ImageComments\AI.cs\EditAIDifficulty.png" scale="0.6" />
                            // Select the topmost difficulty
                            for (int i = 0; i < Enum.GetNames(typeof(Difficulty)).Length; i++)
                            {
                                sim.Add(Keys.Up);
                            }
                            // Select the difficulty in selectDifficulty.
                            for (int i = 0; i < (int)selectDifficulty; i++)
                            {
                                sim.Add(Keys.Down);
                            }
                            sim.Add(Keys.Space);
                        }
                        // Confirm the changes
                        sim.Add(Keys.Return);

                        // Send the keypresses.
                        cg.KeyPress(sim.ToArray());

                        cg.ResetMouse();
                        return(true);
                    }
                    else
                    {
                        cg.ResetMouse();
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
예제 #5
0
 /// <summary>
 /// Edits the hero an AI is playing.
 /// </summary>
 /// <param name="slot">Slot to edit.</param>
 /// <param name="setToHero">Hero to change to.</param>
 /// <returns>Returns true on success.</returns>
 public bool EditAI(int slot, AIHero setToHero)
 {
     return(EditAI(slot, setToHero, null, true));
 }
예제 #6
0
 /// <summary>
 /// Edits the hero an AI is playing and the difficulty of the AI.
 /// </summary>
 /// <param name="slot">Slot to edit.</param>
 /// <param name="setToHero">Hero to change to.</param>
 /// <param name="setToDifficulty">Difficulty to change to.</param>
 /// <returns>Returns true on success.</returns>
 public bool EditAI(int slot, AIHero setToHero, Difficulty setToDifficulty)
 {
     return(EditAI(slot, setToHero, setToDifficulty, true));
 }
예제 #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>
 /// Edits the hero an AI is playing and the difficulty of the AI.
 /// </summary>
 /// <param name="slot">Slot to edit.</param>
 /// <param name="setToHero">Hero to change to.</param>
 /// <param name="setToDifficulty">Difficulty to change to.</param>
 /// <returns>Returns true on success.</returns>
 /// <include file='docs.xml' path='doc/exceptions/invalidslot/exception'/>
 public bool EditAI(int slot, AIHero setToHero, Difficulty setToDifficulty)
 {
     return(EditAI(slot, (AIHero?)setToHero, (Difficulty?)setToDifficulty));
 }
        /// <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. Can be red, blue, or both.</param>
        /// <param name="count">Amount of AI that is added. Set to -1 for max. Default is -1</param>
        /// <returns>Returns false if no AI can be added.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="count"/> is less than -1 or <paramref name="team"/> is Spectator or Queue.</exception>
        /// <include file='docs.xml' path='doc/AddAI/example'></include>
        public bool AddAI(AIHero hero, Difficulty difficulty, Team team, int count = -1)
        {
            using (cg.LockHandler.Interactive)
            {
                if (team.HasFlag(Team.Queue) || team.HasFlag(Team.Spectator))
                {
                    throw new ArgumentOutOfRangeException(nameof(team), team, "Team cannot be Spectator or Queue.");
                }

                if (count < -1)
                {
                    throw new ArgumentOutOfRangeException(nameof(count), count, "AI count must be at least -1.");
                }

                cg.UpdateScreen();

                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
                 */
                {
                    if (cg.OpenChatIsDefault)
                    {
                        cg.Chat.CloseChat();
                    }

                    // Open AddAI menu.
                    cg.MoveMouseTo(Points.LOBBY_ADD_AI);
                    cg.WaitForUpdate(Points.LOBBY_ADD_AI, 20, 2000);
                    cg.LeftClick(Points.LOBBY_ADD_AI, 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);

                    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);

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

                    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();

                    Thread.Sleep(50);

                    if (cg.OpenChatIsDefault)
                    {
                        cg.Chat.OpenChat();
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #10
0
 public Dummy(AIHero player) : base(player)
 {
 }
예제 #11
0
 public void DefinePlayer(AIHero hero)
 {
     this.Hero = hero;
 }