goaltimer.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // goaltimer.h
  19. // Project: Postal
  20. //
  21. // History:
  22. //
  23. // 06/30/97 BRH Started this file for the challenge levels. It will
  24. // keep track of the goal time and be able to count up
  25. // or down. It will set the bRealmOver flag when the goal
  26. // is met.
  27. //
  28. ////////////////////////////////////////////////////////////////////////////////
  29. #ifndef GOALTIMER_H
  30. #define GOALTIMER_H
  31. #include "RSPiX.h"
  32. #include "realm.h"
  33. // CGoalTimer keeps track of the time and goal for a challenge level
  34. class CGoalTimer : public CThing
  35. {
  36. //---------------------------------------------------------------------------
  37. // Types, enums, etc.
  38. //---------------------------------------------------------------------------
  39. public:
  40. //---------------------------------------------------------------------------
  41. // Variables
  42. //---------------------------------------------------------------------------
  43. public:
  44. protected:
  45. double m_dX; // x coord
  46. double m_dY; // y coord
  47. double m_dZ; // z coord
  48. RImage* m_pImage; // Pointer to only image (replace with 3d anim, soon)
  49. CSprite2 m_sprite; // Sprite (replace with CSprite3, soon)
  50. long m_lTimerMS; // Timer value in Milliseconds
  51. short m_sKillGoal; // Number of kills to achieve
  52. short m_sUpDown; // Up or down timer
  53. short m_sSuspend; // Suspend flag
  54. // Tracks file counter so we know when to load/save "common" data
  55. static short ms_sFileCount;
  56. // "Constant" values that we want to be able to tune using the editor
  57. //---------------------------------------------------------------------------
  58. // Constructor(s) / destructor
  59. //---------------------------------------------------------------------------
  60. protected:
  61. // Constructor
  62. CGoalTimer(CRealm* pRealm)
  63. : CThing(pRealm, CGoalTimerID)
  64. {
  65. m_pImage = 0;
  66. m_sSuspend = 0;
  67. m_sUpDown = 1;
  68. m_sKillGoal = 0;
  69. m_lTimerMS = 120000;
  70. }
  71. public:
  72. // Destructor
  73. ~CGoalTimer()
  74. {
  75. // Remove sprite from scene (this is safe even if it was already removed!)
  76. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  77. // Free resources
  78. FreeResources();
  79. }
  80. //---------------------------------------------------------------------------
  81. // Required static functions
  82. //---------------------------------------------------------------------------
  83. public:
  84. // Construct object
  85. static short Construct( // Returns 0 if successfull, non-zero otherwise
  86. CRealm* pRealm, // In: Pointer to realm this object belongs to
  87. CThing** ppNew) // Out: Pointer to new object
  88. {
  89. short sResult = 0;
  90. *ppNew = new CGoalTimer(pRealm);
  91. if (*ppNew == 0)
  92. {
  93. sResult = -1;
  94. TRACE("CGoalTimer::Construct(): Couldn't construct CGoalTimer (that's a bad thing)\n");
  95. }
  96. return sResult;
  97. }
  98. //---------------------------------------------------------------------------
  99. // Required virtual functions (implimenting them as inlines doesn't pay!)
  100. //---------------------------------------------------------------------------
  101. public:
  102. // Load object (should call base class version!)
  103. short Load( // Returns 0 if successfull, non-zero otherwise
  104. RFile* pFile, // In: File to load from
  105. bool bEditMode, // In: True for edit mode, false otherwise
  106. short sFileCount, // In: File count (unique per file, never 0)
  107. ULONG ulFileVersion); // In: Version of file format to load.
  108. // Save object (should call base class version!)
  109. short Save( // Returns 0 if successfull, non-zero otherwise
  110. RFile* pFile, // In: File to save to
  111. short sFileCount); // In: File count (unique per file, never 0)
  112. // Startup object
  113. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  114. // Shutdown object
  115. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  116. // Suspend object
  117. void Suspend(void);
  118. // Resume object
  119. void Resume(void);
  120. // Update object
  121. void Update(void);
  122. // Render object
  123. void Render(void);
  124. // Called by editor to init new object at specified position
  125. short EditNew( // Returns 0 if successfull, non-zero otherwise
  126. short sX, // In: New x coord
  127. short sY, // In: New y coord
  128. short sZ); // In: New z coord
  129. // Called by editor to modify object
  130. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  131. // Called by editor to move object to specified position
  132. short EditMove( // Returns 0 if successfull, non-zero otherwise
  133. short sX, // In: New x coord
  134. short sY, // In: New y coord
  135. short sZ); // In: New z coord
  136. // Called by editor to update object
  137. void EditUpdate(void);
  138. // Called by editor to render object
  139. void EditRender(void);
  140. // Give Edit a rectangle around this object
  141. void EditRect(RRect* pRect);
  142. // Called by editor to get the hotspot of an object in 2D.
  143. void EditHotSpot( // Returns nothiing.
  144. short* psX, // Out: X coord of 2D hotspot relative to
  145. // EditRect() pos.
  146. short* psY); // Out: Y coord of 2D hotspot relative to
  147. // EditRect() pos.
  148. //---------------------------------------------------------------------------
  149. // Internal functions
  150. //---------------------------------------------------------------------------
  151. protected:
  152. // Get all required resources
  153. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  154. // Free all resources
  155. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  156. };
  157. #endif //GOALTIMER_H
  158. ////////////////////////////////////////////////////////////////////////////////
  159. // EOF
  160. ////////////////////////////////////////////////////////////////////////////////