Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 17, 2005, 12:37:18 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: some definitions of the Weapon

File:
1 edited

Legend:

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

    r4876 r4878  
    7878  void loadParams(const TiXmlElement* root);
    7979
    80   void enable();
    81   void disable();
    82   bool isEnabled();
    83 
    8480  void setProjectile(Projectile* projectile);
    8581  Projectile* getProjectile();
     
    8783  virtual void activate();
    8884  virtual void deactivate();
    89   bool isActive();
     85  virtual void fire() = 0;
     86  //virtual void reload();
     87  //virtual void charge();
     88  bool isActive() const { return this->active; };
    9089
    91 
    92   /** @param idle time in ms  */
    93   inline void setWeaponIdleTime(float idleTime) { this->idleTime = idleTime; };
    94   /** @returns idle time in ms */
    95   inline float getWeaponIdleTime() const { return this->idleTime; };
    96   /** @return true if idletime is elapsed else otherwise */
    97   inline bool hasWeaponIdleTimeElapsed() const { return (this->localTime > this->idleTime)?true:false; };
     90  // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
     91  void setStateDuration(const char* state, float duration);
     92  void setStateDuration(WeaponState state, float duration);
     93  float getStateDuration(WeaponState state) { return (state < WS_STATE_COUNT)?this->times[state]:0.0; };
     94  /** @return true if idletime is elapsed, false otherwise */
     95  inline bool stateTimeElapsed() const { return (this->stateTime > this->times[currentState])?true:false; };
    9896
    9997  /**  fires the weapon */
    100   virtual void fire() = 0;
    10198  virtual void hit (WorldEntity* weapon, const Vector& loc);
    10299  virtual void destroy();
     
    107104
    108105 protected:
    109   float                localTime;                        //<! this is the local time. important for shooting attributes like frequency
    110   float                idleTime;                         //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay
    111   float                slowDownFactor;                   //<! if the shooting frequency is a linear function of time...
    112 
    113106  ////////////
    114107  // PHASES //
    115108  ////////////
    116109  WeaponState          currentState;                     //!< The State the weapon is in.
    117   float                stateTime;                        //!< how long the state has teken until now.
     110  float                stateTime;                        //!< how long the state has taken until now.
    118111  float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
    119112  SoundBuffer*         soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction.
     
    127120
    128121 private:
    129    bool                 enabled;                         //<! states if the weapon is enabled or not
    130    Projectile*          projectile;                      //<! the projectile used for this weapon
    131   //WeaponSound sound;
     122   bool                 active;                          //!< states wheter the weapon is enabled or not
     123   Projectile*          projectile;                      //!< the projectile used for this weapon
    132124};
    133125
Note: See TracChangeset for help on using the changeset viewer.