40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using ActiveProtect.SimulationEnvironment;
|
|
|
|
namespace ActiveProtect.Models
|
|
{
|
|
public class Tank(string id, Vector3D position, Orientation orientation, double initialSpeed, double maxSpeed, double maxArmor) : SimulationElement(id, position, orientation)
|
|
{
|
|
public double Speed { get; set; } = initialSpeed;
|
|
public bool IsActive { get; private set; } = true;
|
|
public double MaxSpeed { get; private set; } = maxSpeed;
|
|
public double MaxArmor { get; private set; } = maxArmor;
|
|
public double Armor { get; private set; } = maxArmor;
|
|
public double CurrentArmor { get; private set; } = maxArmor;
|
|
|
|
public override void Update(double deltaTime)
|
|
{
|
|
if (!IsActive) return;
|
|
|
|
Position.X += Speed * Math.Cos(Orientation.Yaw) * Math.Cos(Orientation.Pitch) * deltaTime;
|
|
Position.Y += Speed * Math.Sin(Orientation.Pitch) * deltaTime;
|
|
Position.Z += Speed * Math.Sin(Orientation.Yaw) * Math.Cos(Orientation.Pitch) * deltaTime;
|
|
}
|
|
|
|
public void TakeDamage(double damage)
|
|
{
|
|
CurrentArmor -= damage;
|
|
if (CurrentArmor <= 0)
|
|
{
|
|
CurrentArmor = 0;
|
|
IsActive = false;
|
|
}
|
|
}
|
|
|
|
public override string GetStatus()
|
|
{
|
|
return $"坦克 {Id}:\n" +
|
|
$" 位置: X={Position.X:F2}, Y={Position.Y:F2}, Z={Position.Z:F2}\n" +
|
|
$" 装甲: {CurrentArmor:F2}";
|
|
}
|
|
}
|
|
} |