Exemplo n.º 1
0
        //Note that AISTATES are never directly part of lists,
        //and exist as fields of an AI. Thus, this will only
        // ever be called by its AI parent.
        public override void Update(GameTime gt)
        {
            if (Moving)
            {
                Body.Go();
                if (MoveTarget != null)
                {
                    if (!MoveTarget.IsDestroyed())
                        Body.SetHeading(PointAt(MoveTarget));
                    else
                        MoveTarget = null;
                }
            }
            else
                Body.Stop();

            if (Shooting)
            {
                Body.Shoot();
                if (ShootTarget != null)
                {
                    if (!ShootTarget.IsDestroyed())
                        Body.SetWeaponHeadings(PointAt(ShootTarget));
                    else
                        ShootTarget = null;
                }
            }
            else
                Body.HoldFire();
        }
Exemplo n.º 2
0
 public void SetMoveTarget(Target t)
 {
     if (MoveTarget == null)
         MoveTarget = t;
 }
Exemplo n.º 3
0
 public void SetShootTarget(Target t)
 {
     if (ShootTarget == null)
         ShootTarget = t;
 }
Exemplo n.º 4
0
 /* This method returns the apropriate heading for the
  * actor to "point" at the given target.
  */
 private double PointAt(Target t)
 {
     var tp = t.GetPosition();
     var bp = Body.GetPosition();
     double dir = Math.Atan2(tp.Y - bp.Y, tp.X - bp.X);
     return dir;
 }