public GainExpByZhangLiangTask(TaskContext context)
     : base(context)
 {
     PathName4 = context.Settings.PathName4;
      string path = util.Read("AttackCitySetting", "AttackPath", PathName4);
      new CityService().AddCityRelation(path);
 }
示例#2
0
        private TaskResult Step2(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            bool ret=Delegater.WaitTrue(() =>
            {

                if (role.HasDialogButton("确定"))
                {
                    if (dm.FindStrE(367, 220, 927, 533, "CD", "dadada-303030", 0.9) != "-1|-1|-1")
                    {
                        role.OutSubMessage("找到cd");
                        dm.MoveToClick(730, 482); //取消
                    }
                    if (dm.FindStrE(367, 220, 927, 533, "刷新", "dadada-303030", 0.9) != "-1|-1|-1")
                    {
                        role.OutSubMessage("找到刷新");
                        dm.MoveToClick(544, 481);//确定
                    }
                }
                if (dm.FindColorE(955, 540, 1132, 660, "cc3636-202020", 1.0, 0) != "-1|-1")
                    return true;
                return false;
            }, () =>
            {
                dm.MoveToClick(1049, 636);
                dm.Delay(500);
            });

            return ret ? TaskResult.Success : Step2(arg);
        }
示例#3
0
        private TaskResult Step1(TaskContext arg)
        {
            if(role.GetMainTaskName()!="欢迎") return TaskResult.Success;

            role.FindGirlAndClick();

            return TaskResult.Success;
        }
示例#4
0
        private TaskResult Step3(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            role.CloseBoard();
            role.CloseMenu();
            return TaskResult.Finished;
        }
示例#5
0
 public BuyThingsTask(TaskContext context)
     : base(context)
 {
     Logger.Debug("1");
        _thing = context.Settings.Thing;
        _num = context.Settings.Num;
        _useLB = context.Settings.UseLB;
        Logger.Debug("2");
 }
示例#6
0
        protected override int GetStepIndex(TaskContext context)
        {
            IRole role = context.Role;

               //有是空腹 返回1
            //快捷键 无 返回2
            //防御》=20 返回3
            //返回4
            return 1;
        }
示例#7
0
        private TaskResult RunStep1(TaskContext context)
        {
            IRole role = context.Role;
            Role r = (Role)role;
            DmPlugin dm = role.Window.Dm;
            int hwnd=role.Window.Hwnd;

            if (_useLB)
            {
                if (!_thing.CanUseLB)
                    return new TaskResult(TaskResultType.Failure, "无法使用龙币购买物品“{0}”.".FormatWith(_thing.Name));
                if (r.MallLB < _thing.Value)
                    return new TaskResult(TaskResultType.Failure, "龙币不足,无法购买物品“{0}”.".FormatWith(_thing.Name));
            }
            else
            {
                if(r.MallVolume<_thing.Value)
                    return new TaskResult(TaskResultType.Failure, "点卷不足,无法购买物品“{0}”.".FormatWith(_thing.Name));
            }

            bool ret=Delegater.WaitTrue(() =>
            {
                dm.MoveToClick(567,43);
                return dm.SendString(hwnd,_thing.Name)==1?true:false;
            }, () => dm.Delay(1000), 10);
            if(ret==false)
                return new TaskResult(TaskResultType.Failure,"发送文本数据失败,无法购买物品“{0}”.".FormatWith(_thing.Name));

            ret = Delegater.WaitTrue(() =>
            {
                dm.MoveToClick(766, 43);
                return role.HasMallThing(_thing.Name) ? true : false;
            }, () =>
            {
                dm.Delay(1000);
                dm.MoveToClick(567, 43);
                dm.SendString(hwnd, _thing.Name);
            }, 5);
            if (ret == false) return new TaskResult(TaskResultType.Failure, "无法找到该商品“{0}”.".FormatWith(_thing.Name));

            if (role.FindMallButtonAndClick(_thing.Name))
            {

               Delegater.WaitTrue(() => role.HasDialogButton("取消") ,()=>dm.Delay(1000));
               if (_useLB)
                   dm.MoveToClick(939, 574);
               role.FindDialogButtonAndClick("购买");
               Delegater.WaitTrue(() => role.HasDialogButton("是"), () => dm.Delay(1000));
               role.FindDialogButtonAndClick("是");
               Delegater.WaitTrue(() => role.HasDialogButton("确认"), () => dm.Delay(1000));
               role.FindDialogButtonAndClick("确认");
            }
            _num--;
            return _num<=0? TaskResult.Success : RunStep1(context);
        }
示例#8
0
        private TaskResult Step2(TaskContext arg)
        {
            if (role.GetMainTaskName() != "民居1") return TaskResult.Success;
            role.FindGirlAndClick();
            dm.MoveToClick(1215, 154);
            dm.Delay(300);
            dm.MoveToClick(647, 162);
             dm.Delay(300);
            dm.MoveToClick(647, 162);

            role.FindGirlAndClick();

            return TaskResult.Success;
        }
示例#9
0
        private TaskResult Step1(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            bool ret=role.OpenMenu();
            if (ret)
            {
                ret=Delegater.WaitTrue(() => role.HasBoardItem("商店"), () => dm.MoveToClick(807, 680), 10);
                if(ret==true)
                    return TaskResult.Success;
            }
            return Step1(arg);
        }
        private TaskResult Step1(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;
            Delegater.WaitTrue(() => !role.HasMapOpen(), () => dm.MoveToClick(1222, 94));
            bool ret = Delegater.WaitTrue(() => role.HasBoardItem("酒馆"), () => role.ClickMenuItem("武将"), 3);
            if (ret)
            {
                var generals = new GeneralsService().Get("张梁", Quality.白色);
                ret = role.RecruitGenerals(generals);
            }

            dm.Delay(1000);
            return ret == true ? TaskResult.Success : Step1(arg);
        }
示例#11
0
        private void Buy(MallThing thing)
        {
            TaskContext context = new TaskContext(SoftContext.Role);

            /// 任务设置,可用属性为:.Thing .Num .UseLB
            context.Settings.Thing = thing;

            context.Settings.Num = Number;
            context.Settings.UseLB = this._useLB;

            TaskBase task = new BuyThingsTask(context);
            task.Name = "购买商城物品";

            SoftContext.TaskEngine.Start(task);
        }
示例#12
0
        private TaskResult Step1(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            Delegater.WaitTrue(() => !role.HasMapOpen(), () => dm.MoveToClick(1222, 94));

            var generals = new GeneralsService().Get("张梁", Quality.白色);
            var ret = role.RecruitGenerals(generals);
            if (ret == true)
            {
                role.WearEquipment("张梁");
            }
            role.CloseBoard();

            return ret==true?TaskResult.Success:Step1(arg);
        }
示例#13
0
        protected override int GetStepIndex(TaskContext context)
        {
            string name = role.GetMainTaskName();
            if (name == "欢迎") return 1;
            if (name == "民居1") return 2;
            if (name == "民居2") return 3;
            if (name == "大名") return 4;
            if (name == "虎牢关1") return 5;
            if (name == "民居1") return 1;
            if (name == "民居1") return 1;
            if (name == "民居1") return 1;
            if (name == "民居1") return 1;
            if (name == "民居1") return 1;
            if (name == "民居1") return 1;

            if (name == "")
            {
                Logger.Error("未能识别任务名");
                return -1;
            }
            return 1;
        }
示例#14
0
 /// <summary>
 /// 检查任务是否满足运行条件,如等级,物品等
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public virtual TaskResult CanRun(TaskContext context)
 {
     return TaskResult.Success;
 }
示例#15
0
 protected TaskBase(TaskContext context)
 {
     _context = context;
 }
示例#16
0
        private TaskResult Step2(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            role.CloseBoard();
            role.CloseMenu();

             var city = role.GetShortestCity();
            if (city == null)
            {
                role.OutSubMessage("未找到符合条件的城市。");
                return Step2(arg);
            }

            bool flag = false;
            while (city.Name!="洛阳")
            {
               role.OutSubMessage("最短的城市:" + city.Name);
               role.OutSubMessage("最短距离:"+city.Distance.ToString());
               //若等待中则需要重新召集武将,否则武将已经不需要召集
               var state = role.GetGeneralsState(-1);
               role.OutSubMessage("武将状态为:" + state.ToString());
               if ( state!= GeneralsState.等待中&&state!=GeneralsState.募兵中)
               {
                   flag = true;
                   break;
               }
               else
               {
                   if (state == GeneralsState.募兵中)
                   {
                       var g1 = dm.GetColorNum(17, 292, 44, 310, "66c941-202020", 1.0);
                       var g2 = dm.GetColorNum(18, 397, 42, 414, "66c941-202020", 1.0);
                       var g3 = dm.GetColorNum(18, 502, 41, 517, "66c941-202020", 1.0);
                       var g4 = dm.GetColorNum(19, 604, 42, 622, "66c941-202020", 1.0);
                       if (g1 < 50 && g2 < 50 && g3 < 50 && g4 < 50)
                          return TaskResult.Success;
                   }
               }
                //点击地图上目标城市
                role.GoToCity(city);

                //点击屏幕城池的坐标
                dm.MoveToClick(611, 436);
                dm.Delay(100);
                //召集张梁
                var ret= Delegater.WaitTrue(() =>
                {
                    dm.MoveToClick(659, 367);
                    dm.Delay(1000);
                    var s = role.GetGeneralsState(4);
                    Debug.WriteLine(s);
                    if (s == GeneralsState.赶路中 || s == GeneralsState.国战中||s==GeneralsState.冲锋中||s==GeneralsState.单挑中)
                        return true;
                    return false;

                }, () =>dm.Delay(200), 1);

                if (!ret)
                {
                    role.OutSubMessage("召集失败,选择上一城市重新召集.");
                    city = city.PrevCity;
                    if (city == null)
                        break;
                }
                else
                {
                    role.OutSubMessage("召集成功");
                    flag = true;
                    break;
                }
            }
            //召集失败则重新执行步骤2
            if (!flag)
                return Step2(arg);

            int count = 0;
            DateTime beginTime=DateTime.Now;
            int last = 0;
            Delegater.WaitTrue(() =>
            {
                var state = role.GetGeneralsState(2);
               // Debug.WriteLine(state.ToString());
                if (state == GeneralsState.牢狱中)
                {
                    count = 0;
                    //dm.MoveToClick(64, 568);
                    role.FindLYAndClick();
                    dm.Delay(35000);
                    return true;
                }

                if (state == GeneralsState.未知状态)
                {
                    count++;
                    if (count > 10)
                    {
                        role.OutSubMessage("未知状态超过10次,重新执行");
                        return true;
                    }
                }
                if (state == GeneralsState.国战中||state==GeneralsState.冲锋中)
                {
                    count = 0;
                    var second =(int) DateTime.Now.Subtract(beginTime).TotalSeconds;
                    if (second/50 >last)
                    {
                        last = second/50;
                        Debug.WriteLine("国战时间超过50秒执行单挑.经过时间:"+second);
                        role.CheckBattle("单挑");
                    }
                    //dm.MoveToClick(84, 346);
                    //dm.MoveToClick(1205, 198); //单挑
                    //dm.MoveToClick(1209, 300);//突进
                    //dm.MoveToClick(1222, 52);//返回
                    //检测是否上阵
                }
                if (state == GeneralsState.单挑中)
                {
                    count = 0;
                }
                if (state == GeneralsState.募兵中)
                {
                    count = 0;
                    dm.Delay(500);
                    if (role.GetGeneralsState(2) == GeneralsState.募兵中)
                    {
                        var g1 = dm.GetColorNum(17, 292, 44, 310, "66c941-202020", 1.0);
                        var g2 = dm.GetColorNum(18, 397, 42, 414, "66c941-202020", 1.0);
                        var g3 = dm.GetColorNum(18, 502, 41, 517, "66c941-202020", 1.0);
                        var g4 = dm.GetColorNum(19, 604, 42, 622, "66c941-202020", 1.0);
                        if (g1 > 50 || g2 > 50 || g3 > 50 || g4 > 50)
                        {
                            Debug.WriteLine("武将兵力未用完,重新选择城市进攻");
                            if (Step2(arg) == TaskResult.Success)
                                return true;
                        }
                        if (g1 < 50 && g2 < 50 && g3 < 50 && g4 < 50)
                            return true;
                    }
                }
                if (state == GeneralsState.等待中)
                {
                    if(Step2(arg)==TaskResult.Success)
                    return true;
                }
                return false;
            }, () =>dm.Delay(2000));
            //Debug.WriteLine(count.ToString());
            return count>10?Step2(arg):TaskResult.Success  ;
        }
示例#17
0
 protected override int GetStepIndex(TaskContext context)
 {
     return 1;
 }
示例#18
0
 public AutoLevel1To70(TaskContext context)
     : base(context)
 {
     role = (Role)context.Role;
     dm = role.Window.Dm;
 }
示例#19
0
        private TaskResult Step3(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;
            role.CloseBoard();

            //var s = role.GetGeneralsState(4);
            //Debug.WriteLine(s);
            //if (s!=GeneralsState.募兵中)
            //    return Step2(arg);

            bool ret = Delegater.WaitTrue(()=>role.HasBoardItem("酒馆"),() =>role.ClickMenuItem("武将"), 3);
            if (ret)
            {
                ret = role.FireGenerals("张梁",4);
                Debug.WriteLine(ret?"解雇成功":"解雇失败");
                if (ret == false)
                {
                    var state = role.GetGeneralsState(-1);
                    role.OutSubMessage("武将状态为:" + state.ToString());
                    if (state == GeneralsState.国战中)
                    {
                        Delegater.WaitTrue(() =>role.GetGeneralsState(2)==GeneralsState.募兵中,() => dm.Delay(2000),60);
                    }
                    if (state == GeneralsState.牢狱中)
                    {
                        role.FindLYAndClick();
                        dm.Delay(35000);
                    }

                }
            }
               // role.CloseBoard();
            return ret == true ? TaskResult.Finished : Step3(arg);
        }
示例#20
0
        private void BtnBeginClick(object sender, RoutedEventArgs e)
        {
            int hWnd = dm.FindWindow("Qt5QWindowIcon", "海马玩模拟器(Droid4X) 0.9.0 Beta");//不通过标题判断可换成NULL
            hWnd = dm.GetHwnd(dm.EnumWindow(hWnd, "screenWindow", "Qt5QWindowIcon", 1 + 2));
            Debug.WriteLine("找到的句柄:" + hWnd);
            if (hWnd < 0)
            {
                MessageBox.Show("未找到模拟器窗口!");
                return;
            }
            var foobar1 = dm.CreateFoobarRoundRect(hWnd, 900, 0, 500, 40, 10, 10);
            dm.FoobarSetFont(foobar1, "宋体", 12, 0);
            dm.FoobarTextRect(foobar1, 20, 0, 550, 40);
            dm.FoobarPrintText(foobar1, "11111","000000");
            dm.FoobarUpdate(foobar1);

            int ret = dm.BindWindowEx(hWnd, "dx.graphic.opengl", "windows", "dx", "", 0);
            if (ret != 1)
            {
                MessageBox.Show("绑定失败!错误码:" + dm.GetLastError() + "," + dm.GetLastMessage());
                return;
            }
            //int intX, intY;
            //var ret1 = dm.FindMultiColor(0, 0, 2000, 2000, "a79371","-10|14|cbc9af,-2|25|c4c0a6,9|24|cbc9b0,-16|56|ccac81,16|56|bb9a79", 0.9, 0, out intX, out intY);
               // var ret1 = dm.FindMultiColor(0, 0, 2000, 2000, "a79c82","22|5|8d3433,9|38|3b3c36,5|54|7d2f2f,50|33|773233,35|51|a09190", 0.9, 0, out intX, out intY);
            //if (intX > 0)
            //{
            //    MessageBox.Show("找到坐标:"+intX+" "+intY);
            //    dm.MoveToClick(intX, intY);
            //}
            //Debug.WriteLine(ret1);

            IRole role = new Role(hWnd, dm);
            Role r = (Role)role;

            // int yy = 0;
            TaskContext context = new TaskContext(role);
            context.Settings.IsChecked1 = this.acsSetting.cbG1.IsChecked;
            context.Settings.IsChecked2 = this.acsSetting.cbG2.IsChecked;
            context.Settings.IsChecked3 = this.acsSetting.cbG3.IsChecked;
            context.Settings.IsChecked4 = this.acsSetting.cbG4.IsChecked;
            context.Settings.PathName4 = this.acsSetting.cbbP4.SelectedValue.ToString();
              //  var task = new GainExpByZhangLiangTask(context);
            // var task = new AutoFightingByZhangLiangTask(context);
            // AutoFightingByZhangLiangTask.DstCityName = this.TbDstCityName.Text;
            //var task=new RefreshEquipmentTask(context);
            var task = new AutoLevel1To70(context);
            task.Time = 1;

            engine.Start(task);
        }
示例#21
0
 public RefreshEquipmentTask(TaskContext context)
     : base(context)
 {
 }
示例#22
0
 protected abstract int GetStepIndex(TaskContext context);
 public AutoFightingByZhangLiangTask(TaskContext context)
     : base(context)
 {
 }
示例#24
0
        private TaskResult Step5(TaskContext arg)
        {
            if (role.GetMainTaskName() != "虎牢关1") return TaskResult.Success;

            role.FindGirlAndClick();

            role.GoToInterface("副本");
            role.GoToArea("虎牢关");
            dm.MoveToClick(266, 188);
            dm.Delay(500);
            dm.MoveToClick(989, 148);
            dm.Delay(500);
            role.ControlFight();
            return TaskResult.Success;
        }
示例#25
0
 private TaskResult run1(TaskContext arg)
 {
     Console.WriteLine("我是任务“{0}”,我正在执行第一步骤。".FormatWith(name1));
     return TaskResult.Finished;
 }
示例#26
0
 public ZidongjianzhuTask(TaskContext context)
     : base(context)
 {
 }
示例#27
0
 public NoOpTask(TaskContext context)
     : base(context)
 {
 }
示例#28
0
 public TaskEventArg(TaskContext context)
 {
     this.Context=context;
 }
        private TaskResult Step2(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;
            role.CloseBoard();
            role.CloseMenu();

            City city=new CityService().GetAll().FirstOrDefault(x => x.Name == DstCityName);
            if(city==null)
                return new TaskResult(TaskResultType.Failure, "目标城市不存在");

            Delegater.WaitTrue(() => role.HasMapOpen(), () => dm.MoveToClick(1222, 94));

            var b=role.GetCityBelong(city.X,city.Y);
            if(b==BelongTo.魏国城池||b==BelongTo.无法识别)
                return new TaskResult(TaskResultType.Failure, "城池不属于敌方或无法识别");

            //点击地图上的城池坐标
            if (city.X == 0 || city.Y == 0)
                return new TaskResult(TaskResultType.Failure, "城市坐标没有更新");
            dm.MoveToClick(city.X, city.Y);
            dm.Delay(100);
            //关闭地图
            Delegater.WaitTrue(() => !role.HasMapOpen(), () => dm.MoveToClick(1222, 94));

            //点击屏幕城池的坐标
            bool ret = Delegater.WaitTrue(() => dm.MoveToClick(611, 436)==1, () => dm.Delay(100), 2);
            if (!ret)
            {
                role.OutSubMessage("点击城市{0}失败".FormatWith(city.Name));
                return new TaskResult(TaskResultType.Failure, "城市名称无法识别");
            }
            dm.Delay(100);

            //召集张梁
              //  ret = role.ConveneGenerals("张梁");
            Delegater.WaitTrue(() => role.HasPicExist(541, 305, 884, 540, "血战.bmp"), () => dm.Delay(1000), 3);
            dm.MoveToClick(764, 431);
            Delegater.WaitTrue(() => role.HasStrExist(470, 202, 755, 347, "血战", "dadada-303030"), () => dm.Delay(1000), 3);

            int intX, intY;
            dm.FindPic(367, 294, 919, 492, "张梁血战.bmp", "000000", 0.9, 0, out intX, out intY);
            if (intX < 0 && intY < 0)
            {
                return new TaskResult(TaskResultType.Failure, "无法找到张梁图片");
            }

            if(Math.Abs(intX-441)>20)
                dm.MoveToClick(441, 363);
            if (Math.Abs(intX - 552) > 20)
                dm.MoveToClick(552, 363);
            if (Math.Abs(intX - 666) > 20)
                dm.MoveToClick(666, 363);
            if (Math.Abs(intX - 779) > 20)
                dm.MoveToClick(779, 363);

            dm.MoveToClick(636, 579);
            dm.Delay(1000);
            dm.MoveToClick(746, 574);
            dm.Delay(1000);
            dm.MoveToClick(60, 284);
            return TaskResult.Success;
        }
        private TaskResult Step3(TaskContext arg)
        {
            Role role = (Role)arg.Role;
            DmPlugin dm = role.Window.Dm;

            if (role.HasPicExist(389, 193, 918, 354, "结束.bmp"))
            {
                dm.Delay(2000);
                dm.MoveToClick(523,579);
               // role.CloseDialogBoard();
                return TaskResult.Finished;
            }

            Delegater.WaitTrue(() =>
            {
                var state = role.GetGeneralsState(4);
               // Debug.WriteLine(state);
                return state== GeneralsState.募兵中;
            }, () => dm.Delay(1000));

            bool ret = Delegater.WaitTrue(() => role.HasBoardItem("酒馆"), () => role.ClickMenuItem("武将"), 3);
            if (ret)
            {
                ret = role.FireGenerals("张梁", 4);
            }
            Step1(arg);

            return Step3(arg);
        }
示例#31
0
 public TaskEventArg(TaskContext context)
 {
     this.Context = context;
 }