public virtual void HanldeCollisions(IPhysicsHandler physics, ITransform transform) { UpdateRectangle(transform.Position); Vector2 collisionDisplacment = new Vector2(0, 0); foreach (var collidableObject in collidableObstacles) { if (CollisionUtilities.CheckRectangleCollision(CollisionRectangle, collidableObject.CollisionRectangle)) //Check of er een collision is { collisionDisplacment = collidableObject.CollisionFix(physics, this); //Los collision op met collisionfix van object waartegen gebotst werd } } transform.Position += collisionDisplacment; UpdateRectangle(transform.Position); physics.CollisionLeft = false; physics.CollisionRight = false; physics.OnGround = false; physics.CollisionTop = false; foreach (var objectB in collidableObstacles) //Check of je ergens opstaat of niet { objectB.CollisionCheck(CollisionRectangle, physics); } UpdateRectangle(transform.Position); //Opnieuw update want nieuwe positie CollisionRectangleOld = CollisionRectangle; }
public override void HanldeCollisions(IPhysicsHandler physics, ITransform transform) { UpdateRectangle(transform.Position); foreach (var collidableObject in collidableObstacles) { if (CollisionUtilities.CheckRectangleCollision(CollisionRectangle, collidableObject.CollisionRectangle)) //Check of er een collision is { Explode(collidableObstacles); } } CollisionRectangleOld = CollisionRectangle; }
public override void HanldeCollisions(IPhysicsHandler physics, ITransform transform) { UpdateRectangle(transform.Position); foreach (var collidableObject in collidableObstacles) { if (CollisionUtilities.CheckRectangleCollision(CollisionRectangle, collidableObject.CollisionRectangle)) //Check of er een collision is { if (collidableObject.Parent is Human) { ((Human)collidableObject.Parent).Health -= ((Bullet)Parent).Damage; //Als het mens is verminder HP met 1 ((Human)collidableObject.Parent).Hit = true; } Parent.Alive = false; //Bullet destroys itself when hit } } CollisionRectangleOld = CollisionRectangle; }