protected override void SetupTask(Bullet bullet)
{
//set the accelerataion we are gonna add to the bullet
startDuration = Node.GetChildValue(ENodeName.term, this);
//check for divide by 0
if (0.0f == startDuration)
{
startDuration = 1.0f;
}
Duration = startDuration;
//Get the horizontal node
HorizontalNode horiz = Node.GetChild(ENodeName.horizontal) as HorizontalNode;
if (null != horiz)
{
//Set the x component of the acceleration
switch (horiz.NodeType)
{
case ENodeType.sequence:
{
//Sequence in an acceleration node means "add this amount every frame"
_acceleration.x = horiz.GetValue(this);
}
break;
case ENodeType.relative:
{
//accelerate by a certain amount
_acceleration.x = horiz.GetValue(this) / Duration;
}
break;
default:
{
//accelerate to a specific value
_acceleration.x = (horiz.GetValue(this) - bullet.Acceleration.x) / Duration;
}
break;
}
}
//Get the vertical node
VerticalNode vert = Node.GetChild(ENodeName.vertical) as VerticalNode;
if (null != vert)
{
//set teh y component of the acceleration
switch (vert.NodeType)
{
case ENodeType.sequence:
{
//Sequence in an acceleration node means "add this amount every frame"
_acceleration.y = vert.GetValue(this);
}
break;
case ENodeType.relative:
{
//accelerate by a certain amount
_acceleration.y = vert.GetValue(this) / Duration;
}
break;
default:
{
//accelerate to a specific value
_acceleration.y = (vert.GetValue(this) - bullet.Acceleration.y) / Duration;
}
break;
}
}
}