Пример #1
0
 public void oncollide(PhysicsObject tar)
 {
     switch (curplan)
     {
         case AIMode.bounce:
             mob.physobj.pos = Vector2.Subtract(mob.physobj.pos, mob.physobj.vel);
             float relx = Math.Abs(tar.pos.X - mob.physobj.pos.X);
             float rely = Math.Abs(tar.pos.Y - mob.physobj.pos.Y);
             if (relx > rely)
             {
                 //Console.WriteLine("x > y");
                 mob.physobj.vel = Vector2.Reflect(mob.physobj.vel, new Vector2(1, 0));
             }
             else
             {
                 //Console.WriteLine("y > x");
                 mob.physobj.vel = Vector2.Reflect(mob.physobj.vel, new Vector2(0, 1));
             }
             //mob.physobj.move();
             break;
     }
 }
Пример #2
0
 public Mob(PhysicsObject pho, DrawingObject dro)
 {
     physobj = pho;
     drawobj = dro;
     physobj.size = 40;
 }
Пример #3
0
 public void oncollide(PhysicsObject tar)
 {
     brain.oncollide(tar);
 }
Пример #4
0
 public Enemy(PhysicsObject pho, DrawingObject dro)
     : base(pho, dro)
 {
     brain = new DogBrain(this);
     brain.curplan = AIMode.bounce;
 }
Пример #5
0
 public Collidable(PhysicsObject pho, DrawingObject dro, CollideMode shape)
     : base(pho, dro)
 {
     physobj.shape = shape;
     physobj.size = Drawing.scale * (int)drawobj.cent.X;
 }
Пример #6
0
 public bool collide(PhysicsObject obj)
 {
     switch (shape)
     {
         case CollideMode.box: //box
             int boxsize = (int)(size + obj.size);
             Rectangle cbox = new Rectangle((int)pos.X - boxsize, (int)pos.Y - boxsize, 2 * boxsize, 2 * boxsize);
             if (cbox.Contains((int)obj.pos.X, (int)obj.pos.Y)) return true;
             else return false;
         case CollideMode.circle: //circle
             float radius = size + obj.size;
             if (Vector2.Subtract(pos, obj.pos).Length() < radius) return true;
             else return false;
         break;
     }
     return false;
 }
Пример #7
0
 public Projectile(Attack src, PhysicsObject pho, Vector2 tar = new Vector2())
 {
     source = src;
     physobj = pho;
     tarpos = tar;
 }
Пример #8
0
 public void oncollide(PhysicsObject tar)
 {
     brain.oncollide(tar);
 }
Пример #9
0
 public Enemy(PhysicsObject pho, DrawingObject dro)
     : base(pho, dro)
 {
     brain         = new DogBrain(this);
     brain.curplan = AIMode.bounce;
 }
Пример #10
0
 public Collidable(PhysicsObject pho, DrawingObject dro, CollideMode shape)
     : base(pho, dro)
 {
     physobj.shape = shape;
     physobj.size  = Drawing.scale * (int)drawobj.cent.X;
 }
Пример #11
0
 public Mob(PhysicsObject pho, DrawingObject dro)
 {
     physobj      = pho;
     drawobj      = dro;
     physobj.size = 40;
 }