예제 #1
0
        // Kershove!
        public override void OnCollide(IGameObj o, GameState g)
        {
            Vector2d force = Vector2d.NormalizeFast(Vel);

            force = Vector2d.Multiply(force, 300);
            o.Push(force);
            base.OnCollide(o, g);
        }
예제 #2
0
        public void Boundary(IGameObj o)
        {
            double dist = o.Loc.Length;
            double f    = dist - Radius;

            if (f > 0)
            {
                Vector2d pos = o.Loc;
                pos.Normalize();
                o.Push(Vector2d.Multiply(pos, -(dist / 100)));                // And bounce them back.
            }
        }
예제 #3
0
 // We sort of cheat and use this function to push the nearby
 // object away from the fan.
 public override bool Colliding(IGameObj o)
 {
     // If the objects are too close... such as actually in contact...
     // then EXTREME things can happen.
     if (base.Colliding(o))
     {
         return(true);
     }
     else
     {
         Vector2d separation = o.Loc - Loc;
         double   distance2  = separation.LengthSquared;
         Vector2d sepDir     = Vector2d.NormalizeFast(separation);
         if (distance2 < 10000)
         {
             separation = Vector2d.Multiply(sepDir, ((10000 - distance2) / 100) * Force);
             o.Push(separation);
         }
         return(false);
     }
 }