Try to find things to do that they don't enjoy, so you won't be in the same place - or at least try to find different times to do those things so the unpleasant people aren't there
Stay on the other side of the room if you must be in the same room as they are
Change the subject - when they start being unpleasant, just start talking about something pleasant instead
Try being direct - sometimes people don't know they're being unpleasant! Try saying "talking about unpleasant things like that makes me uncomfortable. Let's talk about something nice instead." or "I feel insulted when you say things like that. Let's try to have a pleasant talk instead."
Get some help - have a friend or acquaintance occupy the person's attention so you don't have to talk with them