Esempio n. 1
0
        private TaskResult RunStep7(TaskContext arg)
        {
            Role role = (Role)Role;

            Dm.UseDict(0);
            Delegater.WaitTrue(() => role.OpenMenu("资源"), () => role.IsExistWindowMenu("集市"), () => Dm.Delay(1000));
            Delegater.WaitTrue(() => role.OpenWindowMenu("集市"),
                               () => Dm.Delay(1000));

            Dm.UseDict(1);
            Dm.Delay(1000);
            Delegater.WaitTrue(() =>
            {
                bool result = Dm.IsChangeColorNumEx(170, 72, 237, 107, "49A031-152F0F", () =>
                {
                    Dm.StartWatch();
                    var rt1 = GetResourceType(160, 129, 346, 377);
                    var rc1 = GetColor(176, 119, 328, 178);
                    Dm.DebugPrint("第一个资源:" + rt1.ToString() + ",颜色:" + rc1.ToString());

                    var rt2 = GetResourceType(395, 132, 573, 373);
                    var rc2 = GetColor(409, 129, 566, 175);
                    Dm.DebugPrint("第二个资源:" + rt2.ToString() + ",颜色:" + rc2.ToString());

                    var rt3 = GetResourceType(630, 131, 810, 377);
                    var rc3 = GetColor(633, 124, 804, 180);
                    Dm.DebugPrint("第三个资源:" + rt3.ToString() + ",颜色:" + rc3.ToString());
                    Dm.StopWatch();
                    Dm.StartWatch();
                    List <Resource> list = new List <Resource>()
                    {
                        new Resource()
                        {
                            Pos = 1, Type = rt1, Color = rc1, Buypos = new Tuple <int, int>(253, 353)
                        },
                        new Resource()
                        {
                            Pos = 2, Type = rt2, Color = rc2, Buypos = new Tuple <int, int>(495, 353)
                        },
                        new Resource()
                        {
                            Pos = 3, Type = rt3, Color = rc3, Buypos = new Tuple <int, int>(727, 353)
                        }
                    };
                    var rlist = list.OrderByDescending(q => q.Type).ThenByDescending(x => x.Color).ToList();
                    Dm.DebugPrint(string.Format("购买位置:{0},资源类型:{1},资源颜色:{2}", rlist.First().Pos, rlist.First().Type.ToString(), rlist.First().Color.ToString()));
                    Dm.MoveToClick(rlist.First().Buypos.Item1, rlist.First().Buypos.Item2);
                    Dm.StopWatch();
                    Dm.Delay(1000);
                });
                if (!result)
                {
                    Dm.DebugPrint("操作完颜色结果不变,可能已经完成!~");
                    if (Dm.IsExistPic(171, 71, 247, 105, @"\bmp\集市0.bmp"))
                    {
                        return(true);
                    }
                }
                if (Dm.FindPicAndClick(475, 315, 628, 415, @"\bmp\取消.bmp"))
                {
                    Dm.Delay(1000);
                }
                return(false);
            }, () => Dm.Delay(50), 40);
            Dm.UseDict(0);
            role.CloseWindow();
            return(TaskResult.Success);
        }