Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 17, 2005, 2:17:09 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: more functionality, but firing does not work anymore… this will soon be fixed

File:
1 edited

Legend:

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

    r4879 r4880  
    1212    weapon in this world:
    1313     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
    14      o shooting animation
     14     o animations
    1515*/
    1616
     
    4545  WS_NONE          =    0,    //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable)
    4646  WS_SHOOTING      =    1,    //!< The State of the Shooting
     47  WS_CHARGING      =    2,    //!< The state of charging th weapon
    4748  WS_RELOADING     =    3,    //!< The State of the Reloading
    4849  WS_ACTIVATING    =    4,    //!< The State in which the weapon gets activated
     
    6869class Weapon : public WorldEntity
    6970{
    70   friend class World;
     71  public:
     72    // INITIALISATION //
     73    Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
     74    Weapon(const TiXmlElement* root);
     75    virtual ~Weapon ();
    7176
    72  public:
    73   Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction);
    74   Weapon(const TiXmlElement* root);
    75   virtual ~Weapon ();
     77    void init();
     78    void loadParams(const TiXmlElement* root);
     79    ////////////////////
    7680
    77   void init();
    78   void loadParams(const TiXmlElement* root);
     81    void requestAction(WeaponAction action);
    7982
    80   void setProjectile(Projectile* projectile);
    81   Projectile* getProjectile();
     83    /** @returns true if the Weapon is Active */
     84    inline bool isActive() const { return this->active; };
    8285
    83   virtual void activate();
    84   virtual void deactivate();
    85   virtual void fire() = 0;
    86   //virtual void reload();
    87   //virtual void charge();
    88   bool isActive() const { return this->active; };
     86    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
     87    void setProjectile(Projectile* projectile);
     88    Projectile* getProjectile();
    8989
    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; };
     90    /** @param state the State to time @param duration the duration of the State */
     91    inline void setStateDuration(const char* state, float duration) { setStateDuration(charToState(state), duration); };
     92    /** @param state the State to time @param duration the duration of the State */
     93    inline void setStateDuration(WeaponState state, float duration) { /*(state < WS_STATE_COUNT)?*/this->times[state] = duration; };
     94    /** @param state The state to query @returns the Time the queried State takes to complete */
     95    inline float getStateDuration(WeaponState state) const { return (state < WS_STATE_COUNT)?this->times[state]:0.0; };
     96    /** @returns true if the time of the currentState is elapsed, false otherwise */
     97    inline bool stateTimeElapsed() const { return (this->stateDuration > this->times[currentState])?true:false; };
     98    /** @returns the current State of the Weapon */
     99    inline WeaponState getCurrentState() const { return this->currentState; };
    96100
    97   /**  fires the weapon */
    98   virtual void hit (WorldEntity* weapon, const Vector& loc);
    99   virtual void destroy();
    100101
    101   virtual void tick(float time);
    102   virtual void draw();
    103102
    104   private:
     103    virtual void destroy();
     104
     105
     106
     107    virtual void tick(float dt);
     108    virtual void draw();
     109
     110  protected:
    105111    static WeaponAction  charToAction(const char* action);
    106112    static WeaponState   charToState(const char* state);
    107113
    108114
    109  protected:
    110   ////////////
    111   // PHASES //
    112   ////////////
    113   WeaponState          currentState;                     //!< The State the weapon is in.
    114   WeaponAction         requestAction;                    //!< An action to try to Engage after the currentState ends.
    115   float                stateTime;                        //!< how long the state has taken until now.
    116   float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
    117   SoundBuffer*         soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction.
    118   Animation3D*         animation[WS_STATE_COUNT];        //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
     115    bool execute(WeaponAction action);
     116    virtual void activate();
     117    virtual void deactivate();
     118    virtual void fire();
     119    virtual void reload();
     120    virtual void charge();
    119121
    120   SoundBuffer*         fireSound;
    121   SoundSource*         weaponSource;
     122  private:
     123    bool nextActionValid() const;
    122124
    123   float                minCharge;
    124   float                maxCharge;
     125  protected:
     126    SoundSource*         weaponSource;
     127    float                energy;
     128    int                  energyI;
    125129
    126  private:
    127    bool                 active;                          //!< states wheter the weapon is enabled or not
    128    Projectile*          projectile;                      //!< the projectile used for this weapon
    129 };
     130    ////////////
     131    // PHASES //
     132    ////////////
     133    WeaponState          currentState;                     //!< The State the weapon is in.
     134    WeaponAction         requestedAction;                  //!< An action to try to Engage after the currentState ends.
     135    float                stateDuration;                    //!< how long the state has taken until now.
     136    float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
     137    SoundBuffer*         soundBuffers[WA_ACTION_COUNT];    //!< SoundBuffers for all actions @see WeaponAction.
     138    Animation3D*         animation[WS_STATE_COUNT];        //!< Animations for all the States (you can say yourself on what part of the gun this animation acts).
     139
     140    float                minCharge;
     141    float                maxCharge;
     142
     143    bool                 hideInactive;                    //!< Hides the Weapon if it is inactive
     144
     145  private:
     146    bool                 active;                          //!< states wheter the weapon is enabled or not
     147    Projectile*          projectile;                      //!< the projectile used for this weapon
     148  };
    130149
    131150#endif /* _WEAPON_H */
Note: See TracChangeset for help on using the changeset viewer.