Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4878 in orxonox.OLD for orxonox


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

orxonox/branches/weaponSystem: some definitions of the Weapon

Location:
orxonox/branches/weaponSystem/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/lib/sound/sound_engine.h

    r4836 r4878  
    3737
    3838//! A class that represents a SoundSource
     39/**
     40 * @todo ability to play back different SoundBuffers on the same SounSource
     41 */
    3942class SoundSource : public BaseObject
    4043{
  • orxonox/branches/weaponSystem/src/util/loading/factory.h

    r4836 r4878  
    1515
    1616/*!
    17   \file factory.h
    18   \brief A loadable object handler
     17 * @file factory.h
     18 * @brief A loadable object handler
    1919*/
    2020
     
    3131
    3232/**
    33     Creates a factory to a Loadable Class.
    34     this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    35   @todo make factoryName a BaseObject-parameter. (else it would be redundant)
     33 * Creates a factory to a Loadable Class.
     34 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    3635*/
    37 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
     36#define CREATE_FACTORY(CLASS_NAME) \
     37    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
    3838
    3939//! The Factory is a loadable object handler
     
    4848
    4949  static void registerFactory( Factory* factory);
    50   /** \brief sets the Next factory in the list @param nextFactory the next factory */
     50  /** sets the Next factory in the list @param nextFactory the next factory */
    5151  inline void setNext( Factory* nextFactory) { this->next = nextFactory; };
    5252  /** @returns the first factory */
     
    5454  /** @returns the next factory */
    5555  Factory* getNext() const { return this->next; };
    56 
    57 
    58   private:
    5956
    6057  private:
  • orxonox/branches/weaponSystem/src/world_entities/player.cc

    r4877 r4878  
    241241  if( this->bRight &&  TrackManager::getInstance()->getWidth() > this->getRelCoor().z*2)
    242242    accel = accel + (orthDirection*acceleration);
    243   if( this->bAscend )
     243  if( this->bAscend ) { /* FIXME */ }
    244244  if( this->bDescend) {/* FIXME */} /* @todo up and down player movement */
    245245
     
    250250
    251251/**
    252  *  weapon manipulation by the player
     252 * weapon manipulation by the player
    253253*/
    254254void Player::weaponAction()
     
    271271{
    272272  if( event.type == KeyMapper::PEV_UP)
    273     {
    274273      this->bUp = event.bPressed;
    275     }
    276274  else if( event.type == KeyMapper::PEV_DOWN)
    277     {
    278275      this->bDown = event.bPressed;
    279     }
    280276  else if( event.type == KeyMapper::PEV_RIGHT)
    281     {
    282277      this->bRight= event.bPressed;
    283     }
    284278  else if( event.type == KeyMapper::PEV_LEFT)
    285     {
    286279      this->bLeft = event.bPressed;
    287     }
    288280  else if( event.type == KeyMapper::PEV_FIRE1)
    289     {
    290        this->bFire = event.bPressed;
    291     }
     281      this->bFire = event.bPressed;
    292282  else if( event.type == KeyMapper::PEV_NEXT_WEAPON)
    293     {
    294283      if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;
    295     }
    296 
    297 }
     284
     285}
  • orxonox/branches/weaponSystem/src/world_entities/weapons/test_gun.cc

    r4836 r4878  
    5050
    5151  this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN);
    52   this->idleTime = 0.2f;
    5352  this->leftRight = leftRight;
    5453
     
    145144void TestGun::fire()
    146145{
    147   if( !this->hasWeaponIdleTimeElapsed())
     146  if( !this->stateTimeElapsed())
    148147    {
    149148      this->weaponIdle();
     
    158157  pj->setVelocity(this->getVelocity());
    159158  State::getWorldEntityList()->add(pj);
    160   this->localTime = 0;
    161159
    162160  this->animation1->replay();
     
    191189void TestGun::tick (float time)
    192190{
    193   this->localTime += time;
     191  this->stateTime += time;
    194192}
    195193
  • orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc

    r4836 r4878  
    2525
    2626/**
    27  *  standard constructor
    28 
    29    creates a new weapon
     27 * standard constructor
     28 *
     29 * creates a new weapon
    3030*/
    3131Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction)
    3232{
     33  this->init();
    3334  parent->addChild(this, PNODE_ALL);
    3435  this->setRelCoor(coordinate);
     
    3637}
    3738
    38 
    3939/**
    40  *  standard deconstructor
     40 * standard deconstructor
    4141*/
    4242Weapon::~Weapon ()
     
    5050}
    5151
     52void Weapon::init()
     53{
     54  this->currentState     = WS_INACTIVE;
     55  this->stateTime        = 0.0;
     56  for (int i = 0; i < WS_STATE_COUNT; i++)
     57  {
     58    this->times[i] = 0.0;
     59    this->animation[i] = NULL;
     60  }
     61  for (int i = 0; i < WA_ACTION_COUNT; i++)
     62    this->soundBuffers[i] = NULL;
     63
     64  this->weaponSource = NULL;
     65  this->minCharge;
     66  this->maxCharge;
     67
     68  this->active = false;
     69  this->projectile = NULL;
     70}
    5271
    5372/**
    54   *  enables the weapon
    55 
    56     a weapon can be enabled/disabled because of various reasons. if a weapon is
    57     been enabled, it can interact in a world. elswhere it wont react to any
    58     action.
    59 */
    60 void Weapon::enable()
    61 {
    62   this->enabled = true;
    63 }
    64 
    65 
    66 /**
    67   *  disables the weapon
    68 
    69     a weapon can be enabled/disabled because of various reasons. if a weapon is
    70     been enabled, it can interact in a world. elswhere it wont react to any
    71     action.
    72 */
    73 void Weapon::disable()
    74 {
    75   this->enabled = false;
    76 }
    77 
    78 
    79 /**
    80   *  checks if the weapon is enabled
    81   * @returns true if enabled
    82 
    83     a weapon can be ebabled/disabled because of various reasons. if a weapon is
    84     been enabled, it can interact in a world. elswhere it wont react to any
    85     action.
    86 */
    87 bool Weapon::isEnabled()
    88 {
    89   return this->enabled;
    90 }
    91 
    92 
    93 /**
    94  *  sets a new projectile to the weapon
     73 * sets a new projectile to the weapon
    9574 * @param new projectile for this weapon
    96 
    97    weapon an projectile are independent, so you can combine them as you want
     75 *
     76 * weapon an projectile are independent, so you can combine them as you want
    9877*/
    9978void Weapon::setProjectile(Projectile* projectile)
     
    10483
    10584/**
    106  *  sets a new projectile to the weapon
     85 * sets a new projectile to the weapon
    10786 * @returns the current projectile of this weapon
    108 
    109    weapon an projectile are independent, so you can combine them as you want
     87 *
     88 * weapon an projectile are independent, so you can combine them as you want
    11089*/
    11190Projectile* Weapon::getProjectile()
     
    11695
    11796/**
    118  *  this activates the weapon
    119 
    120    This is needed, since there can be more than one weapon on a ship. the
    121    activation can be connected with an animation. for example the weapon is
    122    been armed out.
     97 * this activates the weapon
     98 *
     99 * This is needed, since there can be more than one weapon on a ship. the
     100 * activation can be connected with an animation. for example the weapon is
     101 * been armed out.
    123102*/
    124103void Weapon::activate()
     
    127106
    128107/**
    129  *  this deactivates the weapon
    130 
    131    This is needed, since there can be more than one weapon on a ship. the
    132    activation can be connected with an animation. for example the weapon is
    133    been armed out.
     108 * this deactivates the weapon
     109 *
     110 * This is needed, since there can be more than one weapon on a ship. the
     111 * activation can be connected with an animation. for example the weapon is
     112 * been armed out.
    134113*/
    135114void Weapon::deactivate()
     
    137116
    138117/**
    139  *  asks if the current weapon is active
    140  * @returns true if it the weapon is active
    141 */
    142 bool Weapon::isActive()
    143 {}
    144 
    145 
    146 
    147 
    148 
    149 
    150 /**
    151  *  is called, when the weapon gets hit (=collide with something)
     118 * is called, when the weapon gets hit (=collide with something)
    152119 * @param from which entity it is been hit
    153120 * @param where it is been hit
    154 
    155    this may not be used, since it would make the game relay complicated when one
    156    can destroy the weapons of enemies or vice versa.
     121 *
     122 * this may not be used, since it would make the game relay complicated when one
     123 * can destroy the weapons of enemies or vice versa.
    157124*/
    158125void Weapon::hit (WorldEntity* entity, const Vector& position)
     
    162129/**
    163130 *  is called, when the weapon is destroyed
    164 
    165    this is in conjunction with the hit function, so when a weapon is able to get
    166    hit, it can also be destoryed.
     131 *
     132 * this is in conjunction with the hit function, so when a weapon is able to get
     133 * hit, it can also be destoryed.
    167134*/
    168135void Weapon::destroy ()
  • 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
  • orxonox/branches/weaponSystem/src/world_entities/world_entity.cc

    r4877 r4878  
    6262
    6363/**
    64  *  loads a Model onto a WorldEntity
     64 * loads a Model onto a WorldEntity
    6565 * @param fileName the name of the model to load
    6666*/
     
    7979
    8080/**
    81  *  sets the character attributes of a worldentity
     81 * sets the character attributes of a worldentity
    8282 * @param character attributes
    83 
    84    these attributes don't have to be set, only use them, if you need them
     83 *
     84 * these attributes don't have to be set, only use them, if you need them
    8585*/
    8686void WorldEntity::setCharacterAttributes(CharacterAttributes* charAttr)
     
    8989
    9090/**
    91  *  gets the Character attributes of this worldentity
     91 * gets the Character attributes of this worldentity
    9292 * @returns character attributes
    9393*/
     
    9595{}
    9696
    97 
    98 /**
    99  *  set the WorldEntity's collision hull
    100  * @param newhull: a pointer to a completely assembled CollisionCluster
    101 
    102    Any previously assigned collision hull will be deleted on reassignment
    103 */
    104 /*
    105 void WorldEntity::setCollision (CollisionCluster* newhull)
    106 {
    107   if( newhull == NULL) return;
    108   if( collisioncluster != NULL) delete collisioncluster;
    109   collisioncluster = newhull;
    110 }
    111 */
    112 
    11397/**
    11498 *  this function is called, when two entities collide
    11599 * @param entity: the world entity with whom it collides
    116 
    117    Implement behaviour like damage application or other miscellaneous collision stuff in this function
     100 *
     101 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
    118102*/
    119103void WorldEntity::collideWith(WorldEntity* entity)
     
    127111 * @param weapon: the laser/rocket/shoot that hits.
    128112 * @param loc: place where it is hit
    129 
    130    calculate the damage depending
     113 *
     114 * calculate the damage depending
    131115*/
    132116void WorldEntity::hit(WorldEntity* weapon, Vector* loc) {}
     
    135119/**
    136120 *  this is called immediately after the Entity has been constructed and initialized
    137 
    138    Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
    139    DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
     121 *
     122 * Put any initialisation code that requires knowledge of location (placement if the Entity is free) and owner of the entity here.
     123 * DO NOT place such code in the constructor, those variables are set AFTER the entity is constucted.
    140124*/
    141125void WorldEntity::postSpawn ()
     
    146130/**
    147131 *  this method is called by the world if the WorldEntity leaves valid gamespace
    148 
    149    For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
    150    place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
     132 *
     133 * For free entities this means it left the Track boundaries. With bound entities it means its Location adresses a
     134 * place that is not in the world anymore. In both cases you might have to take extreme measures (a.k.a. call destroy).
    151135*/
    152136void WorldEntity::leftWorld ()
     
    158142 *  this method is called every frame
    159143 * @param time: the time in seconds that has passed since the last tick
    160 
    161    Handle all stuff that should update with time inside this method (movement, animation, etc.)
     144 *
     145 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
    162146*/
    163147void WorldEntity::tick(float time)
     
    167151/**
    168152 *  the entity is drawn onto the screen with this function
    169 
    170    This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
     153 *
     154 * This is a central function of an entity: call it to let the entity painted to the screen.
     155 * Just override this function with whatever you want to be drawn.
    171156*/
    172157void WorldEntity::draw()
  • orxonox/branches/weaponSystem/src/world_entities/world_entity.h

    r4877 r4878  
    11/*!
    2     \file world_entity.h
    3   * Definition of the basic WorldEntity
     2 * @file world_entity.h
     3 * Definition of the basic WorldEntity
    44*/
    55
     
    88
    99#include "p_node.h"
    10 #include "comincl.h"
    1110#include "resource_manager.h"
    1211#include "factory.h"
     
    1615
    1716
    18 
     17// FORWARD DECLARATION
    1918class CharacterAttributes;
    2019class SoundEngine;
     
    2322
    2423
    25 //! Basic class from which all interactive stuff in the world is derived from
     24//! Basis-class all interactive stuff in the world is derived from
    2625class WorldEntity : public PNode
    2726{
     
    5352  virtual unsigned int getFaceCount () const { if (this->model) return this->model->getFaceCount(); else return 0; };
    5453
     54  virtual void tick (float time);
    5555  virtual void draw ();
    5656  void drawBVTree(int depth, int drawMode);
    57   virtual void tick (float time);
    5857
    5958 protected:
Note: See TracChangeset for help on using the changeset viewer.