Changeset 4891 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Jul 19, 2005, 3:21:43 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities/weapons
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4890 r4891 87 87 88 88 89 /** 90 * assigns a Sound-file to an action 91 * @param action the action the sound should be assigned too 92 * @param soundFile the soundFile's relative position to the data-directory (will be looked for by the ResourceManager) 93 */ 89 94 void Weapon::setActionSound(WeaponAction action, const char* soundFile) 90 95 { … … 147 152 } 148 153 154 /** 155 * executes an action, and with it starts a new State. 156 * @return true, if it worked, false otherwise 157 * 158 * This function checks, wheter the possibility of executing an action is valid, 159 * and does all the necessary stuff, to execute them. If an action does not succeed, 160 * it tries to go around it. (ex. shoot->noAmo->reload()->wait until shoot comes again) 161 */ 149 162 bool Weapon::execute() 150 163 { 151 this->stateDuration = this->times[this->requestedAction] + this->stateDuration;152 164 153 165 PRINTF(4)("trying to execute action %s\n", actionToChar(this->requestedAction)); … … 161 173 if (this->minCharge <= this->energyLoaded) 162 174 { 175 // playing Sound 163 176 if (this->soundBuffers[WA_SHOOT] != NULL) 164 177 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 178 // fire 165 179 this->fire(); 180 // setting up for the next state 181 this->stateDuration = this->times[WA_SHOOT] + this->stateDuration; 166 182 this->requestedAction = WA_NONE; 167 183 } … … 176 192 if ( this->currentState != WS_INACTIVE && this->energyLoaded >= this->minCharge) 177 193 { 194 // playing Sound 178 195 if (this->soundBuffers[WA_CHARGE] != NULL) 179 196 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 197 // charge 180 198 this->charge(); 199 // setting up for the next state 181 200 this->requestedAction = WA_NONE; 201 this->stateDuration = this->times[WA_CHARGE] + this->stateDuration; 182 202 } 183 203 else // deactivate the Weapon if we do not have enough energy … … 190 210 //if (this->currentState != WS_INACTIVE && this->energy + this->energyLoaded >= this->minCharge) 191 211 { 212 // playing Sound 192 213 if (this->soundBuffers[WA_RELOAD] != NULL) 193 214 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 194 215 // reload 195 216 this->reload(); 217 // setting up for next action 196 218 this->requestedAction = WA_NONE; 219 this->stateDuration = this->times[WA_RELOAD] + this->stateDuration; 197 220 } 198 221 break; … … 200 223 if (this->currentState != WS_INACTIVE) 201 224 { 225 // play Sound 202 226 if (this->soundBuffers[WA_DEACTIVATE] != NULL) 203 227 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 204 228 // deactivate 205 229 this->deactivate(); 230 // setting up for next action 206 231 this->requestedAction = WA_NONE; 232 this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration; 207 233 } 208 234 break; … … 210 236 if (this->currentState == WS_INACTIVE) 211 237 { 238 // play Sound 212 239 if (this->soundBuffers[WA_ACTIVATE] != NULL) 213 240 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 214 241 // activate 215 242 this->activate(); 243 // setting up for next action 216 244 this->requestedAction = WA_NONE; 245 this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration; 217 246 } 218 247 break; … … 349 378 } 350 379 380 381 /** 382 * checks wether all the Weapons functions are valid, and if it is possible to go to action with it. 383 * 384 */ 385 bool Weapon::check() const 386 { 387 bool retVal = true; 388 389 if (this->projectile == NULL) 390 { 391 PRINTF(2)("There was no projectile assigned to the Weapon.\n"); 392 retVal = false; 393 } 394 395 396 397 398 return retVal; 399 } 351 400 352 401 /** -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4890 r4891 115 115 virtual void draw(); 116 116 117 bool check() const; 117 118 void debug() const; 118 119 … … 132 133 static WeaponState charToState(const char* state); 133 134 static const char* stateToChar(WeaponState state); 135 136 134 137 private: 135 138 bool nextActionValid() const;
Note: See TracChangeset
for help on using the changeset viewer.