Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4879 in orxonox.OLD


Ignore:
Timestamp:
Jul 17, 2005, 12:52:07 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: some more definitions

Location:
orxonox/branches/weaponSystem/src/world_entities/weapons
Files:
2 edited

Legend:

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

    r4878 r4879  
    143143{}
    144144
    145 
    146 /**
    147  *  is called, when there is no fire button pressed
    148 */
    149 void Weapon::weaponIdle()
    150 {}
    151 
    152 
    153145/**
    154146 *  this will draw the weapon
     
    157149{}
    158150
     151
     152
     153
     154
     155/**
     156 * Converts a String into an Action.
     157 * @param action the String input holding the Action.
     158 * @return The Action if known, WA_NONE otherwise.
     159 */
     160WeaponAction Weapon::charToAction(const char* action)
     161{
     162  if (!strcmp(action, "none"))
     163    return WA_NONE;
     164  else if (!strcmp(action, "shoot"))
     165    return WA_SHOOT;
     166  else if (!strcmp(action, "charge"))
     167    return WA_CHARGE;
     168  else if (!strcmp(action, "reload"))
     169    return WA_RELOAD;
     170  else if (!strcmp(action, "acitvate"))
     171    return WA_ACTIVATE;
     172  else if (!strcmp(action, "deactivate"))
     173    return WA_DEACTIVATE;
     174  else if (!strcmp(action, "special1"))
     175    return WA_SPECIAL1;
     176  else
     177  {
     178    PRINTF(2)("action %s could not be identified.\n", action);
     179    return WA_NONE;
     180  }
     181}
     182
     183/**
     184 * Converts a String into a State.
     185 * @param state the String input holding the State.
     186 * @return The State if known, WS_NONE otherwise.
     187 */
     188WeaponState Weapon::charToState(const char* state)
     189{
     190  if (!strcmp(state, "none"))
     191    return WS_NONE;
     192  else if (!strcmp(state, "shooting"))
     193    return WS_SHOOTING;
     194  else if (!strcmp(state, "reloading"))
     195    return WS_RELOADING;
     196  else if (!strcmp(state, "activating"))
     197    return WS_ACTIVATING;
     198  else if (!strcmp(state, "deactivating"))
     199    return WS_DEACTIVATING;
     200  else if (!strcmp(state, "inactive"))
     201    return WS_INACTIVE;
     202  else if (!strcmp(state, "idle"))
     203    return WS_IDLE;
     204  else
     205  {
     206    PRINTF(2)("state %s could not be identified.\n", state);
     207    return WS_NONE;
     208  }
     209}
     210
  • orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.h

    r4878 r4879  
    3939
    4040  WA_ACTION_COUNT  =    7     //!< This must match the count of enumerations-members.
    41 } WeaponActions;
     41} WeaponAction;
    4242
    4343//! An enumerator defining the States of a Weapon
     
    100100
    101101  virtual void tick(float time);
    102   virtual void weaponIdle();
    103102  virtual void draw();
     103
     104  private:
     105    static WeaponAction  charToAction(const char* action);
     106    static WeaponState   charToState(const char* state);
     107
    104108
    105109 protected:
     
    108112  ////////////
    109113  WeaponState          currentState;                     //!< The State the weapon is in.
     114  WeaponAction         requestAction;                    //!< An action to try to Engage after the currentState ends.
    110115  float                stateTime;                        //!< how long the state has taken until now.
    111116  float                times[WS_STATE_COUNT];            //!< Times to stay in the different States @see WeaponState.
Note: See TracChangeset for help on using the changeset viewer.