Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics/src/world_entities/weapon.h

    r3862 r3953  
    3434
    3535#define W_MAX_SLOTS 8
    36 #define W_MAX_CONFS 4
     36#define W_MAX_CONFIGS 4
    3737
    3838class Projectile;
    3939class Weapon;
     40class Animation3D;
    4041
    4142typedef enum {
     
    4849} weaponSoundType;
    4950
     51
    5052//! 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
    51 typedef enum slotID {W_SLOT0=0, W_SLOT1, W_SLOT2, W_SLOT3,
    52                      W_SLOT4, W_SLOT5, W_SLOT6, W_SLOT7};
     53#define W_SLOT0 0
     54#define W_SLOT1 1
     55#define W_SLOT2 2
     56#define W_SLOT3 3
     57#define W_SLOT4 4
     58#define W_SLOT5 5
     59#define W_SLOT6 6
     60#define W_SLOT7 7
     61#define W_FREE_SLOT 99
     62
    5363
    5464//! this is an identifier for the weapon config
    55 typedef enum configID {W_CONFIG0=0, W_CONFIG1,
    56                        W_CONFIG2, W_CONFIG3};
     65#define W_CONFIG0 0
     66#define W_CONFIG1 1
     67#define W_CONFIG2 2
     68#define W_CONFIG3 3
     69
     70//! a weapon can be left or right sided
     71#define W_LEFT 0
     72#define W_RIGHT 1
    5773
    5874//! this is a weapon Configuration: it has up to 8 slots
    5975typedef struct weaponConfig {
    60   Weapon* slot1;                    //<! standard right side weapon
    61   Weapon* slot2;                    //<! standard left side weapon
    62   Weapon* slot3;                    //<! custom
    63   Weapon* slot4;                    //<! custom
    64   Weapon* slot5;                    //<! custom
    65   Weapon* slot6;                    //<! custom
    66   Weapon* slot7;                    //<! custom
    67   Weapon* slot8;                    //<! custom
     76  bool bUsed;                       //<! is set to true, if this configuration is
     77  Weapon* slots[8];
    6878};
    6979
     
    7484  ~WeaponManager();
    7585 
    76   void addWeapon(Weapon* weapon, slotID slot, configID config = W_CONFIG0);
    77   void addWeaponConfig(weaponConfig* config);
     86  void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT);
     87  void removeWeapon(Weapon* weapon, int configID = W_CONFIG0);
     88  void nextWeaponConf();
    7889
    79   void nextWeaponConf();
    80   void prevWeaponConf();
    81   void selectConfig(configID config);
     90  void fire();
     91  void tick(float sec);
     92  void draw();
    8293
    8394 private:
    84   int nrOfConfigs;                      //<! number of configurations defined
    8595  int nrOfSlots;                        //<! number of weapon slots a ship has
    86   weaponConfig* currentConfig;          //<! the currently selected config
    87   weaponConfig* configs[4];             //<! a list of four configurations
     96  int currConfID;                       //<! the currently selected config
     97  weaponConfig configs[4];              //<! a list of four configurations
     98 
     99  int getNextFreeSlot(int configID);
    88100};
    89101
     
    93105
    94106 public:
    95   Weapon (PNode* parent, Vector* coordinate, Quaternion* direction);
     107  Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
    96108  virtual ~Weapon ();
    97109 
     
    107119  bool isActive(void);
    108120
    109   void setWeaponIdleTime(float time);
    110   float getWeaponIdleTime(void);
    111   bool hasWeaponIdleTimeElapsed(void);
    112121
     122  /**
     123     \brief sets a weapon idle time
     124     \param idle time in ms
     125     
     126     a weapon idle time is the time spend after a shoot until the weapon can
     127     shoot again
     128  */
     129  inline void setWeaponIdleTime(float time) { this->idleTime = time; }
     130  /**
     131     \brief gets the weapon idle time
     132     \returns idle time in ms
     133     
     134     a weapon idle time is the time spend after a shoot until the weapon can
     135     shoot again
     136  */
     137  inline float getWeaponIdleTime(void) const { return this->idleTime;}
     138  /**
     139     \brief checks if the idle time is elapsed
     140     \return true if time is elapsed
     141     
     142     a weapon idle time is the time spend after a shoot until the weapon can
     143   shoot again
     144  */
     145  inline bool hasWeaponIdleTimeElapsed(void) const { return (this->localTime>this->idleTime)?true:false; }
     146
     147  /**
     148     \brief fires the weapon
     149     
     150     this is called from the player.cc, when fire-button is been pushed
     151  */
    113152  virtual void fire(void) = 0;
    114153  virtual void hit (WorldEntity* weapon, Vector* loc);
     
    121160 protected:
    122161  tList<WorldEntity>* worldEntities;
    123   float localTime;
    124   float idleTime;
    125   float slowDownFactor;
     162  float localTime;                 //<! this is the local time. important for shooting attributes like frequency
     163  float idleTime;                  //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
     164  float slowDownFactor;            //<! if the shooting frequency is a linear function of time...
     165
     166  PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
     167  PNode* objectComponent2;
     168  PNode* objectComponent3;
     169
     170  Animation3D* animation1;
     171  Animation3D* animation2;
     172  Animation3D* animation3;
     173
     174  Vector projectileOffset;
     175  int leftRight;   // this will become an enum
    126176
    127177 private:
    128   bool enabled;
    129   Projectile* projectile;
     178  bool enabled;                    //<! states if the weapon is enabled or not
     179  Projectile* projectile;          //<! the projectile used for this weapon
    130180  //WeaponSound sound;
    131181};
Note: See TracChangeset for help on using the changeset viewer.