QuestNpcScreen.cs 2.0 KB

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