public override void Tick(Bitmap viewportCapture, RECT viewportRect)
        {
            var viewportMat = viewportCapture.ToOpenCvMat();

            if (TryClickNextTag(viewportMat, viewportRect))
            {
                logTools.Info("TryClickNextTag");
            }
            else if (TryClickChallengeButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickChallengeButton");
            }
            else if (TryClickStartFightButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickStartFightButton");
            }
            else if (TryClickAutoOffButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickAutoOffButton");
            }
            else if (TryClickNextStepButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickNextStepButton");
            }
            else
            {
                logTools.Info("ClickBack");
                MumuState.DoClick(viewportRect, new Vec2f(0.1f, 0.7f));
                //MumuState.ClickBack(viewportRect);
            }
        }
Пример #2
0
        public override void Tick(Bitmap viewportCapture, RECT viewportRect)
        {
            var viewportMat = viewportCapture.ToOpenCvMat();


            if (IsDataDownloadWin(viewportMat, viewportRect))
            {
                logTools.Info("DataDownloadWin");
                MumuState.ClickDataDownloadButton(viewportRect, false);
            }
            else if (TryClickChoiceOne(viewportMat, viewportRect))
            {
                logTools.Info("TryClickChoiceOne");
            }
            else if (IsReliabilityMainScene(viewportMat, viewportRect))
            {
                DoMainSceneThings(viewportMat, viewportRect);
            }
            else if (IsReliabilityEpisodeScene(viewportMat, viewportRect))
            {
                DoEpisodeSceneThings(viewportMat, viewportRect);
            }
            else
            {
                logTools.Info("ClickBack");
                MumuState.ClickBack(viewportRect);
            }
        }
Пример #3
0
        List <ArenaPlayerPCRResult> GetArenaPlayerOCRResults(Bitmap viewportCapture, RECT viewportRect)
        {
            var r = new List <ArenaPlayerPCRResult>();

            for (int i = 0; i < 3; i++)
            {
                r.Add(new ArenaPlayerPCRResult());
            }
            var tasks = new Task[3];
            var viewportCaptureClone = viewportCapture.ToOpenCvMat();

            for (int i = 0; i < 3; i++)
            {
                var index = i;
                var task  = new Task(() =>
                {
                    var name = MumuState.DoArenaPlayerNameOCR(viewportCaptureClone, viewportRect, index);
                    var rank = MumuState.DoArenaPlayerRankOCR(viewportCaptureClone, viewportRect, index);
                    r[index] = new ArenaPlayerPCRResult()
                    {
                        Index = index,
                        Name  = name,
                        Rank  = rank,
                    };
                });
                task.Start();
                tasks[i] = task;
            }
            Task.WaitAll(tasks);
            return(r);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="viewportMat"></param>
        /// <param name="viewportRect"></param>
        /// <param name="depth">主线剧情界面这种算第一层</param>
        public void DoListSceneThings(Mat viewportMat, RECT viewportRect, int depth)
        {
            if (depth >= 3)
            {
                return;
            }

            logTools.Info($"DoListSceneThings; CurStory: {CurStory}; Depth: {depth}");

            var listRectRate = new Vec4f(0.5342f, 0.1210f, 0.9789f, 0.8790f);
            var matchRes     = MatchImage(viewportMat, viewportRect, listRectRate, "story_new_tag_inner.png", listItemNewTagThreshold);

            if (matchRes.Success)
            {
                ClickListItem(viewportRect, listRectRate, matchRes.MatchedRect);
                Thread.Sleep(2000);
                var newViewportRect    = MumuState.ViewportRect;
                var newViewportCapture = MumuState.DoCapture(newViewportRect);
                DoListSceneThings(newViewportCapture.ToOpenCvMat(), viewportRect, depth + 1);
            }
            else
            {
                if (DragListTimes > 10)
                {
                    MumuState.ClickBack(viewportRect);
                }
                else
                {
                    MumuState.DoDrag(viewportRect, new Vec2f(0.7700f, 0.7012f), new Vec2f(0.7700f, 0.2332f), 1200);
                    DragListTimes += 1;
                }
            }
        }
Пример #5
0
        public void ClickListItem(RECT viewportRect, Vec4f listRectRate, RECT listItemNewTagRect)
        {
            var newTagAbsoluteRect = GetMatchedAbsoluteRect(viewportRect, listRectRate, listItemNewTagRect);
            //这个是opencv中的坐标
            var clickCvPoint  = new RawPoint((newTagAbsoluteRect.x1 + newTagAbsoluteRect.x2) / 2, newTagAbsoluteRect.y2);
            var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, clickCvPoint);

            MumuState.DoClick(emulatorPoint);
        }
        public override void OnStart(Bitmap viewportCapture, RECT viewportRect)
        {
            CurDifficulty = UndergroundDifficulty.Veryhard;
            //TryClickButton(viewportCapture.ToOpenCvMat(), viewportRect, "underground_special_box.png", leftPartRectRate, 0.6);

            MumuState.ClickTab(viewportRect, PCRTab.Battle);
            Thread.Sleep(3000);
            MumuState.ClickBattleEntrance(viewportRect, PCRBattleMode.Underground);
            Thread.Sleep(2000);
        }
Пример #7
0
        public bool DoMainSceneThings(Mat viewportMat, RECT viewportRect, PCRStory story)
        {
            var rectRate = mainsceneStoryTypeExMap[story];
            var matchRes = MatchImage(viewportMat, viewportRect, rectRate, "story_new_tag.png");

            if (!matchRes.Success)
            {
                return(false);
            }
            logTools.Info($"Found Story New Tag: {story}");
            CurStory = story;
            MumuState.ClickStoryEntrance(viewportRect, story);
            return(true);
        }
Пример #8
0
        public override void Tick(Bitmap viewportCapture, RECT viewportRect)
        {
            if (viewportCapture.Width < 10 || viewportCapture.Height < 10)
            {
                logTools.Info("Capture Size Sucks, Special Process, Click Skip");
                MumuState.ClickSkipConfirmButton(viewportRect);
                return;
            }

            var viewportMat = viewportCapture.ToOpenCvMat();

            if (IsStoryMainScene(viewportMat, viewportRect))
            {
                DoMainSceneThings(viewportMat, viewportRect);
                DragListTimes = 0;
            }
            else if (IsStoryListScene(viewportMat, viewportRect))
            {
                DoListSceneThings(viewportMat, viewportRect, 1);
            }
            else if (IsDataDownloadWin(viewportMat, viewportRect))
            {
                MumuState.ClickDataDownloadButton(viewportRect, false);
                ClickMenuButtonTimes = 0;
                DragListTimes        = 0;
            }
            else if (HasSkipConfirmButton(viewportMat, viewportRect))
            {
                MumuState.ClickSkipConfirmButton(viewportRect);
            }
            else if (HasSkipButton(viewportMat, viewportRect))
            {
                MumuState.ClickSkipButton(viewportRect);
            }
            else if (HasMenuButton(viewportMat, viewportRect))
            {
                MumuState.ClickMenuButton(viewportRect);
                ClickMenuButtonTimes += 1;
                if (ClickMenuButtonTimes > 5)
                {
                    MumuState.ClickBack(viewportRect);
                }
            }
            else
            {
                logTools.Info("Found Nothing, Click Back");
                MumuState.ClickBack(viewportRect);
            }
        }
Пример #9
0
        public bool TryClickButton(Mat viewportMat, RECT viewportRect, string exImgName, Vec4f rectRate, double threshold)
        {
            var matchRes = MatchImage(viewportMat, viewportRect, rectRate, exImgName, threshold);

            if (!matchRes.Success)
            {
                return(false);
            }
            var absoluteRect  = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect);
            var centerPos     = absoluteRect.GetCenterPos();
            var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, centerPos);

            MumuState.DoClick(emulatorPoint);
            return(true);
        }
Пример #10
0
        public override void Tick(Bitmap viewportCapture, RECT viewportRect)
        {
            var list = GetArenaPlayerOCRResults(viewportCapture, viewportRect);
            var idx  = GetArenaPlayerIndex(list);

            logTools.Info("Player Index: " + idx + (idx == -1 ? "(Not Found)" : ""));
            if (idx != -1)
            {
                MumuState.ClickArenaPlayer(viewportRect, idx);
                var res = list[idx];
                throw new BreakException($"已找到目标玩家 名字:{res.Name} 排名:{res.Rank}, 脚本终止");
            }
            else
            {
                MumuState.ClickArenaRefresh(viewportRect);
            }
        }
        public override void Tick(Bitmap viewportCapture, RECT viewportRect)
        {
            var viewportMat = viewportCapture.ToOpenCvMat();

            var f = true;

            if (TryClickChallengeButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickChallengeButton");
            }
            else if (TryClickStartFightButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickStartFightButton");
            }
            else if (TryClickAutoOffButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickAutoOffButton");
            }
            else if (TryClickNextStepButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickNextStepButton");
            }
            else if (TryClickGobackUnderGroundButton(viewportMat, viewportRect))
            {
                logTools.Info("TryClickGobackUnderGroundButton");
            }
            else
            {
                f = false;
            }

            if (!f)
            {
                var b1 = TryClickNormalBox(viewportMat, viewportRect);
                var b2 = TryClickSpecailBox(viewportMat, viewportRect);
                if (!b1 && !b2)
                {
                    logTools.Info("Click Back");
                    MumuState.ClickBack(viewportRect);
                }
            }

            TryClickNormalBox(viewportMat, viewportRect);
        }
Пример #12
0
        public bool ClickConfrimIfHas(Mat viewportMat, RECT viewportRect)
        {
            var skipConfirmButtonRectRate = new Vec4f(0.5364f, 0.6254f, 0.6674f, 0.7493f);
            var matchRes = MatchImage(viewportMat, viewportRect, skipConfirmButtonRectRate, "skip_confirm_button.png");

            if (!matchRes.Success)
            {
                return(false);
            }
            var confirmAbsoluteRect = GetMatchedAbsoluteRect(viewportRect, skipConfirmButtonRectRate, matchRes.MatchedRect);
            //这个是opencv中的坐标
            var cvX           = (confirmAbsoluteRect.x1 + confirmAbsoluteRect.x2) / 2;
            var cvY           = (confirmAbsoluteRect.y1 + confirmAbsoluteRect.y2) / 2;
            var clickCvPoint  = new RawPoint(cvX, cvY);
            var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, clickCvPoint);

            MumuState.DoClick(emulatorPoint);
            return(true);
        }
Пример #13
0
        public bool TryClickNextTag(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.6;
            var rectRate  = new Vec4f(0.0044f, 0.1122f, 0.9833f, 0.8950f);
            var matchRes  = MatchImage(viewportMat, viewportRect, rectRate, "battle_next_tag.png", threshold);

            if (!matchRes.Success)
            {
                return(false);
            }
            var absoluteRect = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect);
            var pos          = absoluteRect.GetCenterPos();

            pos.Y = pos.Y + (int)(viewportRect.Height * 0.1500f);
            var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, pos);

            MumuState.DoClick(emulatorPoint);
            return(true);
        }
Пример #14
0
        public void DoMainSceneThings(Mat viewportMat, RECT viewportRect)
        {
            logTools.Info("DoMainSceneThings");

            var listItemNewTagThreshold = 0.6;
            var listRectRate            = new Vec4f(0.5378f, 0.1254f, 0.9760f, 0.8834f);
            var matchRes = MatchImage(viewportMat, viewportRect, listRectRate, "reliability_new_tag.png", listItemNewTagThreshold);

            if (matchRes.Success)
            {
                var absoluteRect  = GetMatchedAbsoluteRect(viewportRect, listRectRate, matchRes.MatchedRect);
                var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos());
                MumuState.DoClick(emulatorPoint);
            }
            else
            {
                logTools.Info("DoMainSceneThings Cannot Find New Tag");
                MumuState.DoDrag(viewportRect, new Vec2f(0.7700f, 0.7012f), new Vec2f(0.7700f, 0.2332f), 1200);
            }
        }
Пример #15
0
        public void DoEpisodeSceneThings(Mat viewportMat, RECT viewportRect)
        {
            logTools.Info("DoEpisodeSceneThings");

            var threshold = 0.6;
            var rectRate  = new Vec4f(0.0408f, 0.0350f, 0.9651f, 0.8499f);
            var matchRes  = MatchImage(viewportMat, viewportRect, rectRate, "reliability_episode_new_tag.png", threshold);

            if (matchRes.Success)
            {
                var absoluteRect  = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect);
                var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos());
                MumuState.DoClick(emulatorPoint);
            }
            else
            {
                logTools.Info("DoEpisodeSceneThings Cannot Find New Tag");
                MumuState.ClickBack(viewportRect);
            }
        }
        public bool TryClickNormalBox(Mat viewportMat, RECT viewportRect)
        {
            var threshold = 0.8;
            var rectRate  = fullPartRectRate;
            var matchRes  = MatchImage(viewportMat, viewportRect, rectRate, "underground_normal_box.png", threshold);

            if (!matchRes.Success)
            {
                return(false);
            }
            var absoluteRect  = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect);
            var left2right    = absoluteRect.GetCenterPos().X < 1.0f * viewportRect.Width / 2;
            var emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos());

            MumuState.DoClick(emulatorPoint);
            Thread.Sleep(500);
            for (int i = 1; i < 3; i++)
            {
                if (left2right)
                {
                    var newX1Rate = 1.0f * absoluteRect.x2 / viewportRect.Width;
                    rectRate.Item0 = newX1Rate;
                }
                else
                {
                    var newX2Rate = 1.0f * absoluteRect.x1 / viewportRect.Width;
                    rectRate.Item2 = newX2Rate;
                }
                matchRes = MatchImage(viewportMat, viewportRect, rectRate, "underground_normal_box.png", threshold);
                if (!matchRes.Success)
                {
                    break;
                }
                absoluteRect  = GetMatchedAbsoluteRect(viewportRect, rectRate, matchRes.MatchedRect);
                emulatorPoint = MumuState.GetEmulatorPoint(viewportRect, absoluteRect.GetCenterPos());
                MumuState.DoClick(emulatorPoint);
                Thread.Sleep(500);
            }
            return(true);
        }
Пример #17
0
 public void SetMumuState(MumuState mumuState)
 {
     MumuState = mumuState;
 }
Пример #18
0
 public override void OnStart(Bitmap viewportCapture, RECT viewportRect)
 {
     MumuState.ClickTab(viewportRect, PCRTab.Story);
     Thread.Sleep(3000);
 }
Пример #19
0
 public override void OnStart(Bitmap viewportCapture, RECT viewportRect)
 {
     MumuState.ClickTab(viewportRect, PCRTab.Mainpage);
     Thread.Sleep(3000);
     MumuState.ClickMainpageButton(viewportRect, PCRMainpageButton.Present);
 }
 public override void Tick(Bitmap viewportCapture, RECT viewportRect)
 {
     MumuState.ClickActStageExchange(viewportRect);
 }