bullet hits tank, tank dies

This commit is contained in:
Vinzenz Schroeter 2024-04-07 21:09:36 +02:00
parent 190c0c3143
commit dd33ec59ad
6 changed files with 45 additions and 9 deletions

View file

@ -2,7 +2,7 @@ namespace TanksServer.Models;
internal sealed class Bullet(Player tankOwner, FloatPosition position, double rotation)
{
public Player TankOwner { get; } = tankOwner;
public Player Owner { get; } = tankOwner;
public FloatPosition Position { get; set; } = position;

View file

@ -7,6 +7,10 @@ internal sealed class Player(string name)
public Guid Id { get; } = Guid.NewGuid();
public PlayerControls Controls { get; } = new();
public int Kills { get; set; }
public int Deaths { get; set; }
}
internal sealed class PlayerControls

View file

@ -1,3 +1,5 @@
using TanksServer.Services;
namespace TanksServer.Models;
internal sealed class Tank(Player player, FloatPosition spawnPosition)
@ -16,8 +18,17 @@ internal sealed class Tank(Player player, FloatPosition spawnPosition)
}
public FloatPosition Position { get; set; } = spawnPosition;
public DateTime NextShotAfter { get; set; }
public bool Moved { get; set; }
public (FloatPosition TopLeft, FloatPosition BottomRight) GetBounds()
{
const int halfTile = MapService.TileSize / 2;
return (
new FloatPosition(Position.X - halfTile, Position.Y - halfTile),
new FloatPosition(Position.X + halfTile, Position.Y + halfTile)
);
}
}