home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / demo4 / weapon.h < prev   
Encoding:
C/C++ Source or Header  |  2000-07-21  |  1.9 KB  |  97 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CWeapon
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CActor
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_WEAPON_H
  16. #define _INCLUDE_WEAPON_H
  17.  
  18. #include "actor.h"
  19. #include "bullet.h"
  20.  
  21. //-------------------------------------------------------------
  22.  
  23. typedef enum {
  24.     NO_WEAPON,
  25.     MISSILE_WEAPON,
  26.     HOMING_MISSILE_WEAPON,
  27.     LASER_WEAPON
  28. } WeaponType;
  29.  
  30. //-------------------------------------------------------------
  31.  
  32. typedef enum {
  33.     WEAPON_STANDARD,
  34.     WEAPON_MEDIUM,
  35.     WEAPON_BEST
  36. } WeaponGrade;
  37.  
  38. //-------------------------------------------------------------
  39.  
  40. typedef enum {
  41.     WEAPON_AUTOMATIC,
  42.     WEAPON_MANUAL,
  43. } WeaponFiringMode;
  44.  
  45. //-------------------------------------------------------------
  46.  
  47. typedef enum {
  48.     WEAPON_FORWARD,
  49.     WEAPON_REVERSE,
  50. } WeaponDirection;
  51.  
  52. //-------------------------------------------------------------
  53.  
  54. const int WEAPON_ONSCREEN_RADIUS = 8;
  55.  
  56. //-------------------------------------------------------------
  57.  
  58. class CWeapon : public CActor
  59. {
  60.     protected:
  61.         WeaponGrade m_grade;
  62.         gsCVector m_offset;
  63.  
  64.         gsCTimer m_fire_timer;
  65.         bool m_delay_fire;
  66.  
  67.         gsCTimer m_autofire_timer;
  68.         bool m_autofire;
  69.  
  70.         WeaponFiringMode m_mode;
  71.         WeaponDirection m_direction;
  72.  
  73.         bool isValidFiringPosition();
  74.  
  75.     public:
  76.         CWeapon();
  77.         virtual ~CWeapon();
  78.  
  79.         bool update(Controls *controls);
  80.  
  81.         virtual bool activate();
  82.         virtual bool fire() = 0;
  83.  
  84.         void setGrade(WeaponGrade grade = WEAPON_STANDARD);
  85.         void setOffset(const gsCVector& offset);
  86.         void setFiringMode(WeaponFiringMode mode = WEAPON_AUTOMATIC);
  87.         void setDirection(WeaponDirection direction = WEAPON_FORWARD);
  88.  
  89.         WeaponDirection getDirection();
  90.  
  91.         bool upgrade();
  92. };
  93.  
  94. //-------------------------------------------------------------
  95.  
  96. #endif
  97.