コード例 #1
0
ファイル: Bot.cs プロジェクト: xuejwei/LOLBot-1
        public static bool Start()
        {
            walkKeys.Add(Keys.F2);
            walkKeys.Add(Keys.F3);
            walkKeys.Add(Keys.F4);
            walkKeys.Add(Keys.F5);

            IntPtr clientIntPtr = GetClientIntPtr();
            IntPtr gameIntPtr   = User32.FindWindow("RiotWindowClass", "League of Legends (TM) Client");

            bool runing = false;

            if (gameIntPtr != IntPtr.Zero)
            {
                Window gameWindow = new Window(gameIntPtr);
                gameHandle = new GameHandle(gameWindow);

                StartLoadingGameThread();
                runing = true;
            }
            if (clientIntPtr != IntPtr.Zero)
            {
                Window clientWindow = new Window(clientIntPtr);
                clientHandle = new ClientHandle(clientWindow);

                if (!runing)
                {
                    clientHandle.SetWindowTopmost();
                    StartInTeamRoomThreadThread();
                    runing = true;
                }
            }
            return(runing);
        }
コード例 #2
0
ファイル: Bot.cs プロジェクト: xuejwei/LOLBot-1
        /// <summary>
        /// 处理加载游戏
        /// </summary>
        public static void LoadingGame()
        {
            Console.WriteLine("LoadingGame 开始");

            while (true)
            {
                if (Process.GetProcessesByName("League of Legends").ToList().Count > 0)
                {//游戏在运行
                    IntPtr gameIntPtr = User32.FindWindow("RiotWindowClass", "League of Legends (TM) Client");
                    if (gameIntPtr != IntPtr.Zero)
                    {
                        Window gameWindow = new Window(gameIntPtr);
                        gameHandle = new GameHandle(gameWindow);
                        //窗口出现,跳出循环
                        clientHandle.CancelWindowTopmost();
                        break;
                    }
                }
                else
                {     //游戏没有运行
                    if (clientHandle != null && clientHandle.Running())
                    { //客户端在运行
                        StartInTeamRoomThreadThread();
                        break;
                    }
                    else
                    {//客户端没有运行
                        //重开游戏
                        break;
                    }
                }
            }

            if (gameHandle != null)
            {
                while (true)
                {
                    Thread.Sleep(new Random().Next(5000, 8000));
                    //if (gameHandle.InLoadingGame())
                    //{//载入游戏界面
                    //    Console.WriteLine("游戏载入中...");
                    //    Thread.Sleep(10000);
                    //}
                    if (gameHandle.Playing())
                    {//进入游戏
                        StartPlayGameThread();

                        Point point = gameHandle.GetNowWalkMarkPoint();
                        if (!point.IsEmpty)
                        {
                            gameHandle.UpdateLastWalkMark(point);
                        }
                        break;
                    }
                }
            }

            Console.WriteLine("LoadingGame 结束");
        }