Changeset 4878 in orxonox.OLD for orxonox/branches/weaponSystem/src/world_entities/weapons
- Timestamp:
- Jul 17, 2005, 12:37:18 AM (19 years ago)
- Location:
- orxonox/branches/weaponSystem/src/world_entities/weapons
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/weaponSystem/src/world_entities/weapons/test_gun.cc
r4836 r4878 50 50 51 51 this->model = (Model*)ResourceManager::getInstance()->load("models/test_gun.obj", OBJ, RP_CAMPAIGN); 52 this->idleTime = 0.2f;53 52 this->leftRight = leftRight; 54 53 … … 145 144 void TestGun::fire() 146 145 { 147 if( !this-> hasWeaponIdleTimeElapsed())146 if( !this->stateTimeElapsed()) 148 147 { 149 148 this->weaponIdle(); … … 158 157 pj->setVelocity(this->getVelocity()); 159 158 State::getWorldEntityList()->add(pj); 160 this->localTime = 0;161 159 162 160 this->animation1->replay(); … … 191 189 void TestGun::tick (float time) 192 190 { 193 this-> localTime += time;191 this->stateTime += time; 194 192 } 195 193 -
orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.cc
r4836 r4878 25 25 26 26 /** 27 * 28 29 27 * standard constructor 28 * 29 * creates a new weapon 30 30 */ 31 31 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 32 32 { 33 this->init(); 33 34 parent->addChild(this, PNODE_ALL); 34 35 this->setRelCoor(coordinate); … … 36 37 } 37 38 38 39 39 /** 40 * 40 * standard deconstructor 41 41 */ 42 42 Weapon::~Weapon () … … 50 50 } 51 51 52 void 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 } 52 71 53 72 /** 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 95 74 * @param new projectile for this weapon 96 97 75 * 76 * weapon an projectile are independent, so you can combine them as you want 98 77 */ 99 78 void Weapon::setProjectile(Projectile* projectile) … … 104 83 105 84 /** 106 * 85 * sets a new projectile to the weapon 107 86 * @returns the current projectile of this weapon 108 109 87 * 88 * weapon an projectile are independent, so you can combine them as you want 110 89 */ 111 90 Projectile* Weapon::getProjectile() … … 116 95 117 96 /** 118 * 119 120 121 122 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. 123 102 */ 124 103 void Weapon::activate() … … 127 106 128 107 /** 129 * 130 131 132 133 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. 134 113 */ 135 114 void Weapon::deactivate() … … 137 116 138 117 /** 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) 152 119 * @param from which entity it is been hit 153 120 * @param where it is been hit 154 155 156 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. 157 124 */ 158 125 void Weapon::hit (WorldEntity* entity, const Vector& position) … … 162 129 /** 163 130 * is called, when the weapon is destroyed 164 165 166 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. 167 134 */ 168 135 void Weapon::destroy () -
orxonox/branches/weaponSystem/src/world_entities/weapons/weapon.h
r4876 r4878 78 78 void loadParams(const TiXmlElement* root); 79 79 80 void enable();81 void disable();82 bool isEnabled();83 84 80 void setProjectile(Projectile* projectile); 85 81 Projectile* getProjectile(); … … 87 83 virtual void activate(); 88 84 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; }; 90 89 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; }; 98 96 99 97 /** fires the weapon */ 100 virtual void fire() = 0;101 98 virtual void hit (WorldEntity* weapon, const Vector& loc); 102 99 virtual void destroy(); … … 107 104 108 105 protected: 109 float localTime; //<! this is the local time. important for shooting attributes like frequency110 float idleTime; //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay111 float slowDownFactor; //<! if the shooting frequency is a linear function of time...112 113 106 //////////// 114 107 // PHASES // 115 108 //////////// 116 109 WeaponState currentState; //!< The State the weapon is in. 117 float stateTime; //!< how long the state has t eken until now.110 float stateTime; //!< how long the state has taken until now. 118 111 float times[WS_STATE_COUNT]; //!< Times to stay in the different States @see WeaponState. 119 112 SoundBuffer* soundBuffers[WA_ACTION_COUNT]; //!< SoundBuffers for all actions @see WeaponAction. … … 127 120 128 121 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 132 124 }; 133 125
Note: See TracChangeset
for help on using the changeset viewer.