示例#1
0
        public override void UpdateAI(GameTime gameTime)
        {
            decisionTrigger.Update(gameTime);
            actionTrigger.Update(gameTime);
            if (lastTarget != null)
            {
                Vector2 distanceVector   = lastTarget.Body.Position - Owner.Body.Position;
                Vector2 desired_velocity = Vector2.Normalize(distanceVector) * Owner.RearThruster.Power;
                Vector2 steering         = desired_velocity - Owner.Body.LinearVelocity;
                steering.Normalize();
                float angleDiff = AngleToTarget(lastTarget.Body.Position, Owner.Body.Rotation);
                //                if (distanceVector.Length() > WorldConversions.ConvertFromPixels(300))
                //                {
                Owner.Steer(angleDiff);
                //                }
                if (Math.Abs(angleDiff) < Math.PI / 5)
                {
                    Owner.Accelerate(steering.Length());
                }
            }
            else
            {
            }


            base.UpdateAI(gameTime);
        }