コード例 #1
0
        private TaskResult RunStep4(TaskContext context)
        {
            Role role = (Role)context.Role;

            Delegater.WaitTrue(() => Dm.FindPicAndClick(856, 448, 958, 536, @"\bmp\菜单未打开.bmp"),
                               () => Dm.IsExistPic(856, 448, 958, 536, @"\bmp\菜单打开.bmp"), () => Dm.Delay(1000));
            Delegater.WaitTrue(() => role.OpenMenu("装备"),
                               () => role.OpenWindowMenu("商店"), () => Dm.Delay(1000));
            Delegater.WaitTrue(() =>
            {
                Dm.FindStrAndClick(718, 448, 857, 502, "刷新", "86.17.70-5.5.25");
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\金币秒CD.bmp"))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店取消.bmp");
                    return(true);
                }
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\适合您的装备.bmp"))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店确定.bmp");
                }
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\稀有物品.bmp"))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店确定.bmp");
                }
                return(Dm.IsExistStr(718, 448, 857, 502, "清除", "86.17.70-5.5.25"));
            }, () => Dm.Delay(500));
            role.CloseWindow();
            return(TaskResult.Finished);
        }
コード例 #2
0
        private TaskResult RunStep6(TaskContext arg)
        {
            Role role = (Role)Role;

            taozhuangList.Clear();
            role.CloseWindow();
            #region 数字识别等级
            //Dm.UseDict(1);
            // int level = Dm.GetOcrNumber(101, 31, 159, 59, "40.30.88-20.30.30");
            //  Dm.UseDict(0);
            int level = role.Level;
            Dm.DebugPrint("人物等级:" + level);
            if (level >= 16 && level < 28) //蓝
            {
                MaxColor = Color.蓝;
            }
            else if (level >= 28 && level < 36) //绿
            {
                MaxColor = Color.绿;
            }
            else if (level >= 36 && level < 53)//黄
            {
                MaxColor = Color.黄;
            }
            else if (level >= 53 && level < 70)//红
            {
                MaxColor = Color.红;
            }
            else if (level >= 70)//紫
            {
                MaxColor = Color.紫;
            }
            else
            {
                Dm.DebugPrint("人物等级无法识别!" + level);
                MaxColor = Color.无法识别;
                role.CloseWindow();
                return(TaskResult.Finished);
            }
            #endregion
            for (int i = 0; i < 6; i++)
            {
                needs[i] = 0;
            }
            int count = 0;
            //获取所需装备件数
            if (MaxColor == Color.紫)
            {
                Delegater.WaitTrue(() => role.OpenMenu("武将"), () => role.IsExistWindowMenu("将领"), () => Dm.Delay(1000));
                Delegater.WaitTrue(() => role.OpenWindowMenu("将领"),
                                   () => Dm.Delay(1000));
                GetSelectedGeneralEquipment(86, 68, 177, 149, 152, 107);
                GetSelectedGeneralEquipment(86, 156, 173, 241, 154, 194);
                GetSelectedGeneralEquipment(84, 244, 176, 326, 153, 286);
                GetSelectedGeneralEquipment(83, 332, 174, 417, 153, 375);

                GetSelectedGeneralEquipment(86, 68, 177, 149, 152, 107);
                GetSelectedGeneralEquipment(86, 156, 173, 241, 154, 194);
                GetSelectedGeneralEquipment(84, 244, 176, 326, 153, 286);
                GetSelectedGeneralEquipment(83, 332, 174, 417, 153, 375);
                Dm.DebugPrint("需要装备:" + needs[0] + " " + needs[1] + " " + needs[2] + " " + needs[3] + " " + needs[4] + " " + needs[5]);
                string temp = "";

                foreach (var item in taozhuangList)
                {
                    temp = temp + item + " ";
                    if (item.Contains("极"))
                    {
                        role.CloseWindow();
                        return(TaskResult.Finished);
                    }
                    if (item.Contains("真"))
                    {
                        count = count + 2;
                        continue;
                    }
                    if (item.Contains("套装"))
                    {
                        count = count + 1;
                    }
                }
                if (count >= 10)
                {
                    role.CloseWindow();
                    return(TaskResult.Finished);
                }
                Debug.WriteLine("已经拥有套装:" + temp);
                role.CloseWindow();
            }
            Delegater.WaitTrue(() => role.OpenMenu("装备"), () => role.IsExistWindowMenu("商店"), () => Dm.Delay(1000));
            Delegater.WaitTrue(() => role.OpenWindowMenu("商店"),
                               () => Dm.Delay(1000));

            Dictionary <int, int[]> dict = new Dictionary <int, int[]>();
            dict.Add(1, new int[] { 115, 134, 217, 174, 104, 272, 212, 312, 165, 369, 0, 0 });
            dict.Add(2, new int[] { 235, 135, 350, 173, 233, 271, 344, 311, 296, 369, 0, 0 });
            dict.Add(3, new int[] { 365, 135, 475, 174, 361, 273, 464, 313, 418, 369, 0, 0 });
            dict.Add(4, new int[] { 488, 133, 604, 176, 486, 276, 581, 311, 551, 374, 0, 0 });
            dict.Add(5, new int[] { 614, 131, 732, 175, 614, 270, 721, 314, 675, 369, 0, 0 });
            dict.Add(6, new int[] { 740, 129, 857, 178, 744, 272, 843, 312, 802, 372, 0, 0 });
            Delegater.WaitTrue(() =>
            {
                Dm.FindStrAndClick(718, 448, 857, 502, "刷新", "86.17.70-5.5.25");
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\金币秒CD.bmp", 0.8, false))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店取消.bmp");
                    return(true);
                }
                //出现适合装备
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\适合您的装备.bmp", 0.8, false))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店取消.bmp");
                    List <Goods> list = new List <Goods>();
                    // Dm.StartWatch();
                    for (int i = 1; i <= 6; i++)
                    {
                        var color     = GetColor(dict[i][0], dict[i][1], dict[i][2], dict[i][3]);
                        var starLevel = Dm.GetPicCount(dict[i][4], dict[i][5], dict[i][6], dict[i][7], @"\bmp\星星1.bmp");
                        list.Add(new Goods()
                        {
                            Pos = i, StarLevel = starLevel, Color = color, Buypos = new Tuple <int, int>(dict[i][8], dict[i][9])
                        });
                        //Dm.DebugPrint(string.Format("位置{0}:星级【{1}】,颜色【{2}】", i, starLevel, color));
                    }
                    // Dm.StopWatch();
                    List <Goods> buyList = null;
                    if (list.Max(x => x.Color) != MaxColor)
                    {
                        Dm.DebugPrint("最大颜色错误,应是:" + list.Max(x => x.Color) + ",等级识别的maxcolor:" + MaxColor.ToString());
                        MaxColor = list.Max(x => x.Color);

                        if (MaxColor == Color.紫)
                        {
                            role.CloseWindow();
                            Delegater.WaitTrue(() => role.OpenMenu("武将"), () => role.IsExistWindowMenu("将领"), () => Dm.Delay(1000));
                            Delegater.WaitTrue(() => role.OpenWindowMenu("将领"),
                                               () => Dm.Delay(1000));
                            GetSelectedGeneralEquipment(86, 68, 177, 149, 152, 107);
                            GetSelectedGeneralEquipment(86, 156, 173, 241, 154, 194);
                            GetSelectedGeneralEquipment(84, 244, 176, 326, 153, 286);
                            GetSelectedGeneralEquipment(83, 332, 174, 417, 153, 375);

                            role.CloseWindow();
                            Delegater.WaitTrue(() => role.OpenMenu("装备"), () => role.IsExistWindowMenu("商店"), () => Dm.Delay(1000));
                            Delegater.WaitTrue(() => role.OpenWindowMenu("商店"),
                                               () => Dm.Delay(1000));
                        }
                    }
                    if (MaxColor == Color.白 || MaxColor == Color.蓝 || MaxColor == Color.绿)
                    {
                        buyList = list.Where(x => x.Color == MaxColor).ToList();
                    }
                    else if (MaxColor == Color.黄)//黄
                    {
                        buyList = list.Where(x => x.Color == Color.黄 && x.StarLevel == 1).ToList();
                    }
                    else if (MaxColor == Color.红)//红
                    {
                        buyList = list.Where(x => x.Color == Color.红 && x.StarLevel == 2).ToList();
                    }
                    else if (MaxColor == Color.紫)//紫
                    {
                        buyList = list.Where(x => x.Color == Color.紫 && x.StarLevel == 3).ToList();
                    }
                    else
                    {
                        Dm.DebugPrint("人物等级无法识别!" + level);
                        return(true);
                    }
                    if (buyList != null)
                    {
                        Dm.Delay(500);
                        foreach (var goods in buyList)
                        {
                            try
                            {
                                StoreItem items = role.GameHelper.GetStoreItem();
                                if (items == null)
                                {
                                    Dm.DebugPrint("Error:获取商店数据错误。");
                                    role.CloseWindow();
                                    return(true);
                                }
                                if (int.Parse(items.nowItemNum) >= int.Parse(items.maxItemNum))
                                {
                                    Dm.DebugPrint("Error:仓库数量达到上限。");
                                    role.CloseWindow();
                                    return(true);
                                }
                                if (items.items[goods.Pos - 1].curItemNum == null)
                                {
                                    Dm.DebugPrint("获取的商品跟识别不一致。");

                                    Dm.Delay(500);
                                    continue;
                                }


                                if (MaxColor >= Color.紫)
                                {
                                    if (int.Parse(items.items[goods.Pos - 1].curItemNum) < (10 - count))
                                    {
                                        Dm.MoveToClick(goods.Buypos.Item1, goods.Buypos.Item2);
                                        Dm.Delay(1000);
                                    }
                                }
                                else
                                {
                                    Dm.MoveToClick(goods.Buypos.Item1, goods.Buypos.Item2);
                                    Dm.Delay(1000);
                                }
                            }
                            catch (Exception ex)
                            { Debug.WriteLine(ex.Message); }
                        }
                    }
                    Dm.FindStrAndClick(718, 448, 857, 502, "刷新", "86.17.70-5.5.25");
                    Dm.Delay(1000);
                    if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\适合您的装备.bmp"))
                    {
                        Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店确定.bmp");
                    }
                }
                //出现稀有物品
                if (Dm.IsExistPic(283, 192, 668, 411, @"\bmp\稀有物品.bmp", 0.8, false))
                {
                    Dm.FindPicAndClick(283, 192, 668, 411, @"\bmp\商店取消.bmp");
                    Dm.Delay(500);
                    Dm.MoveToClick(168, 370);
                }
                return(Dm.IsExistStr(718, 448, 857, 502, "清除", "86.17.70-5.5.25"));
            }, () => Dm.Delay(200));
            // Dm.DebugPrint("需要装备:" + needs[0] + " " + needs[1] + " " + needs[2] + " " + needs[3] + " " + needs[4] + " " + needs[5]);
            role.CloseWindow();
            return(TaskResult.Finished);
        }