wip client "secret"
This commit is contained in:
parent
698271ae9f
commit
b192cd7da0
15 changed files with 117 additions and 71 deletions
|
@ -2,17 +2,15 @@ using System.Text.Json.Serialization;
|
|||
|
||||
namespace TanksServer.Models;
|
||||
|
||||
internal sealed class Player(string name)
|
||||
internal sealed class Player(string name, Guid id)
|
||||
{
|
||||
public string Name => name;
|
||||
|
||||
public Guid Id { get; } = Guid.NewGuid();
|
||||
[JsonIgnore] public Guid Id => id;
|
||||
|
||||
[JsonIgnore] public PlayerControls Controls { get; } = new();
|
||||
|
||||
public int Kills { get; set; }
|
||||
|
||||
public int Deaths { get; set; }
|
||||
public Scores Scores { get; } = new();
|
||||
|
||||
public DateTime LastInput { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ internal static class PositionHelpers
|
|||
public static FloatPosition ToFloatPosition(this PixelPosition position) => new(position.X, position.Y);
|
||||
|
||||
|
||||
public static double Distance(this FloatPosition p1, FloatPosition p2) =>
|
||||
Math.Sqrt(
|
||||
public static double Distance(this FloatPosition p1, FloatPosition p2)
|
||||
=> Math.Sqrt(
|
||||
Math.Pow(p1.X - p2.X, 2) +
|
||||
Math.Pow(p1.Y - p2.Y, 2)
|
||||
);
|
||||
|
|
8
TanksServer/Models/Scores.cs
Normal file
8
TanksServer/Models/Scores.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
namespace TanksServer.Models;
|
||||
|
||||
internal sealed record class Scores(int Kills = 0, int Deaths = 0)
|
||||
{
|
||||
public int Kills { get; set; } = Kills;
|
||||
|
||||
public int Deaths { get; set; } = Deaths;
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System.Diagnostics;
|
||||
using TanksServer.GameLogic;
|
||||
|
||||
namespace TanksServer.Models;
|
||||
|
||||
|
@ -28,12 +27,14 @@ internal sealed class Tank(Player player, FloatPosition spawnPosition) : IMapEnt
|
|||
|
||||
public PixelBounds Bounds => GetBoundsForCenter(Position);
|
||||
|
||||
public int Orientation => (int)Math.Round(Rotation * 16) % 16;
|
||||
|
||||
public static PixelBounds GetBoundsForCenter(FloatPosition position)
|
||||
{
|
||||
var pixelPosition = position.ToPixelPosition();
|
||||
return new PixelBounds(
|
||||
pixelPosition.GetPixelRelative(-3, -3),
|
||||
pixelPosition.GetPixelRelative(4, 4)
|
||||
pixelPosition.GetPixelRelative(-4, -4),
|
||||
pixelPosition.GetPixelRelative(3, 3)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue