Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05174c37c2 | ||
|
|
4f0ffc3980 | ||
|
|
0a86f4726f |
No files matched your search
@@ -2,4 +2,5 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=chyan/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=enkanomiya/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=mirrorchan/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=onslaugh/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=steambird/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -19,6 +19,7 @@ using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.AutoArtifactSalvage;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
@@ -151,6 +152,12 @@ public partial class AllConfig : ObservableObject
|
||||
/// 自动秘境配置
|
||||
/// </summary>
|
||||
public AutoDomainConfig AutoDomainConfig { get; set; } = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动秘境配置
|
||||
/// </summary>
|
||||
public AutoStygianOnslaughtConfig AutoStygianOnslaughtConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动分解圣遗物配置
|
||||
|
||||
@@ -195,7 +195,6 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
|
||||
private static void SimpleCloneRepository(string repoUrl, string repoPath, CheckoutProgressHandler? onCheckoutProgress)
|
||||
{
|
||||
// 使用浅克隆选项
|
||||
var options = new CloneOptions
|
||||
{
|
||||
Checkout = true,
|
||||
@@ -203,7 +202,7 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
RecurseSubmodules = false, // 不递归克隆子模块
|
||||
OnCheckoutProgress = onCheckoutProgress
|
||||
};
|
||||
options.FetchOptions.Depth = 1; // 浅克隆,只获取最新的提交
|
||||
// options.FetchOptions.Depth = 1; // 浅克隆,只获取最新的提交
|
||||
// 克隆仓库
|
||||
Repository.Clone(repoUrl, repoPath, options);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoDomain.Model;
|
||||
|
||||
@@ -52,4 +53,35 @@ public class ResinUseRecord
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ResinUseRecord> BuildFromDomainParam(AutoStygianOnslaughtConfig taskParam)
|
||||
{
|
||||
List<ResinUseRecord> list = [];
|
||||
if (taskParam.SpecifyResinUse)
|
||||
{
|
||||
if (taskParam.CondensedResinUseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("浓缩树脂", taskParam.CondensedResinUseCount));
|
||||
}
|
||||
if (taskParam.OriginalResinUseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("原粹树脂", taskParam.OriginalResinUseCount));
|
||||
}
|
||||
if (taskParam.TransientResinUseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("须臾树脂", taskParam.TransientResinUseCount));
|
||||
}
|
||||
if (taskParam.FragileResinUseCount > 0)
|
||||
{
|
||||
list.Add(new ResinUseRecord("脆弱树脂", taskParam.FragileResinUseCount));
|
||||
}
|
||||
|
||||
if (list.Count == 0)
|
||||
{
|
||||
throw new Exception("你选择了指定树脂刷取次数,请至少配置一种树脂的刷取次数!");
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ public partial class AutoPickTrigger : ITaskTrigger
|
||||
speedTimer.DebugPrint();
|
||||
}
|
||||
|
||||
private static Rect GetWhiteTextBoundingRect(Mat textMat)
|
||||
public static Rect GetWhiteTextBoundingRect(Mat textMat)
|
||||
{
|
||||
// 预处理提取纯白色文字
|
||||
var processedMat = new Mat();
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
[Serializable]
|
||||
public partial class AutoStygianOnslaughtConfig : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _strategyName = "";
|
||||
|
||||
// 结束后是否自动分解圣遗物
|
||||
[ObservableProperty]
|
||||
private bool _autoArtifactSalvage = false;
|
||||
|
||||
// 指定树脂的使用次数
|
||||
[ObservableProperty]
|
||||
private bool _specifyResinUse = false;
|
||||
|
||||
// 自定义使用树脂优先级
|
||||
[ObservableProperty]
|
||||
private List<string> _resinPriorityList =
|
||||
[
|
||||
"浓缩树脂",
|
||||
"原粹树脂"
|
||||
];
|
||||
|
||||
// 使用原粹树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _originalResinUseCount = 0;
|
||||
|
||||
//使用浓缩树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _condensedResinUseCount = 0;
|
||||
|
||||
// 使用须臾树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _transientResinUseCount = 0;
|
||||
|
||||
// 使用脆弱树脂刷取副本次数
|
||||
[ObservableProperty]
|
||||
private int _fragileResinUseCount = 0;
|
||||
}
|
||||
@@ -0,0 +1,521 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoArtifactSalvage;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
|
||||
public class AutoStygianOnslaughtTask : ISoloTask
|
||||
{
|
||||
public string Name => "自动幽境危战";
|
||||
|
||||
private readonly AutoStygianOnslaughtConfig _taskParam;
|
||||
|
||||
private readonly CombatScriptBag _combatScriptBag;
|
||||
|
||||
private CancellationToken _ct;
|
||||
|
||||
|
||||
private List<ResinUseRecord> _resinPriorityListWhenSpecifyUse;
|
||||
|
||||
private LowerHeadThenWalkToTask? _lowerHeadThenWalkToTask;
|
||||
|
||||
public AutoStygianOnslaughtTask(AutoStygianOnslaughtConfig taskParam, string path)
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
_taskParam = taskParam;
|
||||
|
||||
_combatScriptBag = CombatScriptParser.ReadAndParse(path);
|
||||
|
||||
_resinPriorityListWhenSpecifyUse = ResinUseRecord.BuildFromDomainParam(taskParam);
|
||||
}
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
_lowerHeadThenWalkToTask = new LowerHeadThenWalkToTask("chest_tip.png", 20000);
|
||||
_ct = ct;
|
||||
|
||||
Init();
|
||||
Notify.Event(NotificationEvent.DomainStart).Success($"{Name}启动");
|
||||
|
||||
await DoDomain();
|
||||
|
||||
|
||||
await Delay(2000, ct);
|
||||
await Bv.WaitForMainUi(_ct, 30);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await ArtifactSalvage();
|
||||
Notify.Event(NotificationEvent.DomainEnd).Success($"{Name}结束");
|
||||
}
|
||||
|
||||
private async Task DoDomain()
|
||||
{
|
||||
// 前置进入秘境
|
||||
await EnterDomain();
|
||||
|
||||
for (var i = 0; i < 9999; i++)
|
||||
{
|
||||
// 确认载入
|
||||
bool res = await Bv.WaitUntilFound(ElementAssets.Instance.LeylineDisorderIconRo, _ct, 60);
|
||||
if (!res)
|
||||
{
|
||||
throw new Exception("幽境危战进入秘境失败!");
|
||||
}
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
{
|
||||
throw new Exception("识别队伍角色失败!");
|
||||
}
|
||||
|
||||
// 0. 切换到第一个角色
|
||||
var combatCommands = FindCombatScriptAndSwitchAvatar(combatScenes);
|
||||
|
||||
await Delay(2950, _ct); // 开始的三秒计时
|
||||
// 走到boss前面
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
await Delay(1200, _ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
|
||||
|
||||
// 2. 执行战斗(战斗线程、视角线程、检测战斗完成线程)
|
||||
Logger.LogInformation($"{Name}:{{Text}}", "2. 执行战斗策略");
|
||||
await StartFight(combatScenes, combatCommands);
|
||||
await Delay(500, _ct);
|
||||
|
||||
// 3.判断是否成功(存在确认按钮就是失败)
|
||||
using var ra = CaptureToRectArea();
|
||||
if (ra.Find(ElementAssets.Instance.BtnWhiteConfirm).IsExist())
|
||||
{
|
||||
Logger.LogWarning($"{Name}:{{Text}}", "挑战失败,重试!");
|
||||
Bv.ClickWhiteCancelButton(ra);
|
||||
continue;
|
||||
}
|
||||
|
||||
Bv.ClickWhiteCancelButton(ra); // 点击返回后是主角
|
||||
await Bv.WaitUntilFound(ElementAssets.Instance.LeylineDisorderIconRo, _ct);
|
||||
await Delay(6000, _ct); // 等待载入完成
|
||||
|
||||
// 4. 寻找地脉花
|
||||
Logger.LogInformation($"{Name}:{{Text}}", "3. 寻找地脉花");
|
||||
await _lowerHeadThenWalkToTask!.Start(_ct);
|
||||
Simulation.SendInput.Keyboard.KeyPress(AutoPickAssets.Instance.PickVk);
|
||||
|
||||
|
||||
// 5. 快速领取奖励并判断是否有下一轮
|
||||
Logger.LogInformation($"{Name}:{{Text}}", "5. 领取奖励");
|
||||
if (!await GettingTreasure())
|
||||
{
|
||||
Logger.LogInformation($"体力耗尽或者设置轮次已达标,{Name}");
|
||||
break;
|
||||
}
|
||||
|
||||
Notify.Event(NotificationEvent.DomainReward).Success($"{Name}奖励领取");
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
if (_taskParam.SpecifyResinUse)
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 指定使用树脂", $"{Name},");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 用尽所有浓缩树脂和原粹树脂后结束", $"{Name},");
|
||||
}
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
{
|
||||
var gameScreenSize = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
|
||||
if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
|
||||
{
|
||||
Logger.LogError($"游戏窗口分辨率不是 16:9 !当前分辨率为 {{Width}}x{{Height}} , 非 16:9 分辨率的游戏无法正常使用{Name}功能 !",
|
||||
gameScreenSize.Width, gameScreenSize.Height);
|
||||
throw new Exception("游戏窗口分辨率不是 16:9");
|
||||
}
|
||||
|
||||
if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
|
||||
{
|
||||
Logger.LogWarning($"游戏窗口分辨率小于 1920x1080 !当前分辨率为 {{Width}}x{{Height}} , 小于 1920x1080 的分辨率的游戏可能无法正常使用{Name}功能 !",
|
||||
gameScreenSize.Width, gameScreenSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task EnterDomain()
|
||||
{
|
||||
await Delay(300, _ct);
|
||||
var ra = CaptureToRectArea();
|
||||
|
||||
var ocrList = ra.FindMulti(RecognitionObject.OcrThis);
|
||||
if (ocrList.Any(o => o.Text.Contains("好友挑战")) && ocrList.Any(o => o.Text.Contains("开始挑战")))
|
||||
{
|
||||
// 幽境危战确认界面
|
||||
Bv.ClickWhiteConfirmButton(ra);
|
||||
|
||||
// 载入动画
|
||||
await Delay(3000, _ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("当前界面不是幽境危战{Msg1}界面,请注意是旅行者打开钥匙后弹出的界面!", "开始挑战");
|
||||
throw new NormalEndException("当前界面不是幽境危战开始挑战界面,请注意是旅行者打开钥匙后弹出的界面!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<CombatCommand> FindCombatScriptAndSwitchAvatar(CombatScenes combatScenes)
|
||||
{
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.GetAvatars());
|
||||
var avatar = combatScenes.SelectAvatar(combatCommands[0].Name);
|
||||
avatar?.SwitchWithoutCts();
|
||||
Sleep(200);
|
||||
return combatCommands;
|
||||
}
|
||||
|
||||
private Task StartFight(CombatScenes combatScenes, List<CombatCommand> combatCommands)
|
||||
{
|
||||
CancellationTokenSource cts = new();
|
||||
_ct.Register(cts.Cancel);
|
||||
combatScenes.BeforeTask(cts.Token);
|
||||
// 战斗操作
|
||||
var combatTask = new Task(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
{
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
command.Execute(combatScenes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogInformation("战斗操作中断:{Msg}", e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning(e.Message);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Logger.LogInformation("自动战斗线程结束");
|
||||
Simulation.ReleaseAllKey();
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 对局结束检测
|
||||
var domainEndTask = DomainEndDetectionTask(cts);
|
||||
combatTask.Start();
|
||||
domainEndTask.Start();
|
||||
return Task.WhenAll(combatTask, domainEndTask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对局结束检测
|
||||
/// </summary>
|
||||
private Task DomainEndDetectionTask(CancellationTokenSource cts)
|
||||
{
|
||||
return new Task(async () =>
|
||||
{
|
||||
await Bv.WaitUntilFound(ElementAssets.Instance.BtnWhiteCancel, cts.Token, 150, 1000);
|
||||
await cts.CancelAsync();
|
||||
}, cts.Token);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 领取奖励
|
||||
/// </summary>
|
||||
private async Task<bool> GettingTreasure()
|
||||
{
|
||||
bool isLastTurn = false;
|
||||
// 等待窗口弹出
|
||||
await Delay(300, _ct);
|
||||
|
||||
// 1. OCR 直到确认弹出框弹出
|
||||
bool chooseResinPrompt = await NewRetry.WaitForAction(() =>
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
var regionList = ra.FindMulti(RecognitionObject.Ocr(ra.Width * 0.25, ra.Height * 0.2, ra.Width * 0.5, ra.Height * 0.6));
|
||||
var res = regionList.FirstOrDefault(t => t.Text.Contains("地脉之花"));
|
||||
if (res != null)
|
||||
{
|
||||
// 解决水龙王按下左键后没松开,然后后续点击按下就没反应了,界面上点一下
|
||||
res.Click();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}, _ct, 10, 500);
|
||||
Debug.WriteLine("识别到选择树脂页");
|
||||
await Delay(800, _ct);
|
||||
|
||||
// 再 OCR 一次,弹出框,确认当前是否有原粹树脂
|
||||
using var ra2 = CaptureToRectArea();
|
||||
var textListInPrompt = ra2.FindMulti(RecognitionObject.Ocr(ra2.Width * 0.25, ra2.Height * 0.2, ra2.Width * 0.5, ra2.Height * 0.6));
|
||||
if (textListInPrompt.Any(t => t.Text.Contains("数量不足") || t.Text.Contains("补充原粹树脂")))
|
||||
{
|
||||
// 没有原粹树脂,直接退出秘境
|
||||
Logger.LogInformation("自动秘境:原粹树脂已用尽,退出秘境");
|
||||
await ExitDomain();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (chooseResinPrompt)
|
||||
{
|
||||
using var ra3 = CaptureToRectArea();
|
||||
|
||||
if (!_taskParam.SpecifyResinUse)
|
||||
{
|
||||
// 自动刷干树脂
|
||||
// 识别树脂状况
|
||||
var resinStatus = ResinStatus.RecogniseFromRegion(ra3);
|
||||
resinStatus.Print(Logger);
|
||||
|
||||
if (resinStatus is { CondensedResinCount: <= 0, OriginalResinCount: < 20 })
|
||||
{
|
||||
Logger.LogWarning("树脂不足");
|
||||
await ExitDomain();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool resinUsed = false;
|
||||
if (resinStatus.CondensedResinCount > 0)
|
||||
{
|
||||
resinUsed = PressUseResin(ra3, "浓缩树脂");
|
||||
resinStatus.CondensedResinCount -= 1;
|
||||
}
|
||||
else if (resinStatus.OriginalResinCount >= 20)
|
||||
{
|
||||
resinUsed = PressUseResin(ra3, "原粹树脂");
|
||||
resinStatus.OriginalResinCount -= 20;
|
||||
}
|
||||
|
||||
if (!resinUsed)
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未找到可用的树脂,可能是{Msg1} 或者 {Msg2}。", "树脂不足", "OCR 识别失败");
|
||||
await ExitDomain();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (resinStatus is { CondensedResinCount: <= 0, OriginalResinCount: < 20 })
|
||||
{
|
||||
// 没树脂了就是最后一回合了
|
||||
isLastTurn = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 指定使用树脂
|
||||
var textListInPrompt2 = ra3.FindMulti(RecognitionObject.Ocr(ra3.Width * 0.25, ra3.Height * 0.2, ra3.Width * 0.5, ra3.Height * 0.6));
|
||||
// 按优先级使用
|
||||
var failCount = 0;
|
||||
foreach (var record in _resinPriorityListWhenSpecifyUse)
|
||||
{
|
||||
if (record.RemainCount > 0 && PressUseResin(textListInPrompt2, record.Name))
|
||||
{
|
||||
record.RemainCount -= 1;
|
||||
Logger.LogInformation("自动秘境:{Name} 刷取 {Re}/{Max}", record.Name, record.MaxCount - record.RemainCount, record.MaxCount);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (_resinPriorityListWhenSpecifyUse.Sum(o => o.RemainCount) <= 0)
|
||||
{
|
||||
// 全部刷完
|
||||
isLastTurn = true;
|
||||
}
|
||||
|
||||
if (failCount == _resinPriorityListWhenSpecifyUse.Count)
|
||||
{
|
||||
// 没有找到对应的树脂
|
||||
Logger.LogWarning("自动秘境:指定树脂领取次数时,当前可用树脂选项无法满足配置。你可能设置的刷取次数过多!退出秘境。");
|
||||
Logger.LogInformation("当前刷取情况:{ResinList}", string.Join(", ", _resinPriorityListWhenSpecifyUse.Select(o => $"{o.Name}({o.MaxCount - o.RemainCount}/{o.MaxCount})")));
|
||||
await ExitDomain();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果没有选择树脂的提示,说明只有原粹树脂
|
||||
// 继续向下执行
|
||||
}
|
||||
|
||||
Sleep(1000, _ct);
|
||||
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
// 优先点击继续
|
||||
using var confirmRectArea = ra.Find(AutoFightAssets.Instance.ConfirmRa);
|
||||
if (!confirmRectArea.IsEmpty())
|
||||
{
|
||||
if (isLastTurn)
|
||||
{
|
||||
// 最后一回合 退出
|
||||
var exitRectArea = ra.Find(AutoFightAssets.Instance.ExitRa);
|
||||
if (!exitRectArea.IsEmpty())
|
||||
{
|
||||
exitRectArea.Click();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!chooseResinPrompt)
|
||||
{
|
||||
// TODO 前面没有弹框的情况下,意味着只有原粹树脂,要再识别一次右上角确认树脂余量,没有余量直接退出
|
||||
}
|
||||
|
||||
// 有体力继续
|
||||
confirmRectArea.Click();
|
||||
await Delay(60, _ct); // 双击
|
||||
confirmRectArea.Click();
|
||||
|
||||
if (!chooseResinPrompt)
|
||||
{
|
||||
// 真没树脂了还有提示兜底
|
||||
await Delay(900, _ct);
|
||||
var textListInNoResinPrompt = CaptureToRectArea().FindMulti(RecognitionObject.Ocr(ra2.Width * 0.25, ra2.Height * 0.2, ra2.Width * 0.5, ra2.Height * 0.6));
|
||||
if (textListInNoResinPrompt.Any(t => t.Text.Contains("是否仍要") && t.Text.Contains("挑战") && t.Text.Contains("秘境")))
|
||||
{
|
||||
var cancelBtn = textListInNoResinPrompt.FirstOrDefault(t => t.Text.Contains("取消"));
|
||||
if (cancelBtn != null)
|
||||
{
|
||||
cancelBtn.Click();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(300, _ct);
|
||||
}
|
||||
|
||||
throw new NormalEndException("未检测到秘境结束,可能是背包物品已满。");
|
||||
}
|
||||
|
||||
private async Task ExitDomain()
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE);
|
||||
await Delay(500, _ct);
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_ESCAPE);
|
||||
await Delay(800, _ct);
|
||||
Bv.ClickBlackConfirmButton(CaptureToRectArea());
|
||||
}
|
||||
|
||||
private bool PressUseResin(ImageRegion ra, string resinName)
|
||||
{
|
||||
var regionList = ra.FindMulti(RecognitionObject.Ocr(ra.Width * 0.25, ra.Height * 0.2, ra.Width * 0.5, ra.Height * 0.6));
|
||||
return PressUseResin(regionList, resinName);
|
||||
}
|
||||
|
||||
private bool PressUseResin(List<Region> regionList, string resinName)
|
||||
{
|
||||
var resinKey = regionList.FirstOrDefault(t => t.Text.Contains(resinName));
|
||||
if (resinKey != null)
|
||||
{
|
||||
// 找到树脂名称对应的按键,关键词为使用,是同一行的(高度相交)
|
||||
var useList = regionList.Where(t => t.Text.Contains("使用")).ToList();
|
||||
if (useList.Count != 0)
|
||||
{
|
||||
// 找到使用按键
|
||||
var useKey = useList.FirstOrDefault(t => t.X > TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect.Width / 2
|
||||
&& IsHeightOverlap(t, resinKey));
|
||||
if (useKey != null)
|
||||
{
|
||||
// 点击使用
|
||||
useKey.Click();
|
||||
// 解决水龙王按下左键后没松开,然后后续点击按下就没反应了。使用双击
|
||||
Sleep(60, _ct);
|
||||
useKey.Click();
|
||||
Logger.LogInformation("自动秘境:使用 {ResinName}", resinName);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未找到 {ResinName} 的使用按键", resinName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("自动秘境:未找到 {ResinName} 的使用按键", resinName);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断两个区域在垂直方向上是否有重叠
|
||||
/// </summary>
|
||||
private bool IsHeightOverlap(Region region1, Region region2)
|
||||
{
|
||||
int region1Top = region1.Y;
|
||||
int region1Bottom = region1.Y + region1.Height;
|
||||
int region2Top = region2.Y;
|
||||
int region2Bottom = region2.Y + region2.Height;
|
||||
|
||||
// 检查区域是否在垂直方向上重叠
|
||||
return (region1Top <= region2Bottom && region1Bottom >= region2Top);
|
||||
}
|
||||
|
||||
private async Task ArtifactSalvage()
|
||||
{
|
||||
if (!_taskParam.AutoArtifactSalvage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(TaskContext.Instance().Config.AutoArtifactSalvageConfig.MaxArtifactStar, out var star))
|
||||
{
|
||||
star = 4;
|
||||
}
|
||||
|
||||
await new AutoArtifactSalvageTask(star).Start(_ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.GameTask.AutoPick;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
|
||||
/// <summary>
|
||||
/// 一些基础图像识别操作
|
||||
/// </summary>
|
||||
public static partial class Bv
|
||||
{
|
||||
public static string FindFKeyText(ImageRegion region)
|
||||
{
|
||||
using var foundRectArea = region.Find(AutoPickAssets.Instance.PickRo);
|
||||
if (foundRectArea.IsEmpty())
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var scale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var textRect = new Rect(foundRectArea.X + (int)(115 * scale), foundRectArea.Y,
|
||||
(int)((400 - 115) * scale), foundRectArea.Height);
|
||||
if (textRect.X + textRect.Width > region.SrcMat.Width
|
||||
|| textRect.Y + textRect.Height > region.SrcMat.Height)
|
||||
{
|
||||
Debug.WriteLine("AutoPickTrigger: 文字区域 out of range");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var textMat = new Mat(region.SrcMat, textRect);
|
||||
var boundingRect = AutoPickTrigger.GetWhiteTextBoundingRect(textMat);
|
||||
// 如果找到有效区域
|
||||
if (boundingRect.Width > 5 && boundingRect.Height > 5)
|
||||
{
|
||||
// 截取只包含文字的区域
|
||||
var textOnlyMat = new Mat(textMat, new Rect(0, 0,
|
||||
boundingRect.Right + 3 < textMat.Width ? boundingRect.Right + 3 : textMat.Width, textMat.Height));
|
||||
return OcrFactory.Paddle.OcrWithoutDetector(textOnlyMat);
|
||||
}
|
||||
else
|
||||
{
|
||||
return OcrFactory.Paddle.Ocr(textMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 770 B |
@@ -43,7 +43,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
|
||||
public RecognitionObject EscMailReward;
|
||||
public RecognitionObject CollectRo;
|
||||
|
||||
|
||||
public RecognitionObject PageCloseWhiteRo;
|
||||
|
||||
public RecognitionObject SereniteaPotHomeRo;
|
||||
@@ -53,7 +53,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
public RecognitionObject SereniteaPotMoneyRo;
|
||||
public RecognitionObject SereniteapotPageClose;
|
||||
public RecognitionObject SereniteapotShopNumberBtn;
|
||||
|
||||
|
||||
public RecognitionObject AYuanClothRo;
|
||||
public RecognitionObject AYuanresinRo;
|
||||
public RecognitionObject SereniteapotExpBookRo;
|
||||
@@ -63,6 +63,8 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
public RecognitionObject AYuanExpBottleBigRo;
|
||||
public RecognitionObject AYuanExpBottleSmallRo;
|
||||
|
||||
public RecognitionObject LeylineDisorderIconRo;
|
||||
|
||||
private ElementAssets()
|
||||
{
|
||||
// 按钮
|
||||
@@ -211,7 +213,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "CondensedResinCount",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "condensed_resin_count.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, 0, CaptureRect.Width / 4, CaptureRect.Height /15),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, 0, CaptureRect.Width / 4, CaptureRect.Height / 15),
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
// 减少合成
|
||||
@@ -305,7 +307,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
RegionOfInterest = new Rect(0, CaptureRect.Height - CaptureRect.Height / 3, CaptureRect.Width / 4, CaptureRect.Height / 3),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
|
||||
PageCloseWhiteRo = new RecognitionObject
|
||||
{
|
||||
Name = "PageCloseWhite",
|
||||
@@ -321,7 +323,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "SereniteaPotHome",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "sereniteapot_home.png"),
|
||||
RegionOfInterest = new Rect(0, 0 , CaptureRect.Width, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
TeleportSereniteaPotHomeRo = new RecognitionObject
|
||||
@@ -329,7 +331,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "TeleportSereniteaPotHome",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "sereniteapot_home.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width/2, CaptureRect.Height / 2, CaptureRect.Width/2, CaptureRect.Height/2),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, CaptureRect.Height / 2, CaptureRect.Width / 2, CaptureRect.Height / 2),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanIconRo = new RecognitionObject
|
||||
@@ -355,7 +357,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "SereniteaPotMoneyRo",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "sereniteapot_money.png"),
|
||||
RegionOfInterest = new Rect( CaptureRect.Width / 2, CaptureRect.Height - CaptureRect.Height / 4, CaptureRect.Width / 4, CaptureRect.Height / 4),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, CaptureRect.Height - CaptureRect.Height / 4, CaptureRect.Width / 4, CaptureRect.Height / 4),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanExpBottleBigRo = new RecognitionObject
|
||||
@@ -363,7 +365,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "祝圣精华",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "exp_bottle_big.png"),
|
||||
RegionOfInterest = new Rect( 0, 0, CaptureRect.Width*7/10 , CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanExpBottleSmallRo = new RecognitionObject
|
||||
@@ -371,7 +373,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "祝圣油膏",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "exp_bottle_small.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
SereniteapotPageClose = new RecognitionObject
|
||||
@@ -379,7 +381,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "SereniteapotPageClose",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "sereniteapot_page_close.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2 , CaptureRect.Height /5, CaptureRect.Width/4, CaptureRect.Height/8),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, CaptureRect.Height / 5, CaptureRect.Width / 4, CaptureRect.Height / 8),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
SereniteapotShopNumberBtn = new RecognitionObject
|
||||
@@ -387,7 +389,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "SereniteapotShopNumberBtn",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "sereniteapot_shop_number_btn.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2 , CaptureRect.Height /2, CaptureRect.Width/2, CaptureRect.Height/2),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 2, CaptureRect.Height / 2, CaptureRect.Width / 2, CaptureRect.Height / 2),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
SereniteapotExpBookRo = new RecognitionObject
|
||||
@@ -395,7 +397,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "大英雄的经验",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "exp_book.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
SereniteapotExpBookSmallRo = new RecognitionObject
|
||||
@@ -403,7 +405,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "流浪者的经验",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "exp_book_small.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanClothRo = new RecognitionObject
|
||||
@@ -411,7 +413,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "布匹",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "ayuan_cloth.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanresinRo = new RecognitionObject
|
||||
@@ -419,7 +421,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "须臾树脂",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "ayuan_resin.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanMagicmineralprecisionRo = new RecognitionObject
|
||||
@@ -427,7 +429,7 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "精锻用魔矿",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "ayuan_magicmineralprecision.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
AYuanMOlaRo = new RecognitionObject
|
||||
@@ -435,7 +437,15 @@ public class ElementAssets : BaseAssets<ElementAssets>
|
||||
Name = "摩拉",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "ayuan_mola.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width*7/10, CaptureRect.Height),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width * 7 / 10, CaptureRect.Height),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
LeylineDisorderIconRo = new RecognitionObject
|
||||
{
|
||||
Name = "LeylineDisorderIcon",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "leyline_disorder_icon.png"),
|
||||
RegionOfInterest = new Rect(0, 0, (int)(200 * AssetScale), (int)(200 * AssetScale)),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Job;
|
||||
|
||||
/// <summary>
|
||||
/// 低头找指定图标
|
||||
/// </summary>
|
||||
public class LowerHeadThenWalkToTask
|
||||
{
|
||||
private RECT CaptureRect => TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
|
||||
private double AssetScale => TaskContext.Instance().SystemInfo.AssetScale;
|
||||
|
||||
private readonly RecognitionObject _trackPoint;
|
||||
|
||||
private int _timeoutMilliseconds;
|
||||
|
||||
|
||||
public LowerHeadThenWalkToTask(string targetMatName, int timeoutMilliseconds = 30000)
|
||||
{
|
||||
_timeoutMilliseconds = timeoutMilliseconds;
|
||||
_trackPoint = new RecognitionObject
|
||||
{
|
||||
Name = "TrackPoint",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", targetMatName),
|
||||
RegionOfInterest = new Rect((int)(300 * AssetScale), 0, CaptureRect.Width - (int)(600 * AssetScale), CaptureRect.Height),
|
||||
Threshold = 0.6,
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
}
|
||||
|
||||
public async Task<bool> Start(CancellationToken ct)
|
||||
{
|
||||
if (CaptureToRectArea().Find(_trackPoint).IsEmpty())
|
||||
{
|
||||
Logger.LogInformation("未找到追踪点,停止任务");
|
||||
throw new Exception("未找到追踪点");
|
||||
}
|
||||
|
||||
return await MakeTrackPointDirectlyAbove(ct);
|
||||
}
|
||||
|
||||
private async Task<bool> MakeTrackPointDirectlyAbove(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
double dpi = TaskContext.Instance().DpiScale;
|
||||
var startTime = DateTime.Now;
|
||||
int prevMoveX = 0;
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
var ra = CaptureToRectArea();
|
||||
var trackPointRa = ra.Find(_trackPoint);
|
||||
if (trackPointRa.IsExist())
|
||||
{
|
||||
// 使追踪点位于俯视角上方
|
||||
var centerY = trackPointRa.Y + trackPointRa.Height / 2;
|
||||
if (centerY > CaptureRect.Height / 2)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(-50, 0);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
|
||||
Debug.WriteLine("使追踪点位于俯视角上方");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 调整方向
|
||||
var centerX = trackPointRa.X + trackPointRa.Width / 2;
|
||||
var moveX = (int)((centerX - CaptureRect.Width / 2.0) / 8 / dpi);
|
||||
moveX = moveX switch
|
||||
{
|
||||
>= 10 and < 50 => 80 + moveX,
|
||||
> -50 and <= -10 => -80 + moveX,
|
||||
> 0 and < 10 => 10 + moveX,
|
||||
> -10 and < 0 => -10 + moveX,
|
||||
_ => moveX
|
||||
};
|
||||
if (moveX != 0)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(moveX, 0);
|
||||
Debug.WriteLine("调整方向:" + moveX);
|
||||
}
|
||||
|
||||
if (moveX == 0 || prevMoveX * moveX < 0)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
}
|
||||
|
||||
// 识别F
|
||||
var text = Bv.FindFKeyText(ra);
|
||||
if (!string.IsNullOrEmpty(text) && text.Contains("激活"))
|
||||
{
|
||||
Logger.LogInformation("追踪:识别到[{Msg}]", text);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
return true;
|
||||
}
|
||||
|
||||
prevMoveX = moveX;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 随机移动
|
||||
Logger.LogInformation("未找到追踪目标");
|
||||
}
|
||||
|
||||
if (DateTime.Now - startTime > TimeSpan.FromMilliseconds(_timeoutMilliseconds))
|
||||
{
|
||||
Logger.LogInformation("追踪超时");
|
||||
return false;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, 800); // 保证俯视角(低头)
|
||||
await Delay(100, ct);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Job;
|
||||
|
||||
public class WalkToFTask
|
||||
{
|
||||
/// <summary>
|
||||
/// 行走直到F出现
|
||||
/// </summary>
|
||||
/// <param name="ct"></param>
|
||||
/// <param name="timeoutMilliseconds">超时时间</param>
|
||||
/// <param name="runToF">是否冲刺</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Start(CancellationToken ct, int timeoutMilliseconds = 30000, bool runToF = false)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
await Delay(30, ct);
|
||||
// 组合键好像不能直接用 postmessage
|
||||
if (runToF)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintKeyboard, KeyType.KeyDown);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
bool res = await NewRetry.WaitForElementAppear(AutoPickAssets.Instance.PickRo, null, ct, timeoutMilliseconds / 100 + 1, 100);
|
||||
if (res)
|
||||
{
|
||||
Logger.LogInformation("检测到交互键");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("前往目标[F]超时!");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Sleep(50);
|
||||
if (runToF)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintKeyboard, KeyType.KeyUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public static class NewRetry
|
||||
/// <returns>是否成功找到元素</returns>
|
||||
public static async Task<bool> WaitForElementAppear(
|
||||
RecognitionObject recognitionObject,
|
||||
Action retryAction,
|
||||
Action? retryAction,
|
||||
CancellationToken ct,
|
||||
int maxAttemptCount = 10,
|
||||
int retryInterval = 1000
|
||||
@@ -138,7 +138,7 @@ public static class NewRetry
|
||||
/// <returns>是否成功等待元素消失</returns>
|
||||
public static async Task<bool> WaitForElementDisappear(
|
||||
RecognitionObject recognitionObject,
|
||||
Action retryAction,
|
||||
Action? retryAction,
|
||||
CancellationToken ct,
|
||||
int maxAttemptCount = 10,
|
||||
int retryInterval = 1000)
|
||||
|
||||
@@ -117,7 +117,7 @@ public class TaskRunner
|
||||
public async Task RunSoloTaskAsync(ISoloTask soloTask)
|
||||
{
|
||||
// 没启动的时候先启动
|
||||
bool waitForMainUi = soloTask.Name != "自动七圣召唤" && !soloTask.Name.Contains("自动音游");
|
||||
bool waitForMainUi = soloTask.Name != "自动七圣召唤" && !soloTask.Name.Contains("自动音游") && !soloTask.Name.Contains("幽境危战");
|
||||
await ScriptService.StartGameTask(waitForMainUi);
|
||||
await Task.Run(() => RunCurrentAsync(async () => await soloTask.Start(CancellationContext.Instance.Cts.Token)));
|
||||
}
|
||||
|
||||
@@ -1229,6 +1229,257 @@
|
||||
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
||||
<!-- 自动幽境危战 -->
|
||||
<ui:CardExpander Margin="0,0,0,12" ContentPadding="0">
|
||||
<ui:CardExpander.Icon>
|
||||
<ui:FontIcon Glyph="" Style="{StaticResource FaFontIconStyle}" />
|
||||
</ui:CardExpander.Icon>
|
||||
<ui:CardExpander.Header>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="自动幽境危战"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
TextWrapping="Wrap">
|
||||
在接触钥匙后的界面启动本任务 -
|
||||
<Hyperlink Command="{Binding GoToAutoDomainUrlCommand}"
|
||||
Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}">
|
||||
点击查看使用教程
|
||||
</Hyperlink>
|
||||
</ui:TextBlock>
|
||||
<controls:TwoStateButton Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,24,0"
|
||||
DisableCommand="{Binding StopSoloTaskCommand}"
|
||||
DisableContent="停止"
|
||||
EnableCommand="{Binding SwitchAutoStygianOnslaughtCommand}"
|
||||
EnableContent="{Binding SwitchAutoStygianOnslaughtButtonText}"
|
||||
IsChecked="{Binding SwitchAutoStygianOnslaughtEnabled}" />
|
||||
</Grid>
|
||||
</ui:CardExpander.Header>
|
||||
<StackPanel>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="选择战斗策略"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="用于战斗"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:Button Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,12,0"
|
||||
Content="脚本仓库"
|
||||
Command="{Binding OpenLocalScriptRepoCommand}"
|
||||
Icon="{ui:SymbolIcon Archive24}" />
|
||||
<ui:Button Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,12,0"
|
||||
Command="{Binding OpenFightFolderCommand}"
|
||||
Content="打开目录" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="3"
|
||||
Width="180"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding AutoFightViewModel.CombatStrategyList}"
|
||||
SelectedItem="{Binding Config.AutoStygianOnslaughtConfig.StrategyName, Mode=TwoWay}">
|
||||
<b:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="DropDownOpened">
|
||||
<b:InvokeCommandAction Command="{Binding StrategyDropDownOpenedCommand}"
|
||||
CommandParameter="Combat" />
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="刷取至树脂耗尽"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="优先使用浓缩树脂,然后使用原粹树脂,其余树脂不使用"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoStygianOnslaughtConfig.SpecifyResinUse,Converter={StaticResource InverseBooleanConverter}, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 指定树脂使用开关 -->
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="指定每种树脂刷取次数"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="开启后会根据配置的次数使用对应的树脂"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoStygianOnslaughtConfig.SpecifyResinUse, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
|
||||
<!-- 树脂设置组 -->
|
||||
<Border Margin="16,8,16,16"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{ui:ThemeResource CardStrokeColorDefaultBrush}"
|
||||
Background="{ui:ThemeResource ControlFillColorSecondaryBrush}"
|
||||
CornerRadius="8"
|
||||
IsEnabled="{Binding Config.AutoStygianOnslaughtConfig.SpecifyResinUse, Mode=OneWay}">
|
||||
<StackPanel Margin="12">
|
||||
|
||||
<!-- 原粹树脂设置 -->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="0,8,0,12">
|
||||
<ui:TextBlock Text="原粹树脂刷取次数:"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,8,0" />
|
||||
<ui:NumberBox Value="{Binding Config.AutoStygianOnslaughtConfig.OriginalResinUseCount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Minimum="0"
|
||||
SmallChange="1"
|
||||
LargeChange="5"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Width="120"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- 浓缩树脂设置 -->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="0,0,0,12">
|
||||
<ui:TextBlock Text="浓缩树脂刷取次数:"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,8,0" />
|
||||
<ui:NumberBox Value="{Binding Config.AutoStygianOnslaughtConfig.CondensedResinUseCount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Minimum="0"
|
||||
SmallChange="1"
|
||||
LargeChange="5"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Width="120" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- 须臾树脂设置 -->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="0,0,0,12">
|
||||
<ui:TextBlock Text="须臾树脂刷取次数:"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,8,0" />
|
||||
<ui:NumberBox Value="{Binding Config.AutoStygianOnslaughtConfig.TransientResinUseCount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Minimum="0"
|
||||
SmallChange="1"
|
||||
LargeChange="5"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Width="120" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- 脆弱树脂设置 -->
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Margin="0,0,0,0">
|
||||
<ui:TextBlock Text="脆弱树脂刷取次数:"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,8,0" />
|
||||
<ui:NumberBox Value="{Binding Config.AutoStygianOnslaughtConfig.FragileResinUseCount, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Minimum="0"
|
||||
SmallChange="1"
|
||||
LargeChange="5"
|
||||
SpinButtonPlacementMode="Inline"
|
||||
Width="120" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="结束后自动分解圣遗物"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="需要快速分解圣遗物的最高星级"
|
||||
TextWrapping="Wrap" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="80"
|
||||
Margin="0,0,10,0"
|
||||
ItemsSource="{Binding Source={x:Static pages:TaskSettingsPageViewModel.ArtifactSalvageStarList}}"
|
||||
SelectedItem="{Binding Config.AutoArtifactSalvageConfig.MaxArtifactStar, Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.AutoStygianOnslaughtConfig.AutoArtifactSalvage, Mode=TwoWay}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
||||
<!--<ui:CardExpander Margin="0,0,0,12"
|
||||
ContentPadding="0"
|
||||
|
||||
@@ -581,56 +581,8 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
Config.HotKeyConfig.Test1HotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
// var handler = new ElementalCollectHandler(ElementalType.Anemo);
|
||||
// handler.RunAsync(new CancellationToken());
|
||||
|
||||
// var handler = new PickAroundHandler();
|
||||
// handler.RunAsync(new CancellationToken());
|
||||
|
||||
// SwitchPartyTask switchPartyTask = new SwitchPartyTask();
|
||||
// Task.Run(async () => { await switchPartyTask.Start("三保一", new CancellationToken()); });
|
||||
//
|
||||
// GoToAdventurersGuildTask goToAdventurersGuildTask = new GoToAdventurersGuildTask();
|
||||
// Task.Run(async () => { await goToAdventurersGuildTask.Start("蒙德", new CancellationToken()); });
|
||||
|
||||
// ArtifactSalvageTask artifactSalvageTask = new ArtifactSalvageTask();
|
||||
// Task.Run(async () => { await artifactSalvageTask.Start(4, new CancellationToken()); });
|
||||
|
||||
// 领取纪行奖励
|
||||
// Task.Run(async () => { await new ClaimBattlePassRewardsTask().Start(new CancellationToken()); });
|
||||
|
||||
// 领取邮件奖励
|
||||
// Task.Run(async () => { await new ClaimMailRewardsTask().Start(new CancellationToken()); });
|
||||
|
||||
// 拾取物品
|
||||
// Task.Run(async () => { await new ScanPickTask().Start(new CancellationToken()); });
|
||||
|
||||
// Simulation.SendInput.Keyboard.KeyDown(false, User32.VK.VK_LMENU);
|
||||
// // TaskContext.Instance().PostMessageSimulator.KeyDown(User32.VK.VK_MENU);
|
||||
// Thread.Sleep(500);
|
||||
// GameCaptureRegion.GameRegion1080PPosMove(200, 100);
|
||||
// Thread.Sleep(500);
|
||||
// // TaskContext.Instance().PostMessageSimulator.KeyUp(User32.VK.VK_MENU);
|
||||
// Simulation.SendInput.Keyboard.KeyUp(false, User32.VK.VK_LMENU);
|
||||
|
||||
// TaskControl.Logger.LogInformation("大地图界面缩放按钮位置:{Position}", Bv.GetBigMapScale( TaskControl.CaptureToRectArea()));
|
||||
|
||||
|
||||
// TaskControl.Logger.LogInformation($"尝试显示遮罩窗口");
|
||||
// var maskWindow = MaskWindow.Instance();
|
||||
// maskWindow.Invoke(() => { maskWindow.Show(); });
|
||||
Task.Run(async () =>
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
var imageRegion = TaskControl.CaptureToRectArea();
|
||||
var eRa = imageRegion.DeriveCrop(AutoFightAssets.Instance.ECooldownRect);
|
||||
var eRaWhite = OpenCvCommonHelper.InRangeHsv(eRa.SrcMat, new Scalar(0, 0, 235), new Scalar(0, 25, 255));
|
||||
var text = OcrFactory.Paddle.OcrWithoutDetector(eRaWhite);
|
||||
TaskControl.Logger.LogInformation("冷却时间 {Num}", StringUtils.TryParseDouble(text));
|
||||
await Task.Delay(10);
|
||||
}
|
||||
});
|
||||
LowerHeadThenWalkToTask _lowerHeadThenWalkToTask = new("chest_tip.png", 20000);
|
||||
_lowerHeadThenWalkToTask.Start(CancellationToken.None);
|
||||
}
|
||||
));
|
||||
debugDirectory.Children.Add(new HotKeySettingModel(
|
||||
|
||||
@@ -33,6 +33,7 @@ using System.Reflection;
|
||||
using System.Collections.Frozen;
|
||||
using System.Diagnostics;
|
||||
using BetterGenshinImpact.GameTask.AutoArtifactSalvage;
|
||||
using BetterGenshinImpact.GameTask.AutoStygianOnslaught;
|
||||
using BetterGenshinImpact.View.Windows;
|
||||
|
||||
namespace BetterGenshinImpact.ViewModel.Pages;
|
||||
@@ -79,6 +80,15 @@ public partial class TaskSettingsPageViewModel : ViewModel
|
||||
|
||||
[ObservableProperty]
|
||||
private string _switchAutoDomainButtonText = "启动";
|
||||
|
||||
[ObservableProperty]
|
||||
private int _autoStygianOnslaughtRoundNum;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _switchAutoStygianOnslaughtEnabled;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _switchAutoStygianOnslaughtButtonText = "启动";
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _switchAutoFightEnabled;
|
||||
@@ -293,15 +303,20 @@ public partial class TaskSettingsPageViewModel : ViewModel
|
||||
|
||||
public bool GetFightStrategy(out string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Config.AutoFightConfig.StrategyName))
|
||||
return GetFightStrategy(Config.AutoFightConfig.StrategyName, out path);
|
||||
}
|
||||
|
||||
public bool GetFightStrategy(string strategyName, out string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(strategyName))
|
||||
{
|
||||
UIDispatcherHelper.Invoke(() => { Toast.Warning("请先在【独立任务——自动战斗】下拉列表配置中选择战斗策略!"); });
|
||||
UIDispatcherHelper.Invoke(() => { Toast.Warning("请先在下拉列表配置中选择战斗策略!"); });
|
||||
path = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
path = Global.Absolute(@"User\AutoFight\" + Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(Config.AutoFightConfig.StrategyName))
|
||||
path = Global.Absolute(@"User\AutoFight\" + strategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(strategyName))
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
@@ -321,6 +336,27 @@ public partial class TaskSettingsPageViewModel : ViewModel
|
||||
await Launcher.LaunchUriAsync(new Uri("https://bettergi.com/feats/task/domain.html"));
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OnSwitchAutoStygianOnslaught()
|
||||
{
|
||||
if (GetFightStrategy(Config.AutoStygianOnslaughtConfig.StrategyName, out var path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchAutoStygianOnslaughtEnabled = true;
|
||||
await new TaskRunner()
|
||||
.RunSoloTaskAsync(new AutoStygianOnslaughtTask(Config.AutoStygianOnslaughtConfig, path));
|
||||
SwitchAutoStygianOnslaughtEnabled = false;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task OnGoToAutoStygianOnslaughtUrlAsync()
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new Uri("https://bettergi.com/feats/task/stygian.html"));
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
public void OnOpenFightFolder()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user