resetaction.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: resetaction.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the training library "resetaction" interface.
  10. **
  11. ** History:
  12. */
  13. #include "pch.h"
  14. #include "ResetAction.h"
  15. #include "PlaySoundAction.h"
  16. #include "SuspendedSoundFinishedCondition.h"
  17. #include "MessageAction.h"
  18. #include "TrainingMission.h"
  19. #include "ConditionalAction.h"
  20. #include "ProxyAction.h"
  21. namespace Training
  22. {
  23. //------------------------------------------------------------------------------
  24. // global variabes
  25. //------------------------------------------------------------------------------
  26. extern TrainingMission* g_pMission;
  27. //------------------------------------------------------------------------------
  28. // class static variables
  29. //------------------------------------------------------------------------------
  30. int ResetAction::m_iResetCount;
  31. //------------------------------------------------------------------------------
  32. // class methods
  33. //------------------------------------------------------------------------------
  34. /* void */ ResetAction::ResetAction (Goal* pGoal, SoundID soundID) :
  35. m_pGoal (pGoal),
  36. m_soundID (soundID),
  37. m_resetStage (RESET_START)
  38. {
  39. }
  40. //------------------------------------------------------------------------------
  41. /* void */ ResetAction::~ResetAction (void)
  42. {
  43. }
  44. //------------------------------------------------------------------------------
  45. void ResetAction::Execute (void)
  46. {
  47. // XXX this functionality now allows the game engine to continue to run while we reset, thus
  48. // keeping the reset from looking like a lockup. However, it would still be nice to disable controls
  49. // and such during the reset, and possibly switch to a different screen. Maybe set ship velocity to 0.
  50. /*
  51. SoundID resetSoundID[] = {tm_reset_0Sound, tm_reset_1Sound, tm_reset_2Sound, tm_reset_3Sound, tm_reset_4Sound};
  52. switch (m_resetStage)
  53. {
  54. case RESET_START:
  55. // play a "unique" sound
  56. m_iResetCount++;
  57. PlaySound (resetSoundID[0], RESET_NOTIFY);
  58. break;
  59. case RESET_NOTIFY:
  60. // play the mission reset voice over
  61. PlaySound (resetSoundID[m_iResetCount], (m_iResetCount < 4) ? RESET_SPECIFIC_NOTIFY : RESET_COMPLETE);
  62. break;
  63. case RESET_SPECIFIC_NOTIFY:
  64. // play a goal specific reset voice over
  65. PlaySound (m_soundID, RESET_COMPLETE);
  66. break;
  67. case RESET_COMPLETE:
  68. // finish up the reset
  69. if (m_iResetCount < 4)
  70. {
  71. MessageAction messageAction ("Mission stage reset.");
  72. messageAction.Execute ();
  73. m_resetStage = RESET_START;
  74. m_pGoal->Start ();
  75. }
  76. else
  77. g_pMission->Terminate ();
  78. break;
  79. }
  80. */
  81. }
  82. //------------------------------------------------------------------------------
  83. void ResetAction::Initialize (void)
  84. {
  85. m_iResetCount = 0;
  86. }
  87. //------------------------------------------------------------------------------
  88. void ResetAction::PlaySound (SoundID soundID, ResetStage nextStage)
  89. {
  90. if (m_soundID != NA)
  91. {
  92. PlaySoundAction* pPlaySoundAction = new PlaySoundAction (soundID);
  93. // make sure the play sound action is deleted when it is done
  94. SoundFinishedCondition* pSoundFinishedCondition = new SuspendedSoundFinishedCondition (pPlaySoundAction);
  95. ConditionalAction* pConditionalAction = new ConditionalAction (pSoundFinishedCondition, new ProxyAction (this));
  96. g_pMission->AddWaitCondition (pConditionalAction);
  97. pPlaySoundAction->Execute ();
  98. }
  99. m_resetStage = nextStage;
  100. }
  101. //------------------------------------------------------------------------------
  102. }