protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Mail, Globals.MailPage)); }); ActionSequenceTree fromMail = new ActionSequenceTree(() => { Console.WriteLine("[fromMail]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.RecvAllInMailPage)); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(new JobMovePage(_form, Globals.MailPage, Globals.OutFromMailPage, Globals.MainPage)); }); fromMain.Completed = fromMail; fromMain.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.MailPage] = fromMail; }
private State Repair() { Console.WriteLine("Repair " + _type + ".."); RemoveAllSubJobs(); var pageName = _form.CurrentPageName; ActionSequenceTree actionTree = null; if (pageName == Globals.UnknownPage) { } else if (_repairMap.TryGetValue(pageName, out actionTree)) { _repairByForce = false; SetCurrentAction(actionTree); actionTree.Action(); } else { OnJobFailed(); return(State.Failed); } return(_status = State.Active); }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Menu, Globals.MenuPage)); }); ActionSequenceTree fromMenu = new ActionSequenceTree(() => { Console.WriteLine("[fromMenu]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.MenuToItem, Globals.ItemPage)); }); ActionSequenceTree fromItem = new ActionSequenceTree(() => { Console.WriteLine("[fromItem]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot2, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot2, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot2, true)); AddSubJob(new JobWaitTime(_form, 750)); }); ActionSequenceTree selectItem = new ActionSequenceTree(() => { Console.WriteLine("[selectItem]"); if (_upgradeState != UpgradeState.Finished) { var item = _upgradeItemOnState[_upgradeState]; AddSubJob(new JobMovePage(_form, Globals.ItemPage, item, Globals.ItemDetailPage)); } }); ActionSequenceTree fromItemDetail = new ActionSequenceTree(() => { Console.WriteLine("[fromItemDetail]"); AddSubJob(new JobMovePage(_form, Globals.ItemDetailPage, Globals.ToUpgrade, Globals.ItemUpgradePage)); AddSubJob(new JobWaitTime(_form, 750)); }); // upgrade ActionSequenceTree findItem = new ActionSequenceTree(() => { Console.WriteLine("[findItem]"); AddSubJob(new JobTryFindOneOfSubImages(_form, _itemRanks)); }); ActionSequenceTree clickItem = new ActionSequenceTree(() => { Console.WriteLine("[clickItem]"); OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); int addX = 10; int addY = 20; var pos = Utils.RectToPos(rect.X + addX, rect.Y + addY, rect.Width, rect.Height); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 500)); }); ActionSequenceTree upgrade = new ActionSequenceTree(() => { Console.WriteLine("[upgrade]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.StartUpgrade, true)); AddSubJob(new JobWaitTime(_form, 500)); AddSubJob(new JobCheckPage(_form, Globals.ItemUpgradeResultPage, 5000)); }); ActionSequenceTree checkLockPage = new ActionSequenceTree(() => { Console.WriteLine("[checkLockPage]"); AddSubJob(new JobWaitTime(_form, 500)); AddSubJob(new JobCheckPage(_form, Globals.ItemLockPage, 5000)); }); ActionSequenceTree exitResult = new ActionSequenceTree(() => { Console.WriteLine("[exitResult]"); AddSubJob( new JobMovePage( _form, Globals.ItemUpgradeResultPage, Globals.OutFromUpgradeResult, Globals.ItemUpgradePage)); }); // exit ActionSequenceTree exitItemUpgrade = new ActionSequenceTree(() => { Console.WriteLine("[exitItemUpgrade]"); AddSubJob( new JobMovePage( _form, Globals.ItemUpgradePage, Globals.BackInUpgradePage, Globals.ItemPage)); }); ActionSequenceTree checkUpgradeState = new ActionSequenceTree(() => { AddSubJob(new JobCheckCondition(_form, () => { return(_upgradeState == UpgradeState.Finished); })); }); ActionSequenceTree exitItemPage = new ActionSequenceTree(() => { AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot1, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot1, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ItemSlot1, true)); AddSubJob(new JobWaitTime(_form, 750)); Console.WriteLine("[exitItemPage]"); AddSubJob( new JobMovePage( _form, Globals.ItemPage, Globals.BackInItemPage, Globals.MenuPage)); }); ActionSequenceTree exitMenu = new ActionSequenceTree(() => { Console.WriteLine("[exitMenu]"); AddSubJob( new JobMovePage( _form, Globals.MenuPage, Globals.BackInMenu, Globals.MainPage)); }); // if repair ActionSequenceTree exitLockPage = new ActionSequenceTree(() => { Console.WriteLine("[exitLockPage]"); AddSubJob( new JobMovePage( _form, Globals.ItemLockPage, Globals.NoInItemLockPage, Globals.ItemUpgradePage)); }); ActionSequenceTree exitGetVisualPage = new ActionSequenceTree(() => { Console.WriteLine("[exitGetVisualPage]"); AddSubJob( new JobMovePage( _form, Globals.ItemGetVisualPage, Globals.ExitItemGetVisual, Globals.ItemDetailPage)); }); fromMain.Completed = fromMenu; fromMenu.Completed = fromItem; fromItem.Completed = selectItem; selectItem.Completed = fromItemDetail; fromItemDetail.Completed = findItem; // upgrade findItem.Completed = clickItem; findItem.ActionOnCompleted = () => { _form.ItemUpgradeCnt = _form.ItemUpgradeCnt + 1; _nothingToUpgrade = false; }; clickItem.Completed = upgrade; upgrade.Completed = exitResult; upgrade.Failed = checkLockPage; checkLockPage.Completed = exitLockPage; exitLockPage.Completed = exitItemUpgrade; checkLockPage.Failed = findItem; exitResult.Completed = findItem; findItem.Failed = exitItemUpgrade; exitItemUpgrade.Completed = checkUpgradeState; exitItemUpgrade.ActionOnCompleted = () => { UpdateUpgradeState(); }; checkUpgradeState.Completed = exitItemPage; checkUpgradeState.Failed = selectItem; exitItemPage.Completed = exitMenu; exitMenu.ActionOnCompleted = () => { if (_nothingToUpgrade) { _returnState = State.Failed; } else { _returnState = State.Completed; } }; _currentAction = fromMain; // make repair map _repairMap[Globals.MenuPage] = fromMenu; _repairMap[Globals.ItemPage] = fromItem; _repairMap[Globals.ItemDetailPage] = fromItemDetail; _repairMap[Globals.ItemUpgradePage] = findItem; _repairMap[Globals.ItemLockPage] = exitLockPage; _repairMap[Globals.ItemUpgradeResultPage] = exitResult; _repairMap[Globals.ItemGetVisualPage] = exitGetVisualPage; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromLogin = new ActionSequenceTree(() => { Console.WriteLine("[fromLogin]"); // #fix - to page AddSubJob(new JobMovePage(_form, Globals.LoginPage, _signInWith, Globals.FacebookPage)); if (_signInWith == Globals.Facebook) { AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.FacebookPage })); } else if (_signInWith == Globals.Google) { //AddSubJob(new JobCheckCurrentPage(_form, new string[] { Globals.GooglePage })); } else if (_signInWith == Globals.Guest) { //AddSubJob(new JobCheckCurrentPage(_form, new string[] { Globals.FacebookPage })); } }); ActionSequenceTree fromFacebookLogin = new ActionSequenceTree(() => { Console.WriteLine("[fromFacebookLogin]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.EmailInFacebook, true)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobPressKeyboard(_form, _email)); AddSubJob(new JobWaitTime(_form, 500)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.PasswordInFacebook, true)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobPressKeyboard(_form, _password)); AddSubJob(new JobWaitTime(_form, 500)); AddSubJob(new JobMovePage(_form, Globals.FacebookPage, Globals.LoginInFacebook, Globals.FacebookConfirmPage, 2000, 2000)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.FacebookConfirmPage })); }); ActionSequenceTree fromFacebookConfirm = new ActionSequenceTree(() => { Console.WriteLine("[fromFacebookConfirm]"); AddSubJob(new JobMovePage(_form, Globals.FacebookConfirmPage, Globals.YesInFacebook, Globals.StartGamePage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.StartGamePage })); }); ActionSequenceTree fromStartGame = new ActionSequenceTree(() => { Console.WriteLine("[fromStartGame]"); AddSubJob(new JobMovePage(_form, Globals.StartGamePage, Globals.ClickOnStartGamePage, Globals.CharacterSelectPage)); }); ActionSequenceTree fromCharacterSelect = new ActionSequenceTree(() => { Console.WriteLine("[fromCharacterSelect]"); AddSubJob(new JobMovePage(_form, Globals.CharacterSelectPage, Globals.StartGameInSelectPage, Globals.NotifyPage)); }); ActionSequenceTree closeNotifyPage = new ActionSequenceTree(() => { Console.WriteLine("[closeNotifyPage]"); AddSubJob(new JobMovePage(_form, Globals.NotifyPage, Globals.CloseNotify, Globals.MainPage)); }); fromLogin.Completed = fromFacebookLogin; fromFacebookLogin.Completed = fromFacebookConfirm; fromFacebookConfirm.Completed = fromStartGame; fromStartGame.Completed = fromCharacterSelect; fromCharacterSelect.Completed = closeNotifyPage; _currentAction = fromLogin; // make repair map _repairMap[Globals.LoginPage] = fromLogin; _repairMap[Globals.FacebookPage] = fromFacebookLogin; _repairMap[Globals.FacebookConfirmPage] = fromFacebookConfirm; _repairMap[Globals.StartGamePage] = fromStartGame; _repairMap[Globals.CharacterSelectPage] = fromCharacterSelect; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromTrial = new ActionSequenceTree(() => { Console.WriteLine("[fromTrial]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Trial, Globals.TrialPage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.TrialPage })); }); ActionSequenceTree findBeforeDrag = new ActionSequenceTree( () => { Console.WriteLine("[findBeforeDrag]"); string what = ""; if (_todo.TryGetValue(_currentState, out what)) { AddSubJob(new JobTryFindSubImage(_form, what)); } }); ActionSequenceTree click = new ActionSequenceTree( () => { Console.WriteLine("[click]"); OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); var pos = Utils.RectToPos(rect.X + 50, rect.Y + 100, rect.Width, rect.Height); AddSubJob(new JobMoveAndClickMouse(_form, pos)); }); ActionSequenceTree drag = new ActionSequenceTree( () => { Console.WriteLine("[drag]"); AddSubJob(new JobWaitTime(_form, 1500)); Drag(_form, this, new System.Drawing.Point(0, 0)); AddSubJob(new JobWaitTime(_form, 1000)); Drag(_form, this, new System.Drawing.Point(-100, 0)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree findAfterDrag = new ActionSequenceTree( () => { Console.WriteLine("[findAfterDrag]"); string what = ""; if (_todo.TryGetValue(_currentState, out what)) { AddSubJob(new JobTryFindSubImage(_form, what)); } }); ActionSequenceTree fromTrialStage = new ActionSequenceTree( () => { Console.WriteLine("[fromTrialStage]"); AddSubJob(new JobWaitTime(_form, 1500)); Drag(_form, this, new System.Drawing.Point(0, 0)); AddSubJob(new JobWaitTime(_form, 1000)); Drag(_form, this, new System.Drawing.Point(-100, 0)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree getCurrentPage = new ActionSequenceTree( () => { Console.WriteLine("[getCurrentPage]"); AddSubJob(new JobWaitTime(_form, 3000)); _currentPage = _form.CurrentPageName; }); ActionSequenceTree start = new ActionSequenceTree( () => { Console.WriteLine("[start] current page : " + _currentPage); string ui; if (_clickUI.TryGetValue(_currentPage, out ui)) { AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, ui, true)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, ui, true)); AddSubJob(new JobWaitTime(_form, 1000)); } }); ActionSequenceTree checkNoPageMove = new ActionSequenceTree(() => { Console.WriteLine("[checkCurrentPage]"); AddSubJob(new JobCheckPage(_form, _currentPage, 5000)); }); ActionSequenceTree fromResult = new ActionSequenceTree(() => { Console.WriteLine("[fromResult]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ToTrialFromTrialResult, true)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.ToTrialFromTrialResult, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree checkCurrentPage = new ActionSequenceTree(() => { Console.WriteLine("[checkCurrentPage]"); AddSubJob(new JobCheckPage(_form, Globals.TrialPage, 8000)); }); ActionSequenceTree backToTrial = new ActionSequenceTree(() => { Console.WriteLine("[backToTrial]"); AddSubJob(new JobMovePage(_form, _currentPage, Globals.BackInTrialLevelPages, Globals.TrialPage)); }); ActionSequenceTree checkCurrentState = new ActionSequenceTree(() => { Console.WriteLine("[checkCurrentState]"); AddSubJob(new JobCheckCondition(_form, () => { return(_currentState == TrialState.Finished); })); }); ActionSequenceTree exitTrial = new ActionSequenceTree(() => { Console.WriteLine("[exitTrial]"); AddSubJob(new JobMovePage(_form, Globals.TrialPage, Globals.BackInTrial, Globals.MainPage)); }); fromTrial.Completed = checkCurrentState; checkCurrentState.Completed = exitTrial; checkCurrentState.Failed = findBeforeDrag; findBeforeDrag.Completed = click; findBeforeDrag.Failed = drag; drag.Completed = findAfterDrag; findAfterDrag.Completed = click; findAfterDrag.Failed = fromTrial; findAfterDrag.ActionOnFailed = () => { UpdateTrialState(); }; click.Completed = fromTrialStage; fromTrialStage.Completed = getCurrentPage; getCurrentPage.Completed = start; start.Completed = checkNoPageMove; // not started checkNoPageMove.Completed = backToTrial; checkNoPageMove.Failed = fromResult; fromResult.Completed = checkCurrentPage; checkCurrentPage.Completed = fromTrial; checkCurrentPage.Failed = backToTrial; backToTrial.Completed = fromTrial; backToTrial.ActionOnCompleted = () => { UpdateTrialState(); }; exitTrial.ActionOnCompleted = () => { if (_currentState == TrialState.Finished) { Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); _returnState = State.Completed; } else { Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); _returnState = State.Failed; } }; _currentAction = fromTrial; // make repair map _repairMap[Globals.TrialPage] = fromTrial; _repairMap[Globals.TrialSweepAwayPage] = fromTrialStage; _repairMap[Globals.TrialMansFightPage] = fromTrialStage; _repairMap[Globals.TrialWomansFightPage] = fromTrialStage; _repairMap[Globals.TrialTwoDevilPage] = fromTrialStage; //_repairMap[Globals.TrialBattleGodPage] = fromTrialStage; _repairMap[Globals.TrialStormEyePage] = fromTrialStage; _repairMap[Globals.TrialBloodyPage] = fromTrialStage; _repairMap[Globals.TrialResultPage] = fromResult; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Cowork, Globals.CoworkPage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.CoworkPage })); AddSubJob(new JobMovePage(_form, Globals.CoworkPage, Globals.Raid, Globals.RaidPage)); }); ActionSequenceTree moveBoss = new ActionSequenceTree(() => { Console.WriteLine("[moveBoss]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.Demian, true)); AddSubJob(new JobWaitTime(_form, 2000)); }); ActionSequenceTree drag = new ActionSequenceTree( () => { Console.WriteLine("[drag]"); OpenCvSharp.Rect left; bool leftFlag = _form.AllUIRects.TryGetValue(Globals.RaidDragLeftPos, out left); OpenCvSharp.Rect right; bool rightFlag = _form.AllUIRects.TryGetValue(Globals.RaidDragRightPos, out right); if (leftFlag && rightFlag) { var start = Utils.RectToPos(right.X, right.Y, right.Width, right.Height); var end = Utils.RectToPos(left.X, left.Y, left.Width, left.Height); AddSubJob(new JobDrag(_form, start, end)); } }); ActionSequenceTree clickLevel = new ActionSequenceTree( () => { Console.WriteLine("[clickLevel]"); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, _level, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree fromRaid = new ActionSequenceTree(() => { Console.WriteLine("[fromRaid]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.RaidAward, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree checkAwardPage = new ActionSequenceTree(() => { Console.WriteLine("[checkAwardPage]"); AddSubJob(new JobCheckPage(_form, Globals.RaidRepeatAwardPage)); }); // if checkAwardPage completed ActionSequenceTree exitAwardPage = new ActionSequenceTree(() => { Console.WriteLine("[exitAwardPage]"); AddSubJob( new JobMovePage( _form, Globals.RaidRepeatAwardPage, Globals.OutFromRepeatAward, Globals.RaidPage)); }); ActionSequenceTree clickStart = new ActionSequenceTree(() => { Console.WriteLine("[clickStart]"); AddSubJob(new JobMovePage(_form, Globals.RaidPage, Globals.StartRaid, new string[] { Globals.RaidRestrictedPage, Globals.UnknownPage })); }); ActionSequenceTree checkRaidRestricted = new ActionSequenceTree(() => { Console.WriteLine("[checkRaidRestricted]"); AddSubJob(new JobCheckPage(_form, Globals.RaidRestrictedPage)); }); // if checkRaidRestricted completed ActionSequenceTree exitRaidRestrictedPage = new ActionSequenceTree(() => { Console.WriteLine("[exitRaidRestrictedPage]"); AddSubJob( new JobMovePage( _form, Globals.RaidRestrictedPage, Globals.NoInRaidRestrictedPage, Globals.RaidPage)); }); ActionSequenceTree exitRaidPage = new ActionSequenceTree(() => { Console.WriteLine("[exitRaidPage]"); AddSubJob(new JobMovePage(_form, Globals.RaidPage, Globals.BackInRaid, Globals.MainPage)); }); ActionSequenceTree fromStarted = new ActionSequenceTree(() => { Console.WriteLine("[fromStarted]"); AddSubJob( new JobCheckUntilMeetPage( _form, new string[] { Globals.RaidResultPage })); }); ActionSequenceTree fromResult = new ActionSequenceTree(() => { Console.WriteLine("[fromResult]"); AddSubJob(new JobMovePage(_form, Globals.RaidResultPage, Globals.ToMainFromRaidResult, Globals.MainPage)); }); fromMain.Completed = moveBoss; moveBoss.Completed = drag; drag.Completed = clickLevel; clickLevel.Completed = fromRaid; fromRaid.Completed = checkAwardPage; checkAwardPage.Completed = exitAwardPage; checkAwardPage.Failed = clickStart; exitAwardPage.Completed = clickStart; clickStart.Completed = checkRaidRestricted; checkRaidRestricted.Completed = exitRaidRestrictedPage; checkRaidRestricted.Failed = fromStarted; exitRaidRestrictedPage.Completed = exitRaidPage; fromStarted.Completed = fromResult; fromResult.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.CoworkPage] = fromMain; _repairMap[Globals.RaidPage] = moveBoss; _repairMap[Globals.RaidRepeatAwardPage] = exitAwardPage; _repairMap[Globals.RaidRestrictedPage] = exitRaidRestrictedPage; _repairMap[Globals.RaidResultPage] = fromResult; }
public override State Process() { ActivateIfInActive(); var endTime = DateTime.Now; _elapsed = (endTime - _changeStartTime).TotalMilliseconds; if (CheckFail()) { return(_status = State.Failed); } Console.WriteLine(_elapsed); if (_elapsed > _repairPeriod || _repairByForce) { return(_status = Repair()); } var status = ProcessSubJobs(); if (status == State.Completed || status == State.Failed) { if (_currentAction != null) { Action action = null; ActionSequenceTree newActionTree = null; if (status == State.Completed) { action = _currentAction.ActionOnCompleted; newActionTree = _currentAction.Completed; } else { action = _currentAction.ActionOnFailed; newActionTree = _currentAction.Failed; } if (action != null) { action(); } SetCurrentAction(newActionTree); if (_currentAction != null) { _currentAction.Action(); } } else { _status = _returnState; if (_returnState == State.Completed) { OnJobCompleted(); } else if (_returnState == State.Failed) { OnJobFailed(); } } } return(_status); }
private void SetCurrentAction(ActionSequenceTree actionTree) { _currentAction = actionTree; _changeStartTime = DateTime.Now; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Traverse, Globals.TraversePage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.TraversePage })); }); ActionSequenceTree fromTraverse = new ActionSequenceTree(() => { Console.WriteLine("[fromTraverse]"); AddSubJob(new JobMovePage(_form, Globals.TraversePage, Globals.TraverseDungeon, Globals.TraverseDungeonPage)); }); ActionSequenceTree checkForTraverseDungeonBlankPage = new ActionSequenceTree(() => { Console.WriteLine("[checkForBlankTraversePage]"); AddSubJob(new JobCheckPage(_form, Globals.TraverseDungeonBlankPage)); }); ActionSequenceTree moveLeft = new ActionSequenceTree(() => { Console.WriteLine("[moveLeft]"); new JobMovePage(_form, Globals.TraverseDungeonBlankPage, Globals.LeftInTraverse, Globals.TraverseDungeonPage); }); ActionSequenceTree selectLevel = new ActionSequenceTree(() => { Console.WriteLine("[selectLevel]"); AddSubJob(new JobMovePage(_form, Globals.TraverseDungeonPage, _level, Globals.TraverseStagePage)); }); ActionSequenceTree fromTraverseStage = new ActionSequenceTree(() => { Console.WriteLine("[fromTraverseStage]"); AddSubJob(new JobMovePage(_form, Globals.TraverseStagePage, Globals.StartTraverse, new string[] { Globals.TraverseRestrictedPage, Globals.UnknownPage })); }); ActionSequenceTree checkTraverseRestricted = new ActionSequenceTree(() => { Console.WriteLine("[checkTraverseRestricted]"); AddSubJob(new JobCheckPage(_form, Globals.TraverseRestrictedPage)); }); ActionSequenceTree exitTraverseRestricted = new ActionSequenceTree(() => { Console.WriteLine("[exitTraverseRestricted]"); AddSubJob(new JobMovePage(_form, Globals.TraverseRestrictedPage, Globals.NoInTraverseRestrictedPage, Globals.TraverseStagePage)); }); ActionSequenceTree exitTraverseStage = new ActionSequenceTree(() => { Console.WriteLine("[exitTraverseStage]"); AddSubJob(new JobMovePage(_form, Globals.TraverseStagePage, Globals.BackInTraverseStage, Globals.TraverseDungeonPage)); }); ActionSequenceTree exitTraverseDungeon = new ActionSequenceTree(() => { Console.WriteLine("[exitTraverseDungeon]"); AddSubJob(new JobMovePage(_form, Globals.TraverseDungeonPage, Globals.BackInTraverseDungeon, Globals.MainPage)); }); ActionSequenceTree fromStarted = new ActionSequenceTree(() => { Console.WriteLine("[fromStarted]"); AddSubJob(new JobCheckUntilMeetPage( _form, new string[] { Globals.TraverseResultPage })); }); ActionSequenceTree checkClearCnt = new ActionSequenceTree(() => { AddSubJob(new JobCheckCondition(_form, () => { return(_clearCnt >= _clearWaves); })); }); ActionSequenceTree retry = new ActionSequenceTree(() => { Console.WriteLine("[retry]"); AddSubJob(new JobMovePage( _form, Globals.TraverseResultPage, Globals.RetryInTraverseResultPage, Globals.TraverseStagePage)); }); ActionSequenceTree toMainFromResult = new ActionSequenceTree(() => { Console.WriteLine("[toMainFromResult]"); AddSubJob(new JobMovePage( _form, Globals.TraverseResultPage, Globals.ToMainFromTraverseResultPage, Globals.MainPage)); }); ActionSequenceTree outFromInGameStop = new ActionSequenceTree(() => { Console.WriteLine("[outFromInGameStop]"); var job = JobGenerator.CreateJobMoveAndClickMouse( _form, Globals.KeepGoingInStopPage, true); job.AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(job); }); fromMain.Completed = fromTraverse; fromTraverse.Completed = checkForTraverseDungeonBlankPage; checkForTraverseDungeonBlankPage.Completed = moveLeft; checkForTraverseDungeonBlankPage.Failed = selectLevel; moveLeft.Completed = selectLevel; selectLevel.Completed = fromTraverseStage; fromTraverseStage.Completed = checkTraverseRestricted; checkTraverseRestricted.Completed = exitTraverseRestricted; exitTraverseRestricted.Completed = exitTraverseStage; exitTraverseStage.Completed = exitTraverseDungeon; checkTraverseRestricted.Failed = fromStarted; fromStarted.Completed = checkClearCnt; checkClearCnt.Completed = toMainFromResult; checkClearCnt.Failed = retry; checkClearCnt.ActionOnCompleted = () => { _clearCnt++; _form.TraverseClearedCnt = _form.TraverseClearedCnt + 1; }; checkClearCnt.ActionOnFailed = () => { _clearCnt++; _form.TraverseClearedCnt = _form.TraverseClearedCnt + 1; }; retry.Completed = fromTraverseStage; toMainFromResult.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.TraversePage] = fromTraverse; _repairMap[Globals.TraverseDungeonPage] = checkForTraverseDungeonBlankPage; _repairMap[Globals.TraverseDungeonBlankPage] = checkForTraverseDungeonBlankPage; _repairMap[Globals.TraverseStagePage] = fromTraverseStage; _repairMap[Globals.TraverseRestrictedPage] = checkTraverseRestricted; _repairMap[Globals.TraverseResultPage] = checkClearCnt; //_repairMap[Globals.UnknownPage] = outFromInGameStop; }
protected override void MakeActionSequenceTree() { // make action sequence tree ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Menu, Globals.MenuPage)); }); ActionSequenceTree fromMenu = new ActionSequenceTree(() => { Console.WriteLine("[fromMenu]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.MenuToForge, Globals.ForgePage)); }); ActionSequenceTree fromForge = new ActionSequenceTree(() => { Console.WriteLine("[fromForge]"); AddSubJob(new JobMovePage(_form, Globals.ForgePage, Globals.ToAbrasive, Globals.ForgeAbrasivePage)); }); ActionSequenceTree checkTakeAbrasive = new ActionSequenceTree( () => { Console.WriteLine("[checkTakeAbrasive]"); AddSubJob(new JobTryFindSubImage(_form, Globals.TakeAbrasiveImg)); }); ActionSequenceTree takeAbrasive = new ActionSequenceTree( () => { Console.WriteLine("[takeAbrasive]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.TakeAbrasive, true)); AddSubJob(new JobWaitTime(_form, 500, true)); }); ActionSequenceTree checkMakeAbrasive = new ActionSequenceTree( () => { Console.WriteLine("[checkMakeAbrasive]"); AddSubJob(new JobWaitTime(_form, 750, true)); AddSubJob(new JobTryFindSubImage(_form, Globals.MakeAbrasiveImg, 5, 500)); AddSubJob(new JobWaitTime(_form, 750, true)); }); ActionSequenceTree makeAbrasive = new ActionSequenceTree(() => { Console.WriteLine("[makeAbrasive]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.TakeAbrasive, true)); AddSubJob(new JobWaitTime(_form, 500, true)); }); ActionSequenceTree backToForge = new ActionSequenceTree(() => { Console.WriteLine("[backToForge]"); AddSubJob(new JobMovePage(_form, Globals.ForgeAbrasivePage, Globals.BackInForgeAbrasive, Globals.ForgePage)); }); ActionSequenceTree backToMenu = new ActionSequenceTree(() => { Console.WriteLine("[backToMenu]"); AddSubJob(new JobMovePage(_form, Globals.ForgePage, Globals.BackInForge, Globals.MenuPage)); }); ActionSequenceTree backToMain = new ActionSequenceTree(() => { Console.WriteLine("[backToMain]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.BackInMenu, Globals.MainPage)); }); // on repair ActionSequenceTree exitForgeAbrasiveGem = new ActionSequenceTree(() => { Console.WriteLine("[exitForgeAbrasiveGem]"); AddSubJob(new JobMovePage(_form, Globals.ForgeAbrasiveGemPage, Globals.NoInForgeAbrasiveGemPage, Globals.ForgeAbrasivePage)); }); ActionSequenceTree exitForgeAbrasiveRestrict = new ActionSequenceTree(() => { Console.WriteLine("[exitForgeAbrasiveRestrict]"); AddSubJob(new JobMovePage(_form, Globals.ForgeAbrasiveRestrictedPage, Globals.NoInForgeAbrasiveRestrictedPage, Globals.ForgeAbrasivePage)); }); fromMain.Completed = fromMenu; fromMenu.Completed = fromForge; fromForge.Completed = checkTakeAbrasive; checkTakeAbrasive.Completed = takeAbrasive; checkTakeAbrasive.ActionOnCompleted = () => { _returnState = State.Completed; }; checkTakeAbrasive.Failed = checkMakeAbrasive; takeAbrasive.Completed = checkMakeAbrasive; checkMakeAbrasive.Completed = makeAbrasive; checkMakeAbrasive.Failed = backToForge; makeAbrasive.Completed = backToForge; backToForge.Completed = backToMenu; backToMenu.Completed = backToMain; _currentAction = fromMain; // make repair map _repairMap[Globals.MenuPage] = fromMenu; _repairMap[Globals.ForgePage] = fromForge; _repairMap[Globals.ForgeAbrasivePage] = checkTakeAbrasive; _repairMap[Globals.ForgeAbrasiveGemPage] = exitForgeAbrasiveGem; _repairMap[Globals.ForgeAbrasiveRestrictedPage] = exitForgeAbrasiveRestrict; }
protected override void MakeActionSequenceTree() { // make action sequence tree ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Menu, Globals.MenuPage)); }); ActionSequenceTree fromMenu = new ActionSequenceTree(() => { Console.WriteLine("[fromMenu]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.MenuToGuild, Globals.GuildPage)); }); ActionSequenceTree fromGuild = new ActionSequenceTree(() => { Console.WriteLine("[fromGuild]"); }); ActionSequenceTree checkFishingPage = new ActionSequenceTree(() => { Console.WriteLine("[checkFishingPage]"); AddSubJob(new JobCheckPage(_form, Globals.FishingPage, 750)); }); ActionSequenceTree checkBreakAway = new ActionSequenceTree(() => { Console.WriteLine("[checkBreakAway]"); AddSubJob(new JobCheckCondition(_form, () => { return(_drag2Cnt > 25); })); }); ActionSequenceTree exitFishingByBreakAway = new ActionSequenceTree(() => { Console.WriteLine("[exitFishingByBreakAway]"); AddSubJob(new JobMovePage(_form, _form.CurrentPageName, Globals.ToMainPageFromFishing, Globals.MainPage)); }); ActionSequenceTree checkCondition = new ActionSequenceTree(() => { Console.WriteLine("[checkCondition]"); AddSubJob(new JobCheckCondition(_form, () => { return(_drag1Cnt > 10); })); }); ActionSequenceTree drag1 = new ActionSequenceTree(() => { Console.WriteLine("[drag1]"); if (_form.CurrentPageName != Globals.FishingPage) { DragJoystick(_form, this, new System.Drawing.Point(-50, 40)); _drag1Cnt++; } }); ActionSequenceTree drag2 = new ActionSequenceTree(() => { Console.WriteLine("[drag2]"); if (_form.CurrentPageName != Globals.FishingPage) { if (_drag2Cnt == 0) { DragJoystick(_form, this, new System.Drawing.Point(15, -60)); } else { DragJoystick(_form, this, new System.Drawing.Point(-50, -60)); } _drag2Cnt++; } }); ActionSequenceTree goToFishing = new ActionSequenceTree(() => { Console.WriteLine("[goToFishing]"); AddSubJob(new JobMovePage(_form, Globals.FishingPage, Globals.GoToFishing, Globals.FishingInPage)); }); ActionSequenceTree readyToFish = new ActionSequenceTree(() => { Console.WriteLine("[readyToFish]"); _fishingStartTime = DateTime.Now; AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, _bait, true)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.GetList, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree findForCheckNotFishing = new ActionSequenceTree( () => { Console.WriteLine("[findForCheckNotFishing]"); AddSubJob(new JobTryFindSubImage(_form, Globals.StartFishingImg)); }); ActionSequenceTree clickToStartFishing = new ActionSequenceTree(() => { Console.WriteLine("[clickToStartFishing]"); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.StartFishing, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree checkFinish = new ActionSequenceTree(() => { Console.WriteLine("[checkFinish] fishingElapsed : " + _fishingElapsed + " drag2Cnt : " + _drag2Cnt); AddSubJob(new JobCheckCondition(_form, () => { return(_fishingElapsed > _fishingTime); })); }); ActionSequenceTree exitFishing = new ActionSequenceTree(() => { Console.WriteLine("[exitFishing]"); AddSubJob(new JobMovePage(_form, Globals.FishingInPage, Globals.StopFishing, Globals.FishingFinishPage)); AddSubJob(new JobMovePage(_form, Globals.FishingFinishPage, Globals.YesInFishingFinishPage, Globals.FishingPage)); AddSubJob(new JobMovePage(_form, Globals.FishingPage, Globals.ToMainPageFromFishing, Globals.MainPage)); }); fromMain.Completed = fromMenu; fromMenu.Completed = fromGuild; fromGuild.Completed = checkBreakAway; checkBreakAway.Completed = exitFishingByBreakAway; exitFishingByBreakAway.Completed = null; checkBreakAway.Failed = checkFishingPage; checkFishingPage.Completed = goToFishing; checkFishingPage.Failed = checkCondition; checkCondition.Completed = drag2; checkCondition.Failed = drag1; drag1.Completed = checkBreakAway; drag2.Completed = checkBreakAway; goToFishing.Completed = readyToFish; readyToFish.Completed = findForCheckNotFishing; findForCheckNotFishing.Completed = clickToStartFishing; clickToStartFishing.Completed = findForCheckNotFishing; findForCheckNotFishing.Failed = checkFinish; checkFinish.Failed = checkFinish; checkFinish.Completed = exitFishing; exitFishing.Completed = null; exitFishing.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map //_repairMap[Globals.TraversePage] = fromTraverse; //_repairMap[Globals.WeekDungeonPage] = fromWeek; //_repairMap[Globals.WeekDungeonResultPage] = fromResult; }
protected override void MakeActionSequenceTree() { // make action sequence tree ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Traverse, Globals.TraversePage)); }); ActionSequenceTree fromTraverse = new ActionSequenceTree(() => { Console.WriteLine("[fromTraverse]"); AddSubJob(new JobMovePage(_form, Globals.TraversePage, Globals.GoldDungeon, Globals.GoldDungeonPage)); }); ActionSequenceTree fromGold = new ActionSequenceTree(() => { Console.WriteLine("[fromGold]"); OpenCvSharp.Rect left; bool leftFlag = _form.AllUIRects.TryGetValue(Globals.GoldDragLeftPos, out left); OpenCvSharp.Rect right; bool rightFlag = _form.AllUIRects.TryGetValue(Globals.GoldDragRightPos, out right); if (leftFlag && rightFlag) { var start = Utils.RectToPos(right.X, right.Y, right.Width, right.Height); var end = Utils.RectToPos(left.X, left.Y, left.Width, left.Height); AddSubJob(new JobDrag(_form, start, end)); } AddSubJob(new JobWaitTime(_form, 2000)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.GLevel5, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.GLevel5, true)); AddSubJob(new JobWaitTime(_form, 750)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.GLevel5, true)); AddSubJob(new JobWaitTime(_form, 750)); }); ActionSequenceTree checkGoldDungeonPage = new ActionSequenceTree(() => { Console.WriteLine("[checkGoldDungeonPage]"); AddSubJob(new JobCheckPage(_form, Globals.GoldDungeonPage)); }); ActionSequenceTree exitGoldDungeonPage = new ActionSequenceTree(() => { Console.WriteLine("[exitGoldDungeonPage]"); AddSubJob(new JobMovePage(_form, Globals.GoldDungeonPage, Globals.BackInGoldDungeon, Globals.MainPage)); }); ActionSequenceTree fromResult = new ActionSequenceTree(() => { Console.WriteLine("[fromResult]"); AddSubJob(new JobMovePage(_form, Globals.GoldDungeonResultPage, Globals.ToMainFromGoldResult, Globals.MainPage)); }); fromMain.Completed = fromTraverse; fromTraverse.Completed = fromGold; fromGold.Completed = checkGoldDungeonPage; checkGoldDungeonPage.Completed = exitGoldDungeonPage; exitGoldDungeonPage.ActionOnCompleted = () => { _status = State.Failed; }; checkGoldDungeonPage.Failed = fromResult; fromResult.ActionOnCompleted = () => { _status = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.TraversePage] = fromTraverse; _repairMap[Globals.GoldDungeonPage] = fromGold; _repairMap[Globals.GoldDungeonResultPage] = fromResult; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Cowork, Globals.CoworkPage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.CoworkPage })); AddSubJob(new JobMovePage(_form, Globals.CoworkPage, Globals.Party, Globals.PartyPage)); }); ActionSequenceTree dragForFindLevel = new ActionSequenceTree( () => { OpenCvSharp.Rect left; bool leftFlag = _form.AllUIRects.TryGetValue(Globals.RaidDragLeftPos, out left); OpenCvSharp.Rect right; bool rightFlag = _form.AllUIRects.TryGetValue(Globals.RaidDragRightPos, out right); if (leftFlag && rightFlag) { if (_level == Globals.PLevel1 || _level == Globals.PLevel2) { var start = Utils.RectToPos(left.X, left.Y, left.Width, left.Height); var end = Utils.RectToPos(right.X, right.Y, right.Width, right.Height); AddSubJob(new JobDrag(_form, start, end)); } else { var start = Utils.RectToPos(right.X, right.Y, right.Width, right.Height); var end = Utils.RectToPos(left.X, left.Y, left.Width, left.Height); AddSubJob(new JobDrag(_form, start, end)); } } }); ActionSequenceTree findLevel = new ActionSequenceTree( () => { AddSubJob(new JobTryFindSubImage(_form, _level)); }); ActionSequenceTree clickLevel = new ActionSequenceTree( () => { OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); var pos = Utils.RectToPos(rect.X, rect.Y, rect.Width, rect.Height); AddSubJob(new JobMoveAndClickMouse(_form, pos)); }); ActionSequenceTree fromParty = new ActionSequenceTree(() => { Console.WriteLine("[fromParty]"); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.PartyAward, true)); AddSubJob(new JobWaitTime(_form, 1000)); }); ActionSequenceTree checkAwardPage = new ActionSequenceTree(() => { Console.WriteLine("[checkAwardPage]"); AddSubJob(new JobCheckPage(_form, Globals.PartyRepeatAwardPage)); }); // if checkAwardPage completed ActionSequenceTree exitAwardPage = new ActionSequenceTree(() => { AddSubJob( new JobMovePage( _form, Globals.PartyRepeatAwardPage, Globals.OutFromRepeatAward, Globals.PartyPage)); }); ActionSequenceTree clickStart = new ActionSequenceTree(() => { Console.WriteLine("[clickStart]"); AddSubJob(new JobMovePage(_form, Globals.PartyPage, Globals.StartParty, new string[] { Globals.PartyRestrictedPage, Globals.UnknownPage })); }); ActionSequenceTree checkPartyRestricted = new ActionSequenceTree(() => { Console.WriteLine("[checkPartyRestricted]"); AddSubJob(new JobCheckPage(_form, Globals.PartyRestrictedPage)); }); // if checkPartyRestricted completed ActionSequenceTree exitPartyRestrictedPage = new ActionSequenceTree(() => { Console.WriteLine("[exitPartyRestrictedPage]"); AddSubJob( new JobMovePage( _form, Globals.PartyRestrictedPage, Globals.NoInPartyRestrictedPage, Globals.PartyPage)); }); ActionSequenceTree exitPartyPage = new ActionSequenceTree(() => { Console.WriteLine("[exitPartyPage]"); AddSubJob(new JobMovePage(_form, Globals.PartyPage, Globals.BackInParty, Globals.MainPage)); }); ActionSequenceTree fromStarted = new ActionSequenceTree(() => { Console.WriteLine("[fromStarted]"); AddSubJob( new JobCheckUntilMeetPage( _form, new string[] { Globals.PartyResultPage })); }); ActionSequenceTree fromResult = new ActionSequenceTree(() => { Console.WriteLine("[fromResult]"); AddSubJob(new JobMovePage(_form, Globals.PartyResultPage, Globals.ToMainFromPartyResult, Globals.MainPage)); }); if (_form.SkipPartyLevelSelect) { fromMain.Completed = fromParty; } else { fromMain.Completed = dragForFindLevel; dragForFindLevel.Completed = findLevel; findLevel.Completed = clickLevel; clickLevel.Completed = fromParty; } fromParty.Completed = checkAwardPage; checkAwardPage.Completed = exitAwardPage; checkAwardPage.Failed = clickStart; exitAwardPage.Completed = clickStart; clickStart.Completed = checkPartyRestricted; checkPartyRestricted.Completed = exitPartyRestrictedPage; checkPartyRestricted.Failed = fromStarted; exitPartyRestrictedPage.Completed = exitPartyPage; fromStarted.Completed = fromResult; fromResult.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.CoworkPage] = fromMain; _repairMap[Globals.PartyPage] = fromParty; _repairMap[Globals.PartyRepeatAwardPage] = exitAwardPage; _repairMap[Globals.PartyRestrictedPage] = exitPartyRestrictedPage; _repairMap[Globals.PartyResultPage] = fromResult; }
protected override void MakeActionSequenceTree() { ActionSequenceTree checkEmulatorPage = new ActionSequenceTree(() => { Console.WriteLine("[checkEmulatorPage]"); AddSubJob(new JobCheckPage(_form, Globals.EmulatorPage)); }); ActionSequenceTree killProcess = new ActionSequenceTree(() => { Console.WriteLine("[killProcess]"); AddSubJob(new JobKillProcess(_form, MainForm.VirtualMachineProcess)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobCheckCondition( _form, () => { MainForm.HookStates hookState; _form.HookProcessHandle(MainForm.VirtualMachineProcess, out hookState); return(hookState == MainForm.HookStates.NoProcess); })); }); ActionSequenceTree restartEmulator = new ActionSequenceTree(() => { Console.WriteLine("[restartEmulator]"); AddSubJob(new JobExecuteProcess(_form, MainForm.VirtualMachineProcess)); }); ActionSequenceTree fromEmulator = new ActionSequenceTree(() => { Console.WriteLine("[fromEmulator]"); AddSubJob(new JobWaitTime(_form, 3000)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.EmulatorPage })); AddSubJob(new JobMovePage(_form, Globals.EmulatorPage, Globals.StartDarkAvenger3, Globals.StartGamePage)); }); // Login ActionSequenceTree fromLogin = new ActionSequenceTree(() => { Console.WriteLine("[fromLogin]"); AddSubJob(new JobMovePage(_form, Globals.LoginPage, Globals.Facebook, Globals.FacebookPage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.FacebookPage })); }); /*ActionSequenceTree fromFacebookLogin = * new ActionSequenceTree(() => * { * Console.WriteLine("[fromFacebookLogin]"); * * AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.EmailInFacebook, true)); * AddSubJob(new JobWaitTime(_form, 1000)); * * AddSubJob(new JobPressKeyboard(_form, _email)); * AddSubJob(new JobWaitTime(_form, 500)); * * AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.PasswordInFacebook, true)); * AddSubJob(new JobWaitTime(_form, 1000)); * * AddSubJob(new JobPressKeyboard(_form, _password)); * AddSubJob(new JobWaitTime(_form, 500)); * * AddSubJob(new JobMovePage(_form, Globals.FacebookPage, Globals.LoginInFacebook, Globals.FacebookConfirmPage, 2000, 2000)); * * AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.FacebookConfirmPage })); * });*/ ActionSequenceTree findLoginEmail = new ActionSequenceTree(() => { Console.WriteLine("[findLoginEmail]"); AddSubJob(new JobTryFindSubImage(_form, Globals.LoginPhoneImg)); }); ActionSequenceTree clickLoginEmail = new ActionSequenceTree(() => { Console.WriteLine("[clickLoginEmail]"); OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); int addX = 0; int addY = 0; var pos = Utils.RectToPos(rect.X + addX, rect.Y + addY, rect.Width, rect.Height); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobPressKeyboard(_form, _email)); AddSubJob(new JobWaitTime(_form, 500)); }); ActionSequenceTree findLoginPassword = new ActionSequenceTree(() => { Console.WriteLine("[findLoginPassword]"); AddSubJob(new JobTryFindSubImage(_form, Globals.LoginPasswordImg)); }); ActionSequenceTree clickLoginPassword = new ActionSequenceTree(() => { Console.WriteLine("[clickLoginEmail]"); OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); int addX = 0; int addY = 0; var pos = Utils.RectToPos(rect.X + addX, rect.Y + addY, rect.Width, rect.Height); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 1000)); AddSubJob(new JobPressKeyboard(_form, _password)); AddSubJob(new JobWaitTime(_form, 500)); }); ActionSequenceTree findLoginButton = new ActionSequenceTree(() => { Console.WriteLine("[findLoginButton]"); AddSubJob(new JobTryFindSubImage(_form, Globals.LoginButtonImg)); }); ActionSequenceTree clickLoginButton = new ActionSequenceTree(() => { Console.WriteLine("[clickLoginButton]"); OpenCvSharp.Rect rect = (OpenCvSharp.Rect)BlackBoard.Instance.Read(BlackBoard.UIRectBlackBoardID, this); int addX = 0; int addY = 0; var pos = Utils.RectToPos(rect.X + addX, rect.Y + addY, rect.Width, rect.Height); AddSubJob(new JobWaitTime(_form, 500)); AddSubJob(new JobMoveAndClickMouse(_form, pos)); AddSubJob(new JobWaitTime(_form, 3000)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.FacebookConfirmPage })); }); ActionSequenceTree fromFacebookConfirm = new ActionSequenceTree(() => { Console.WriteLine("[fromFacebookConfirm]"); AddSubJob(new JobMovePage(_form, Globals.FacebookConfirmPage, Globals.YesInFacebook, Globals.StartGamePage)); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.StartGamePage })); }); // Login end ActionSequenceTree fromStartGame = new ActionSequenceTree(() => { Console.WriteLine("[fromStartGame]"); AddSubJob(new JobMovePage(_form, Globals.StartGamePage, Globals.ClickOnStartGamePage, Globals.CharacterSelectPage)); }); ActionSequenceTree fromCharacterSelect = new ActionSequenceTree(() => { Console.WriteLine("[fromCharacterSelect]"); AddSubJob(new JobMovePage(_form, Globals.CharacterSelectPage, Globals.StartGameInSelectPage, new string[] { Globals.NotifyPage, Globals.EventPage1, Globals.EventPage2, Globals.MainPage })); }); ActionSequenceTree closeEventPage1 = new ActionSequenceTree(() => { Console.WriteLine("[closeEventPage1]"); AddSubJob(new JobMovePage(_form, Globals.EventPage1, Globals.OutFromEventPage1, new string[] { Globals.EventPage2, Globals.EventPage3, Globals.NotifyPage, Globals.MainPage })); }); ActionSequenceTree closeEventPage2 = new ActionSequenceTree(() => { Console.WriteLine("[closeEventPage2]"); AddSubJob(new JobMovePage(_form, Globals.EventPage2, Globals.OutFromEventPage2, new string[] { Globals.EventPage3, Globals.NotifyPage, Globals.MainPage })); }); ActionSequenceTree closeEventPage3 = new ActionSequenceTree(() => { Console.WriteLine("[closeEventPage3]"); AddSubJob(new JobMovePage(_form, Globals.EventPage3, Globals.OutFromEventPage3, new string[] { Globals.NotifyPage, Globals.MainPage })); }); ActionSequenceTree closeNotifyPage = new ActionSequenceTree(() => { Console.WriteLine("[closeNotifyPage]"); AddSubJob(new JobMovePage(_form, Globals.NotifyPage, Globals.CloseNotify, Globals.MainPage)); }); checkEmulatorPage.Completed = fromEmulator; checkEmulatorPage.Failed = killProcess; killProcess.Completed = restartEmulator; killProcess.Failed = killProcess; restartEmulator.Completed = fromEmulator; fromEmulator.Completed = fromStartGame; fromStartGame.Completed = fromCharacterSelect; fromCharacterSelect.Completed = closeEventPage1; closeEventPage1.Completed = closeEventPage2; closeEventPage2.Completed = closeEventPage3; closeEventPage3.Completed = closeNotifyPage; closeNotifyPage.ActionOnCompleted = () => { _returnState = State.Completed; }; // will be executed only after repair fromLogin.Completed = findLoginEmail; findLoginEmail.Completed = clickLoginEmail; findLoginEmail.Failed = null; clickLoginEmail.Completed = findLoginPassword; findLoginPassword.Completed = clickLoginPassword; findLoginPassword.Failed = null; clickLoginPassword.Completed = findLoginButton; findLoginButton.Completed = clickLoginButton; findLoginButton.Failed = null; clickLoginButton.Completed = fromFacebookConfirm; fromFacebookConfirm.Completed = fromStartGame; _currentAction = checkEmulatorPage; // make repair map _repairMap[Globals.EmulatorPage] = fromEmulator; _repairMap[Globals.LoginPage] = fromLogin; _repairMap[Globals.FacebookPage] = findLoginEmail; _repairMap[Globals.FacebookConfirmPage] = fromFacebookConfirm; _repairMap[Globals.StartGamePage] = fromStartGame; _repairMap[Globals.CharacterSelectPage] = fromCharacterSelect; _repairMap[Globals.EventPage1] = closeEventPage1; _repairMap[Globals.EventPage2] = closeEventPage2; _repairMap[Globals.EventPage3] = closeEventPage3; _repairMap[Globals.NotifyPage] = closeNotifyPage; }
protected override void MakeActionSequenceTree() { ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Fight, Globals.FightPage)); }); ActionSequenceTree fromFight = new ActionSequenceTree(() => { Console.WriteLine("[fromFight]"); AddSubJob(new JobMovePage(_form, Globals.FightPage, Globals.ToCompeteBattle, Globals.CompeteBattlePage)); }); ActionSequenceTree fromCompete = new ActionSequenceTree(() => { Console.WriteLine("[fromCompete]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.RewardCompeteBattle)); AddSubJob(new JobWaitTime(_form, 1000, true)); AddSubJob(new JobCheckPage(_form, Globals.CompeteBattleRewardPage)); }); ActionSequenceTree exitReward = new ActionSequenceTree(() => { Console.WriteLine("[exitReward]"); AddSubJob(new JobMovePage(_form, Globals.CompeteBattleRewardPage, Globals.ToCompeteBattleFromReward, Globals.CompeteBattlePage)); }); ActionSequenceTree rewardRanking = new ActionSequenceTree(() => { Console.WriteLine("[rewardRanking]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.RewardRankingCompeteBattle)); AddSubJob(new JobWaitTime(_form, 1000, true)); AddSubJob(new JobCheckPage(_form, Globals.CompeteBattleRewardRankingPage)); }); ActionSequenceTree exitRewardRanking = new ActionSequenceTree(() => { Console.WriteLine("[exitRewardRanking]"); AddSubJob(new JobMovePage(_form, Globals.CompeteBattleRewardRankingPage, Globals.ToCompeteBattleFromRewardRanking, Globals.CompeteBattlePage)); }); ActionSequenceTree startCompete = new ActionSequenceTree(() => { Console.WriteLine("[startCompete]"); AddSubJob( new JobMovePage( _form, Globals.CompeteBattlePage, Globals.StartCompeteBattle2, new string[] { Globals.CompeteBattleRestrictedPage, Globals.UnknownPage })); }); ActionSequenceTree checkRestricted = new ActionSequenceTree(() => { Console.WriteLine("[checkRestricted]"); AddSubJob(new JobWaitTime(_form, 1500, true)); AddSubJob(new JobCheckPage(_form, Globals.CompeteBattleRestrictedPage)); }); ActionSequenceTree exitRestricted = new ActionSequenceTree(() => { Console.WriteLine("[exitRaidRestrictedPage]"); AddSubJob( new JobMovePage( _form, Globals.CompeteBattleRestrictedPage, Globals.NoInCompeteBattleRestrictedPage, Globals.CompeteBattlePage)); }); ActionSequenceTree exitCompeteBattle = new ActionSequenceTree(() => { Console.WriteLine("[exitCompeteBattle]"); AddSubJob( new JobMovePage( _form, Globals.CompeteBattlePage, Globals.ToMainFromCompeteBattle, Globals.MainPage)); }); ActionSequenceTree fromStarted = new ActionSequenceTree(() => { Console.WriteLine("[fromStarted]"); AddSubJob( new JobCheckUntilMeetPage( _form, new string[] { Globals.CompeteBattleResultPage })); }); ActionSequenceTree fromResult = new ActionSequenceTree(() => { Console.WriteLine("[fromResult]"); AddSubJob(new JobMovePage(_form, Globals.CompeteBattleResultPage, Globals.ToMainFromCompeteBattleResult, Globals.MainPage)); }); fromMain.Completed = fromFight; fromFight.Completed = fromCompete; fromCompete.Completed = exitReward; exitReward.Completed = rewardRanking; fromCompete.Failed = rewardRanking; rewardRanking.Completed = exitRewardRanking; rewardRanking.Failed = startCompete; exitRewardRanking.Completed = startCompete; startCompete.Completed = checkRestricted; checkRestricted.Completed = exitRestricted; checkRestricted.Failed = fromStarted; exitRestricted.Completed = exitCompeteBattle; exitCompeteBattle.ActionOnFailed = () => { _returnState = State.Failed; }; fromStarted.Completed = fromResult; fromResult.ActionOnCompleted = () => { _returnState = State.Completed; }; _currentAction = fromMain; // make repair map _repairMap[Globals.FightPage] = fromFight; _repairMap[Globals.CompeteBattlePage] = fromCompete; _repairMap[Globals.CompeteBattleRewardPage] = exitReward; _repairMap[Globals.CompeteBattleResultPage] = fromResult; _repairMap[Globals.CompeteBattleRestrictedPage] = exitRestricted; }
protected override void MakeActionSequenceTree() { // make action sequence tree ActionSequenceTree fromMain = new ActionSequenceTree(() => { Console.WriteLine("[fromMain]"); AddSubJob(new JobMovePage(_form, Globals.MainPage, Globals.Menu, Globals.MenuPage)); }); ActionSequenceTree checkMenu = new ActionSequenceTree(() => { Console.WriteLine("[checkMenu]"); AddSubJob(new JobCheckUntilMeetPage(_form, new string[] { Globals.MenuPage })); }); ActionSequenceTree fromMenu = new ActionSequenceTree(() => { Console.WriteLine("[fromMenu]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.MenuToQuest)); AddSubJob(new JobWaitTime(_form, 500, true)); }); ActionSequenceTree afterClickQuest = new ActionSequenceTree(() => { Console.WriteLine("[afterClickQuest]"); AddSubJob(new JobTryFindSubImage(_form, Globals.QuestUISetImg)); }); ActionSequenceTree fromWeekQuest = new ActionSequenceTree(() => { Console.WriteLine("[fromWeekQuest]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.MenuToWeekQuest, Globals.WeekQuestPage)); }); ActionSequenceTree checkCleared = new ActionSequenceTree( () => { Console.WriteLine("[checkCleared]"); AddSubJob(new JobTryFindSubImage(_form, Globals.MissionCompletedImg)); }); ActionSequenceTree getAward = new ActionSequenceTree( () => { Console.WriteLine("[getAward]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.MissionCompleted, true)); AddSubJob(new JobWaitTime(_form, 500, true)); }); ActionSequenceTree checkMission = new ActionSequenceTree( () => { Console.WriteLine("[checkMission]"); AddSubJob(new JobWaitTime(_form, 750, true)); AddSubJob(new JobTryFindSubImage(_form, Globals.GetMissionImg, 5, 500)); AddSubJob(new JobWaitTime(_form, 750, true)); }); ActionSequenceTree getMission = new ActionSequenceTree(() => { Console.WriteLine("[getMission]"); AddSubJob(new JobWaitTime(_form, 500, true)); AddSubJob(JobGenerator.CreateJobMoveAndClickMouse(_form, Globals.GetMission, true)); AddSubJob(new JobWaitTime(_form, 500, true)); }); ActionSequenceTree backToMenu = new ActionSequenceTree(() => { Console.WriteLine("[backToMenu]"); AddSubJob(new JobMovePage(_form, Globals.WeekQuestPage, Globals.BackInWeekQuest, Globals.MenuPage)); }); ActionSequenceTree backToMain = new ActionSequenceTree(() => { Console.WriteLine("[backToMain]"); AddSubJob(new JobMovePage(_form, Globals.MenuPage, Globals.BackInMenu, Globals.MainPage)); }); fromMain.Completed = checkMenu; checkMenu.Completed = fromMenu; fromMenu.Completed = afterClickQuest; afterClickQuest.Completed = fromWeekQuest; afterClickQuest.Failed = backToMain; fromWeekQuest.Completed = checkCleared; checkCleared.Completed = getAward; checkCleared.Failed = checkMission; getAward.Completed = checkMission; getAward.ActionOnCompleted = () => { _returnState = State.Completed; }; checkMission.Completed = getMission; checkMission.Failed = backToMenu; getMission.Completed = backToMenu; backToMenu.Completed = backToMain; _currentAction = fromMain; // make repair map _repairMap[Globals.MenuPage] = fromMenu; _repairMap[Globals.WeekQuestPage] = fromWeekQuest; }