//-----------------------------------------------------------------------------
// AlignBehavior.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
using System;
using Microsoft.Xna.Framework;
namespace Flocking
{
///
/// AlignBehavior is a Behavior that makes an animal move in the same
/// direction that the other Animal it sees is
///
class AlignBehavior : Behavior
{
public AlignBehavior(Animal animal)
: base(animal)
{
}
///
/// AlignBehavior.Update infuences the owning animal to move in same the
/// direction as the otherAnimal that it sees.
///
/// the Animal to react to
/// the Behaviors' parameters
public override void Update(Animal otherAnimal, AIParameters aiParams)
{
base.ResetReaction();
if (otherAnimal != null)
{
reacted = true;
reaction = otherAnimal.Direction * aiParams.PerMemberWeight;
}
}
}
}