public override void Die() { base.Die(); foreach (KeyValuePair <string, IDoor> door in doors.ToList()) { if (door.Key == "right" && door.Value is RightOther) { doors.Remove("right"); doors.Add("right", new RightOpen()); Sounds.GetDoorUnlockSound().Play(); } } }
public void Handle() { if (door.Value is TopOpen || door.Value is BottomOpen || door.Value is LeftOpen || door.Value is RightOpen || door.Value is LeftPortal) { if (door.Value.Hitbox.Contains(player.Hitbox)) { HandleEdge(player, door.Value, game); } } else if (door.Value is TopExploded || door.Value is BottomExploded || door.Value is LeftExploded || door.Value is RightExploded) { if (door.Value.Hitbox.Contains(player.Center)) { HandleEdge(player, door.Value, game, 32); } } else { if (!(player.X > 449 && (door.Value is RightWall || door.Value is RightOther || door.Value is RightKey)) && !(player.Y == 435 && door.Value is BottomWall)) { Rectangle collision = Rectangle.Intersect(player.Footbox, door.Value.Hitbox); if (collision.Width > collision.Height) { if (collision.Y != player.Footbox.Y) { player.Y -= collision.Height; } else { player.Y += collision.Height; } } else { if (collision.X > player.Footbox.X) { player.X -= collision.Width; } else { player.X += collision.Width; } } if (door.Value is TopKey && player.Inventory.Keys > 0) { Sounds.GetDoorUnlockSound().Play(); player.Inventory.Keys--; doors.Remove(door); doors.Add("top", new TopOpen()); if (game.roomIndex == 4) { game.rooms[8].Doors.Remove("bottom"); game.rooms[8].Doors.Add("bottom", new BottomOpen()); } } if (door.Value is RightKey && player.Inventory.Keys > 0) { Sounds.GetDoorUnlockSound().Play(); player.Inventory.Keys--; doors.Remove(door); doors.Add("right", new RightOpen()); game.rooms[game.roomIndex + 1].Doors.Remove("left"); game.rooms[game.roomIndex + 1].Doors.Add("left", new LeftOpen()); } if (door.Value is LeftKey && player.Inventory.Keys > 0) { Sounds.GetDoorUnlockSound().Play(); player.Inventory.Keys--; doors.Remove(door); doors.Add("left", new LeftOpen()); game.rooms[game.roomIndex - 1].Doors.Remove("right"); game.rooms[game.roomIndex - 1].Doors.Add("right", new RightOpen()); } if (door.Value is BottomKey && player.Inventory.Keys > 0) { Sounds.GetDoorUnlockSound().Play(); player.Inventory.Keys--; doors.Remove(door); doors.Add("bottom", new BottomOpen()); if (game.roomIndex == 8) { game.rooms[4].Doors.Remove("top"); game.rooms[4].Doors.Add("top", new TopOpen()); } } } } }