222
This commit is contained in:
@@ -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 距离计算
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user