QuestNpcScreen.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //-----------------------------------------------------------------------------
  2. // QuestNpcScreen.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using RolePlaying.Data;
  9. namespace RolePlaying
  10. {
  11. class QuestNpcScreen : NpcScreen<QuestNpc>
  12. {
  13. /// <summary>
  14. /// Constructs a new QuestNpcScreen object.
  15. /// </summary>
  16. /// <param name="mapEntry">The map entry for the quest NPC.</param>
  17. public QuestNpcScreen(MapEntry<QuestNpc> mapEntry)
  18. : base(mapEntry)
  19. {
  20. // assign and check the parameter
  21. QuestNpc questNpc = character as QuestNpc;
  22. if (questNpc == null)
  23. {
  24. throw new ArgumentException(
  25. "QuestNpcScreen requires a MapEntry with a QuestNpc");
  26. }
  27. // check to see if this is NPC is the current quest destination
  28. if ((Session.Quest != null) &&
  29. (Session.Quest.Stage == Quest.QuestStage.RequirementsMet) &&
  30. TileEngine.Map.AssetName.EndsWith(
  31. Session.Quest.DestinationMapContentName) &&
  32. (Session.Quest.DestinationNpcContentName == mapEntry.ContentName))
  33. {
  34. // use the quest completion dialog
  35. this.DialogueText = Session.Quest.CompletionMessage;
  36. // mark the quest for completion
  37. // -- the session will not update until the pop-up screens are cleared
  38. Session.Quest.Stage = Quest.QuestStage.Completed;
  39. }
  40. else
  41. {
  42. // this NPC is not the destination, so use the npc's welcome text
  43. this.DialogueText = questNpc.IntroductionDialogue;
  44. }
  45. }
  46. }
  47. }