37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
public partial class GameObject
|
|
{
|
|
public string Name { get; private set; }
|
|
public CoordinateVector Position { get; private set; }
|
|
public CoordinateVector Size { get; private set; }
|
|
public GameObject Parent { get; private set; }
|
|
|
|
public GameObject(string name, CoordinateVector position, CoordinateVector size, GameObject parent)
|
|
{
|
|
this.Name = name;
|
|
this.Position = position;
|
|
this.Size = size;
|
|
this.Parent = parent;
|
|
}
|
|
|
|
public virtual void Simulate() { }
|
|
|
|
public void Move(CoordinateVector movementVector)
|
|
{
|
|
this.Position = Helpers.AddCoordinates(this.Position, movementVector);
|
|
}
|
|
|
|
public void MoveTo(CoordinateVector destination)
|
|
{
|
|
this.Position = destination;
|
|
}
|
|
|
|
public bool TravelTo(CoordinateVector destination, bool useWarp)
|
|
{
|
|
decimal speedAU = useWarp ? 10000 : 0.1M;
|
|
decimal speed = Helpers.GetCoordinateFromAU(speedAU);
|
|
|
|
this.Position = Helpers.CalculateMovedCoordinates(this.Position, destination, speed);
|
|
|
|
return Helpers.CompareCoordinates(this.Position, destination);
|
|
}
|
|
}
|