Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 8, 2005, 7:02:18 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: moved the weaponManager out of Weapon
we have files enough. one more is not too much :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4759 r4826  
    33    \brief a weapon that a player can use
    44
    5     A Player has a list of weapons, that can be choosen to shoot projectiles
    6     (projectiles.{cc,h}) at ennemies. These weapons can be shooted sequentially
    7     or (if able) combined. Therefore you can choose the weapon mode = choose
    8     a weapon.
    95
    106    A weapon is characterized by:
     
    1713     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
    1814     o shooting animation
    19 
    20 
    21      a player defines one or more weapon configurations. a player has got one to eight
    22      weapon slots: places where weapons can be attached to. a weapon configuration
    23      is a matching between weapons and slots.
    24      Since its clear how many weapons a player will have, there is no list of weapons:
    25      its hard coded and limited to 8 slots and 4 configs. More would be a waste of
    26      memory and time you need to customize and change to a weapon config...
    2715*/
    2816
     
    4432class TiXmlElement;
    4533
     34
     35// typedef enum {
     36//   W_SHOOT,
     37//   W_EMPTY,
     38//   W_RELOAD,
     39//   W_SPECIAL1,
     40//   W_SPECIAL2,
     41//   W_SPECIAL3
     42// } WeaponSoundType;
     43
    4644typedef enum {
     45  W_NONE,
    4746  W_SHOOT,
    48   W_EMPTY,
    4947  W_RELOAD,
    50   W_SPECIAL1,
    51   W_SPECIAL2,
    52   W_SPECIAL3
    53 } WeaponSoundType;
     48  W_ACTIVATING,
     49  W_DEACTIVATE,
     50  W_IDLE,
     51} WeaponState;
    5452
    55 
    56 //! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time
    57 #define    W_SLOT0       0
    58 #define    W_SLOT1       1
    59 #define    W_SLOT2       2
    60 #define    W_SLOT3       3
    61 #define    W_SLOT4       4
    62 #define    W_SLOT5       5
    63 #define    W_SLOT6       6
    64 #define    W_SLOT7       7
    65 #define    W_FREE_SLOT   99
    66 
    67 
    68 //! this is an identifier for the weapon config
    69 #define    W_CONFIG0     0
    70 #define    W_CONFIG1     1
    71 #define    W_CONFIG2     2
    72 #define    W_CONFIG3     3
    7353
    7454//! a weapon can be left or right sided
     
    7656#define    W_RIGHT       1
    7757
    78 //! this is a weapon Configuration: it has up to 8 slots
    79 typedef struct weaponConfig {
    80   bool           bUsed;                       //<! is set to true, if this configuration is
    81   Weapon*        slots[8];
    82 };
    8358
    8459
    85 class WeaponManager : public BaseObject {
    86  public:
    87   WeaponManager(int nrOfSlots = 2);
    88   WeaponManager(const TiXmlElement* root);
    89   ~WeaponManager();
    9060
    91   void init();
    92   void loadParams(const TiXmlElement* root);
    93 
    94   void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
    95   void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
    96   void nextWeaponConf();
    97 
    98   void fire();
    99   void tick(float sec);
    100   void draw();
    101 
    102  private:
    103   int                   nrOfSlots;               //<! number of weapon slots a ship has
    104   int                   currConfID;              //<! the currently selected config
    105   weaponConfig          configs[4];              //<! a list of four configurations
    106 
    107   int getNextFreeSlot(int configID);
    108 };
    10961
    11062class Weapon : public WorldEntity
Note: See TracChangeset for help on using the changeset viewer.