mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-09 04:19:47 +08:00
修复地图移动的已知问题。
This commit is contained in:
parent
ff993f642f
commit
57bcb3cd6b
@ -196,23 +196,36 @@ public class TpTask(CancellationToken ct)
|
|||||||
int moveMouseX = 100 * Math.Sign(xOffset);
|
int moveMouseX = 100 * Math.Sign(xOffset);
|
||||||
int moveMouseY = 100 * Math.Sign(yOffset);
|
int moveMouseY = 100 * Math.Sign(yOffset);
|
||||||
int moveSteps = 10;
|
int moveSteps = 10;
|
||||||
|
double totalMoveMouseX = Double.MaxValue;
|
||||||
|
double totalMoveMouseY = Double.MaxValue;
|
||||||
for (int iteration = 0; iteration < maxIterations; iteration++)
|
for (int iteration = 0; iteration < maxIterations; iteration++)
|
||||||
{
|
{
|
||||||
// 移动鼠标
|
// 移动鼠标
|
||||||
await MouseMoveMap(moveMouseX, moveMouseY, moveSteps);
|
await MouseMoveMap(moveMouseX, moveMouseY, moveSteps);
|
||||||
|
|
||||||
bigMapCenterPoint = newBigMapCenterPoint; // 保存上一次移动的数据
|
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 diffMapX = Math.Abs(newBigMapCenterPoint.X - bigMapCenterPoint.X);
|
||||||
double diffMapY = Math.Abs(newBigMapCenterPoint.Y - bigMapCenterPoint.Y);
|
double diffMapY = Math.Abs(newBigMapCenterPoint.Y - bigMapCenterPoint.Y);
|
||||||
double moveDistance = Math.Sqrt(diffMapX * diffMapX + diffMapY * diffMapY);
|
double moveDistance = Math.Sqrt(diffMapX * diffMapX + diffMapY * diffMapY);
|
||||||
|
|
||||||
if (moveDistance > 10) // 移动距离大于10认为本次移动成功
|
if (moveDistance > 10) // 移动距离大于10认为本次移动成功
|
||||||
{
|
{
|
||||||
(xOffset, yOffset) = (x - newBigMapCenterPoint.X, y - newBigMapCenterPoint.Y); // 更新目标偏移量
|
(xOffset, yOffset) = (x - newBigMapCenterPoint.X, y - newBigMapCenterPoint.Y); // 更新目标偏移量
|
||||||
double totalMoveMouseX = Math.Abs(moveMouseX * xOffset / diffMapX);
|
totalMoveMouseX = Math.Abs(moveMouseX * xOffset / diffMapX);
|
||||||
double totalMoveMouseY = Math.Abs(moveMouseY * yOffset / diffMapY);
|
totalMoveMouseY = Math.Abs(moveMouseY * yOffset / diffMapY);
|
||||||
double mouseDistance = Math.Sqrt(totalMoveMouseX * totalMoveMouseX + totalMoveMouseY * totalMoveMouseY);
|
double mouseDistance = Math.Sqrt(totalMoveMouseX * totalMoveMouseX + totalMoveMouseY * totalMoveMouseY);
|
||||||
// 调整地图缩放
|
// 调整地图缩放
|
||||||
// mapZoomLevel<5 才显示传送锚点和秘境;
|
// mapZoomLevel<5 才显示传送锚点和秘境;
|
||||||
@ -224,15 +237,7 @@ public class TpTask(CancellationToken ct)
|
|||||||
Debug.WriteLine($"在 {iteration} 迭代后,已经接近目标点,不再进一步调整。");
|
Debug.WriteLine($"在 {iteration} 迭代后,已经接近目标点,不再进一步调整。");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//else if (mouseDistance > 1000 && mapZoomLevel < 6)
|
while (mouseDistance < 2 * tolerance && mapZoomLevel > 1)
|
||||||
//{ // 缩小地图
|
|
||||||
// await AdjustMapZoomLevel(false);
|
|
||||||
// totalMoveMouseX *= (mapZoomLevel) / (mapZoomLevel + 1);
|
|
||||||
// totalMoveMouseY *= (mapZoomLevel) / (mapZoomLevel + 1);
|
|
||||||
// mouseDistance *= (mapZoomLevel) / (mapZoomLevel + 1);
|
|
||||||
// mapZoomLevel++;
|
|
||||||
//}
|
|
||||||
else if (mouseDistance < 200 && mapZoomLevel > 1)
|
|
||||||
{ // 放大地图
|
{ // 放大地图
|
||||||
await AdjustMapZoomLevel(true);
|
await AdjustMapZoomLevel(true);
|
||||||
totalMoveMouseX *= (mapZoomLevel) / (mapZoomLevel - 1);
|
totalMoveMouseX *= (mapZoomLevel) / (mapZoomLevel - 1);
|
||||||
@ -240,8 +245,7 @@ public class TpTask(CancellationToken ct)
|
|||||||
mouseDistance *= (mapZoomLevel) / (mapZoomLevel - 1);
|
mouseDistance *= (mapZoomLevel) / (mapZoomLevel - 1);
|
||||||
mapZoomLevel--;
|
mapZoomLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 单次移动最大距离为 250,
|
// 单次移动最大距离为 250,
|
||||||
moveMouseX = (int)Math.Min(totalMoveMouseX, 250 * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset);
|
moveMouseX = (int)Math.Min(totalMoveMouseX, 250 * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset);
|
||||||
moveMouseY = (int)Math.Min(totalMoveMouseY, 250 * totalMoveMouseY / mouseDistance) * Math.Sign(yOffset);
|
moveMouseY = (int)Math.Min(totalMoveMouseY, 250 * totalMoveMouseY / mouseDistance) * Math.Sign(yOffset);
|
||||||
|
Loading…
Reference in New Issue
Block a user