Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

obj_gun.h

Go to the documentation of this file.
00001 #ifndef __OBJECTGUN_H
00002 #define __OBJECTGUN_H
00003 
00004 class GunInterface
00005 {
00006 protected:
00007   Object*           obj;              
00008   FacingInterface*  facing;           
00009   ObjectInfo*       missile_objinfo;  
00010   float             speed;            
00011   int timer; 
00012   int top_timer; 
00013   int dir;                            
00014   void ResetCountdown();    
00015   bool Countdown( int dt ); 
00016   bool Ready();             
00017   void Fire(); 
00019 public:
00020   GunInterface( Object*          _obj,
00021                 FacingInterface* _facing,
00022                 ObjectInfo*      _missile_objinfo,
00023                 float            _speed,
00024                 int              _top_timer,
00025                 int              _dir ):
00026     obj( _obj ),
00027     facing( _facing ),
00028     missile_objinfo( _missile_objinfo ),
00029     speed( _speed ),
00030     timer( _top_timer ),
00031     top_timer( _top_timer ),
00032     dir( _dir ) {}
00033   virtual ~GunInterface() {}
00034   /* bus messages */
00035   virtual void Event( int evt )           {}
00036   virtual void HitTile( Tile* )           {}
00037   virtual void HitObj( Object* )          {}
00038 };
00039 
00040 class GunPlayer: public GunInterface
00041 {
00042 private:
00043   int          key_bits;
00044   int          ammo;
00045 public:
00046   GunPlayer( Object*     _obj,
00047              FacingInterface* _facing,
00048              ObjectInfo* _missile_objinfo,
00049              float       _speed,
00050              int         _top_timer,
00051              int         _dir,
00052              int         _key_bits ):
00053     GunInterface( _obj, _facing, _missile_objinfo,
00054                   _speed, _top_timer, _dir ),
00055     key_bits( _key_bits ),
00056     ammo ( 0 )
00057     {}
00058   virtual ~GunPlayer() {}
00059   virtual void Event( int evt );
00060   int AmmoLeft();
00061   void GrantAmmo( int new_ammo );
00062   void SetAmmo( int new_ammo );
00063 };
00064 
00065 // Periodic gun.
00066 // Set turns to adjust firing from forward:
00067 // -2 - port      (left)
00068 //  0 - bow       (forward)
00069 // +2 - starboard (right)
00070 // +4 - aft       (behind)
00071 class GunPeriodic: public GunInterface
00072 {
00073 public:
00074   GunPeriodic( Object*           _obj,
00075                FacingInterface*  _facing,
00076                ObjectInfo*       _missile_objinfo,
00077                float             _speed,
00078                int               _dir,
00079                int               _top_timer ):
00080     GunInterface( _obj, _facing, _missile_objinfo,
00081                   _speed, _dir, _top_timer )
00082   {}
00083   virtual ~GunPeriodic() {}
00084   virtual void Event( int evt );
00085 };
00086 
00087 // class GunTimeTriggeredBehaviorMotionless: public GunInterface
00088 // {
00089 // public:
00090 //   BehaviorMotionless( Object* _obj ):
00091 //     BehaviorInterface( _obj ) {}
00092 
00093 //   void Action();
00094 // };
00095 
00096 // class GunDeathTriggered: public GunInterface
00097 // {
00098 // };
00099 
00100 #endif /* __OBJECTGUN_H */

Generated on Sun Mar 2 18:50:27 2003 for eounicorn by doxygen1.3-rc3