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.
29 lines
614 B
C#
29 lines
614 B
C#
using System;
|
|
|
|
using Duality;
|
|
|
|
namespace Steering
|
|
{
|
|
public class PointTarget : ISteeringTarget
|
|
{
|
|
private Vector2 location;
|
|
|
|
public Vector2 Location
|
|
{
|
|
get { return this.location; }
|
|
set { this.location = value; }
|
|
}
|
|
|
|
public float CalculateCost(Agent agent, Vector2 sampleDirection)
|
|
{
|
|
var agentPos = agent.GameObj.Transform.Pos.Xy;
|
|
var posDelta = this.location - agentPos;
|
|
return 0.5f * (1f - Vector2.Dot(posDelta.Normalized, sampleDirection));
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Point: {0}, {1}", (int)this.location.X, (int)this.location.Y);
|
|
}
|
|
}
|
|
}
|