You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
595 B
C#
28 lines
595 B
C#
using System;
|
|
|
|
using Duality;
|
|
|
|
namespace Steering
|
|
{
|
|
public class DirectionTarget : ISteeringTarget
|
|
{
|
|
private Vector2 direction;
|
|
|
|
public Vector2 Direction
|
|
{
|
|
get { return this.direction; }
|
|
set { this.direction = value; }
|
|
}
|
|
|
|
public float CalculateCost(Agent agent, Vector2 sampleDirection)
|
|
{
|
|
float dirLen = this.direction.Length;
|
|
return 0.5f * (1.0f - Vector2.Dot(this.direction / (dirLen > 0.0f ? dirLen : 1.0f), sampleDirection));
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Direction: {0}°", MathF.RadToDeg(this.direction.Angle));
|
|
}
|
|
}
|
|
}
|