Пример #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();
        }
Пример #2
0
 public void SetMoveTarget(Target t)
 {
     if (MoveTarget == null)
         MoveTarget = t;
 }
Пример #3
0
 public void SetShootTarget(Target t)
 {
     if (ShootTarget == null)
         ShootTarget = t;
 }
Пример #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;
 }