Exemplo n.º 1
0
        /// <summary>
        /// 推图
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="index"></param>
        public static bool Attack(WlyEntity entity, int index)
        {
            var dmGuid = entity.DMGuid;

            WlyViewMgr.GoTo(dmGuid, WlyViewType.场景_副本);
            var view = WlyViewMgr.GetView(WlyViewType.导航_日常按钮栏);

            if (view.IsCurrentView(dmGuid))
            {
                view.Exit(dmGuid);
            }

            WlyProgressNode current  = null;
            WlyProgressNode previous = null;

            if (!string.IsNullOrEmpty(entity.AccountInfo.ProgressNode))
            {
                m_progressDict.TryGetValue(entity.AccountInfo.ProgressNode, out previous);
            }

            if ((previous != null) && !string.IsNullOrEmpty(previous.Next))
            {
                current = m_progressDict[previous.Next];
            }

            while (true)
            {
                GoToMain(index, dmGuid);
                if (DMService.Instance.FindPic(dmGuid, WlyPicType.一个副本, new WxRect(567, 567, 592, 589)))
                {
                    return(true);
                }

                if (DMService.Instance.FindPic(dmGuid, WlyPicType.首攻军团, WlyUtilityBiz.GameWndRect))
                {
                    return(true);
                }

                // 寻找下一节点
                if (current == null)
                {
                    var node = GetSubPoint(dmGuid, index, previous?.ID);
                    if (!m_progressDict.TryGetValue(node.ID, out current))
                    {
                        current = node;
                    }
                }

                bool?result;
                try
                {
                    result = Attack(current.Location, dmGuid);
                    if (result == false)
                    {
                        return(false);
                    }
                }
                catch
                {
                    entity.AccountInfo.ProgressNode = string.Empty;
                    entity.AccountInfo.Save();
                    throw;
                }

                entity.AccountInfo.ProgressNode = current.ID;
                entity.AccountInfo.Save();

                if (result == null)
                {
                    if (!string.IsNullOrEmpty(current.Next))
                    {
                        current = m_progressDict[current.Next];
                    }
                    else
                    {
                        current = null;
                    }
                }
                else
                {
                    var key = false;
                    if ((previous != null) && (previous.Next == null))
                    {
                        previous.Next = current.ID;
                        key           = true;
                    }

                    if ((current.Previous == null) && (previous != null))
                    {
                        current.Previous = previous.ID;
                        key = true;
                    }

                    if (!m_progressDict.ContainsKey(current.ID))
                    {
                        current = m_progressDict.GetOrAdd(current.ID, current);
                        key     = true;
                    }

                    if (key)
                    {
                        Save();
                    }

                    if (current.IsEnd)
                    {
                        return(true);
                    }

                    previous = current;
                    if (string.IsNullOrEmpty(current.Next))
                    {
                        current = null;
                    }
                    else
                    {
                        m_progressDict.TryGetValue(current.Next, out current);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static WlyProgressNode GetSubPoint(string dmGuid, int index, string previousID)
        {
            var location = new WxPoint(0, 0);

            if (previousID == "wly17_347_127")
            {
                location = new WxPoint(394, 94);
            }
            else
            {
                var wait = FlowLogicHelper.RepeatRun(() =>
                {
                    var find = DMService.Instance.FindPic(dmGuid, WlyPicType.可攻击目标, WlyUtilityBiz.GameWndRect, out var x, out var y);
                    if (find)
                    {
                        location = new WxPoint(x + 7, y + 14);
                        return(true);
                    }

                    Thread.Sleep(500);
                    var view = WlyViewMgr.GetView(WlyViewType.导航_日常按钮栏);
                    if (view.IsCurrentView(dmGuid))
                    {
                        view.Exit(dmGuid);
                    }

                    view = WlyViewMgr.GetView(WlyViewType.右侧提示);
                    if (view.IsCurrentView(dmGuid))
                    {
                        view.Exit(dmGuid);
                    }

                    view = WlyViewMgr.GetView(WlyViewType.略_点击继续);
                    if (view.IsCurrentView(dmGuid))
                    {
                        view.Exit(dmGuid);
                    }

                    Thread.Sleep(100);
                    return(false);
                }, TimeSpan.FromSeconds(5));

                if (!wait)
                {
                    if (index == 11)
                    {
                        location = new WxPoint(909, 213);
                    }

                    if (index == 17)
                    {
                        location = new WxPoint(347, 127);
                    }
                }
            }

            // 判断是否寻到攻击目标
            if ((location.X == 0) && (location.Y == 0))
            {
                throw new InvalidOperationException("找不到攻击目标");
            }

            // 构建攻击节点
            var node = new WlyProgressNode
            {
                Location = location,
                Progress = index
            };

            return(node);
        }