修复地图移动的已知问题。

This commit is contained in:
unknown 2024-12-25 00:24:08 +08:00
parent ff993f642f
commit 57bcb3cd6b

View File

@ -196,23 +196,36 @@ public class TpTask(CancellationToken ct)
int moveMouseX = 100 * Math.Sign(xOffset);
int moveMouseY = 100 * Math.Sign(yOffset);
int moveSteps = 10;
double totalMoveMouseX = Double.MaxValue;
double totalMoveMouseY = Double.MaxValue;
for (int iteration = 0; iteration < maxIterations; iteration++)
{
{
// 移动鼠标
await MouseMoveMap(moveMouseX, moveMouseY, moveSteps);
bigMapCenterPoint = newBigMapCenterPoint; // 保存上一次移动的数据
newBigMapCenterPoint = GetPositionFromBigMap(); // 随循环更新的地图中心
try
{
newBigMapCenterPoint = GetPositionFromBigMap(); // 随循环更新的地图中心
}
catch (Exception)
{
newBigMapCenterPoint = new Point2f(
(float)(bigMapCenterPoint.X + xOffset * moveMouseX / totalMoveMouseX),
(float)(bigMapCenterPoint.Y + yOffset * moveMouseY / totalMoveMouseY)
);
// 利用移动鼠标的距离获取新的中心
}
// 本次移动的距离
double diffMapX = Math.Abs(newBigMapCenterPoint.X - bigMapCenterPoint.X);
double diffMapY = Math.Abs(newBigMapCenterPoint.Y - bigMapCenterPoint.Y);
double moveDistance = Math.Sqrt(diffMapX * diffMapX + diffMapY * diffMapY);
if (moveDistance > 10) // 移动距离大于10认为本次移动成功
{
(xOffset, yOffset) = (x - newBigMapCenterPoint.X, y - newBigMapCenterPoint.Y); // 更新目标偏移量
double totalMoveMouseX = Math.Abs(moveMouseX * xOffset / diffMapX);
double totalMoveMouseY = Math.Abs(moveMouseY * yOffset / diffMapY);
totalMoveMouseX = Math.Abs(moveMouseX * xOffset / diffMapX);
totalMoveMouseY = Math.Abs(moveMouseY * yOffset / diffMapY);
double mouseDistance = Math.Sqrt(totalMoveMouseX * totalMoveMouseX + totalMoveMouseY * totalMoveMouseY);
// 调整地图缩放
// mapZoomLevel<5 才显示传送锚点和秘境;
@ -224,15 +237,7 @@ public class TpTask(CancellationToken ct)
Debug.WriteLine($"在 {iteration} 迭代后,已经接近目标点,不再进一步调整。");
break;
}
//else if (mouseDistance > 1000 && mapZoomLevel < 6)
//{ // 缩小地图
// await AdjustMapZoomLevel(false);
// totalMoveMouseX *= (mapZoomLevel) / (mapZoomLevel + 1);
// totalMoveMouseY *= (mapZoomLevel) / (mapZoomLevel + 1);
// mouseDistance *= (mapZoomLevel) / (mapZoomLevel + 1);
// mapZoomLevel++;
//}
else if (mouseDistance < 200 && mapZoomLevel > 1)
while (mouseDistance < 2 * tolerance && mapZoomLevel > 1)
{ // 放大地图
await AdjustMapZoomLevel(true);
totalMoveMouseX *= (mapZoomLevel) / (mapZoomLevel - 1);
@ -240,8 +245,7 @@ public class TpTask(CancellationToken ct)
mouseDistance *= (mapZoomLevel) / (mapZoomLevel - 1);
mapZoomLevel--;
}
// 单次移动最大距离为 250
moveMouseX = (int)Math.Min(totalMoveMouseX, 250 * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset);
moveMouseY = (int)Math.Min(totalMoveMouseY, 250 * totalMoveMouseY / mouseDistance) * Math.Sign(yOffset);