コード例 #1
0
ファイル: ClientHandle.cs プロジェクト: xuejwei/LOLBot-1
        /// <summary>
        /// 随机选择一个英雄
        /// </summary>
        /// <returns>选择成功</returns>
        public bool RandomlyChooseChampion()
        {
            Bitmap ChampionHeadshotFrame    = Properties.Resources.ChampionHeadshotFrame;
            Bitmap BanChampionHeadshotFrame = Properties.Resources.BanChampionHeadshotFrame;

            ParserImageInWindow parser    = new ParserImageInWindow(ChampionHeadshotFrame, base.window, new Rectangle(340, 130, 610, 470));
            ParserImageInWindow banParser = new ParserImageInWindow(BanChampionHeadshotFrame, base.window, new Rectangle(340, 130, 610, 470));

            int count    = parser.FindInWindow(Color.White, 30);
            int banCount = banParser.FindInWindow(Color.White, 30);

            parser.Dispose();
            banParser.Dispose();

            if (count + banCount > 0)
            {
                Target[] targets;
                if (banCount > 0)
                {
                    targets = banParser.GetTargets();
                }
                else
                {
                    targets = parser.GetTargets();
                }
                //先选择禁用英雄
                Point clickPoint = targets[new Random().Next(0, targets.Length - 1)].Centre;

                base.Click(clickPoint);

                return(true);
            }
            else
            {
                return(false);
            }
        }