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; } }
public Mob(PhysicsObject pho, DrawingObject dro) { physobj = pho; drawobj = dro; physobj.size = 40; }
public void oncollide(PhysicsObject tar) { brain.oncollide(tar); }
public Enemy(PhysicsObject pho, DrawingObject dro) : base(pho, dro) { brain = new DogBrain(this); brain.curplan = AIMode.bounce; }
public Collidable(PhysicsObject pho, DrawingObject dro, CollideMode shape) : base(pho, dro) { physobj.shape = shape; physobj.size = Drawing.scale * (int)drawobj.cent.X; }
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; }
public Projectile(Attack src, PhysicsObject pho, Vector2 tar = new Vector2()) { source = src; physobj = pho; tarpos = tar; }