Example #1
0
 public Hitbox(Player actor, Body pBody, World curWorld, Vector2 baseImageSize, Vector2 boxSize, Vector2 offset)
 {
     SetWorld(curWorld);
     thisActor   = actor;
     playerPos   = actor.Position;
     playerBody  = pBody;
     this.height = baseImageSize.Y;
     body        = curWorld.CreateRectangle(boxSize.X, boxSize.Y, 1, new Vector2(pBody.Position.X + offset.X, pBody.Position.Y - height / 2 + offset.Y));
     this.offset = offset;
     body.SetFriction(0);
     body.SetCollisionGroup(actor.GetCollisionGroup(false));
     hurtboxGroup       = actor.GetCollisionGroup(true);
     body.OnCollision  += Body_OnCollision;
     body.BodyType      = BodyType.Dynamic;
     body.FixedRotation = true;
 }
Example #2
0
 private bool Body_OnCollision(Fixture sender, Fixture other, tainicom.Aether.Physics2D.Dynamics.Contacts.Contact contact)
 {
     if (other.CollisionGroup == thisActor.GetOpposedCollisionGroup(true))
     {
         thisActor.DoJump(100000, 100000);
     }
     if (other.CollisionGroup == thisActor.GetCollisionGroup(true))
     {
         thisActor.DoJump(100000, 100000);
     }
     return(true);
 }