Esempio n. 1
0
 public bool collided(XNACS1Primitive other)
 {
     if (other != null && ballList != null)
     {
         foreach (Ball ball in ballList)
         {
             if (ball.Collided(other))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
 protected void reflectionVelocityResolution(XNACS1Primitive other)
 {
     if (other != null)
     {
         if (other.CenterY >= CenterY + Height / 2f || other.CenterY <= CenterY - Height / 2f)
         {
             other.VelocityY *= -1;
         }
         else
         {
             other.VelocityX *= -1;
         }
     }
 }
 protected void reflectHelper(XNACS1Primitive other)
 {
     if (other != null)
     {
         // Reflect
         if (other.CenterY >= CenterY + Radius || other.CenterY <= CenterY - Radius)
         {
             other.VelocityY *= -1;
         }
         else
         {
             other.VelocityX *= -1;
         }
     }
 }
Esempio n. 4
0
        public void Update(XNACS1Primitive target, float turnRate)
        {
            if (!Collided(target))
            {
                Vector2 targetDir = target.Center - Center;
                targetDir.Normalize();
                float theta = MathHelper.ToDegrees((float)Math.Acos(
                                                       (double)(Vector2.Dot(FrontDirection, targetDir))));

                if (theta > 0.001f)
                { // not quite aligned ...
                    Vector3 fIn3D = new Vector3(FrontDirection, 0f);
                    Vector3 tIn3D = new Vector3(targetDir, 0f);
                    Vector3 sign  = Vector3.Cross(fIn3D, tIn3D);

                    RotateAngle      += Math.Sign(sign.Z) * theta * turnRate;
                    VelocityDirection = FrontDirection;
                }

                mShowV.SetEndPoints(Center, Center + kDrawFactor * Velocity, kDrawWidth);
                mShowV.Color = Color.Blue;
            }
        }