示例#1
0
        /// <summary>
        /// 运行程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Run_Click(object sender, RoutedEventArgs e)
        {
            Corrd corrd = new Corrd();

            try
            {
                corrd.Times    = Convert.ToInt32(failTimes.Text);
                corrd.StopTime = DateTime.Now + TimeSpan.FromHours(Convert.ToDouble(stopTime.Text));
                corrd.WaitTime = Convert.ToInt32(checkTime.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("参数填写错误!");
                return;
            }
            if (TaskMode == TaskMode.None)
            {
                Write("没有选择任务运行的模式!");
                return;
            }
            else if (TaskMode == TaskMode.DGL)
            {
                InitVriual();
                Write("选择了带狗粮,准备开始进入带狗粮模式!");
                runningTask       = RunDGLScript(corrd);
                runTask.IsEnabled = false;
                runningTask.ContinueWith(t =>
                {
                    Write("带狗粮任务结束, 返回结果" + t.Result.ToString());
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        EndInitVriual();
                    }));
                });
            }
            else if (TaskMode == TaskMode.DXC)
            {
                InitVriual();
                Write("选择了地下城,准备开始进入地下城模式!");
                runningTask       = RunDungeonsScript(corrd);
                runTask.IsEnabled = false;
                runningTask.ContinueWith(t =>
                {
                    Write("地下城任务结束, 返回结果" + t.Result.ToString());
                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        EndInitVriual();
                    }));
                });
            }
        }
示例#2
0
        /// <summary>
        /// 运行刷地下城的任务
        /// </summary>
        /// <param name="corrd"></param>
        /// <returns></returns>
        public Task <bool> RunDungeonsScript(Corrd corrd)
        {
            Task <bool> run = Task <bool> .Factory.StartNew(() => {
                try
                {
                    Write("准备开始任务5s倒计时!");
                    Thread.Sleep(5000);
                    Write("脚本截止条件:" + "运行次数 : " + corrd.Times.ToString() + ", 或者 运行到 : " + corrd.StopTime.ToString());
                    while (corrd.Times-- >= 0 && DateTime.Now < corrd.StopTime && !isStopTask)
                    {
                        Write("检测是否处于开始界面!");
                        if (matchtempforsharp(TempImages.StartTemp))
                        {
                            Write("检测到游戏开始界面, 准备游戏!");
                        }
                        else
                        {
                            Write("未检测到游戏开始界面,是否没有调整好界面!脚本退出!");
                            return(false);
                        }
                        keyoption(OptionKeys.StartKey);
                        Thread.Sleep(1500);
                        if (matchtempforsharp(TempImages.BarTemp))
                        {
                            Write("检测到进度条, 游戏开始!");
                        }
                        else
                        {
                            Write("未检测到进度条!");
                        }
                        Thread.Sleep(corrd.WaitTime);
                        ResultType resultType = isGameover();
                        Thread.Sleep(Random.Next(2000, 10000));
                        if (resultType == ResultType.Vector)
                        {
                            Write("开启宝箱!");
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.WhiteKey);
                            ///检测战利品
                            bool issail = checkSpoils();
                            if (matchtempforsharp(TempImages.GetTemp))
                            {
                                if (!issail)
                                {
                                    keyoption(OptionKeys.SureKey);
                                    Write("不出售!");
                                }
                                else
                                {
                                    keyoption(OptionKeys.SailFWKey);
                                    keyoption(OptionKeys.SailFWTwo);
                                    Write("出售!");
                                }
                            }
                            else
                            {
                                keyoption(OptionKeys.GetKey);
                            }
                            keyoption(OptionKeys.LoopKey);
                        }
                        else if (resultType == ResultType.Fail)
                        {
                            Write("游戏失败一次!");
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.GameFailReturnKey);
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.WhiteKey);
                            keyoption(OptionKeys.LoopKey);
                        }
                        Thread.Sleep(1000);
                        if (matchtempforsharp(TempImages.EnergyNotEnoughTemp))
                        {
                            Write("体力不足,退出脚本!");
                            return(true);
                        }
                        Thread.Sleep(2000);
                    }
                    Write("脚本正常次数运行完成!");
                    return(true);
                }
                catch (Exception ex)
                {
                    Write(ex.ToString());
                    return(false);
                }
            }, taskCancle.Token);

            return(run);
        }
示例#3
0
        /// <summary>
        /// 运行带狗粮任务
        /// </summary>
        /// <param name="corrd"></param>
        /// <returns></returns>
        public Task <bool> RunDGLScript(Corrd corrd)
        {
            Task <bool> run = Task <bool> .Factory.StartNew(() => {
                try
                {
                    bool[] ismax = new bool[3];
                    Write("准备开始任务5s倒计时!");
                    Thread.Sleep(5000);
                    Write("脚本截止条件:" + "运行次数 : " + corrd.Times.ToString() + ", 或者 运行到 : " + corrd.StopTime.ToString());
                    while (corrd.Times-- >= 0 && DateTime.Now < corrd.StopTime && !isStopTask)
                    {
                        Write("检测是否处于开始界面!");
                        if (matchtempforsharp(TempImages.StartTemp))
                        {
                            Write("检测到游戏开始界面, 准备游戏!");
                        }
                        else
                        {
                            Write("未检测到游戏开始界面,是否没有调整好界面!脚本退出!");
                            return(false);
                        }
                        ///切换满级的狗粮
                        changeGLS(ismax);
                        ///开始游戏
                        keyoption(OptionKeys.StartKey);
                        Thread.Sleep(1500);
                        if (matchtempforsharp(TempImages.BarTemp))
                        {
                            Write("检测到进度条, 游戏开始!");
                        }
                        else
                        {
                            Write("未检测到进度条!");
                        }
                        Thread.Sleep(corrd.WaitTime);
                        ResultType resultType = isGameover();
                        Thread.Sleep(Random.Next(2000, 10000));
                        ///检测狗粮是否满级
                        checkAndChangeGlMaxLevel(ismax);

                        backGameStartFace(resultType);
                        Thread.Sleep(1000);
                        if (matchtempforsharp(TempImages.EnergyNotEnoughTemp))
                        {
                            Write("体力不足,退出脚本!");
                            return(true);
                        }
                        Thread.Sleep(2000);
                    }
                    Write("脚本正常次数运行完成!");
                    return(true);
                }
                catch (Exception ex)
                {
                    Write(ex.ToString());
                    return(false);
                }
            }, taskCancle.Token);

            return(run);
        }