示例#1
0
 public void HandleCollision(IPlayer player, IItem item, ICollision collisionType)
 {
     areaOfOverlap = Rectangle.Intersect(player.GetRectangle(), item.GetRectangle());
     if (collisionType.GetCollisionType().Equals("Above"))
     {
         int temp = -1 * (areaOfOverlap.Height);
         player.UpdateLocation(0, temp);
     }
     else if (collisionType.GetCollisionType().Equals("Right"))
     {
         player.UpdateLocation(areaOfOverlap.Width, 0);
     }
     else if (collisionType.GetCollisionType().Equals("Left"))
     {
         player.UpdateLocation(-(areaOfOverlap.Width), 0);
     }
     else
     {
         player.UpdateLocation(0, areaOfOverlap.Height);
     }
 }
示例#2
0
 public bool SameTypeOfCollision(ICollision second)
 {
     return(typeOfCollision.Equals(second.GetCollisionType()));
 }