This commit is contained in:
Putoo
2026-06-02 17:58:36 +08:00
parent eb81a1c381
commit 8550d85659
11 changed files with 392 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
namespace Application.Domain;
using System.Drawing;
namespace Application.Domain;
public class GameTool
{
@@ -87,4 +89,39 @@ public class GameTool
return weight;
}
#region
/// <summary>
/// 计算海里
/// </summary>
/// <param name="onMap"></param>
/// <param name="toMap"></param>
/// <returns></returns>
public static int ComputeMile(string onMap, string toMap)
{
string[] _OnMap = onMap.Split('_');
int sx = Convert.ToInt32(_OnMap[0]);
int sy = Convert.ToInt32(_OnMap[1]);
string[] _ToMap = toMap.Split('_');
int ex = Convert.ToInt32(_ToMap[0]);
int ey = Convert.ToInt32(_ToMap[1]);
return GetDistanceByLocation(sx, sy, ex, ey) * 10;
}
private static int GetDistance(PointF start, PointF end)
{
double value = Math.Sqrt(Math.Abs(start.X - end.X) * Math.Abs(start.X - end.X) + Math.Abs(start.Y - end.Y) * Math.Abs(start.Y - end.Y));
return Convert.ToInt32(value);
}
private static int GetDistanceByLocation(int onX, int onY, int toX, int toY)
{
PointF start = new PointF(onX, onY);
PointF end = new PointF(toX, toY);
return GetDistance(start, end);
}
#endregion
}