Changeset 4895 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons
- Timestamp:
- Jul 19, 2005, 6:27:06 PM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4893 r4895 53 53 54 54 this->objectComponent1 = new PNode(); 55 Animation3D* animation1 = this-> createAnimation(WS_SHOOTING, this->objectComponent1);56 Animation3D* animation2 = this-> createAnimation(WS_ACTIVATING, this);57 Animation3D* animation3 = this-> createAnimation(WS_DEACTIVATING, this);55 Animation3D* animation1 = this->getAnimation(WS_SHOOTING, this->objectComponent1); 56 Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); 57 Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); 58 58 //parent->addChild(this->objectComponent1, PNODE_ALL); 59 59 this->addChild(this->objectComponent1, PNODE_ALL); … … 85 85 animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT); 86 86 87 animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0. 1, ANIM_LINEAR, ANIM_CONSTANT);88 animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0. 1, ANIM_LINEAR, ANIM_CONSTANT);89 90 animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0. 1, ANIM_LINEAR, ANIM_CONSTANT);91 animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0. 1, ANIM_LINEAR, ANIM_CONSTANT);87 animation2->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 88 animation2->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 89 90 animation3->addKeyFrame(Vector(-2.6, 0.1, -3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 91 animation3->addKeyFrame(Vector(-2.6, 0.1, -2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 92 92 } 93 93 /* … … 102 102 this->setStateDuration(WS_SHOOTING, .2); 103 103 this->setStateDuration(WS_RELOADING, .5); 104 //this->setStateDuration(WS_ACTIVATING, .4); 105 //this->setStateDuration(WS_DEACTIVATING, .4); 104 106 105 107 this->energy = 100; … … 181 183 void TestGun::destroy () 182 184 {} 183 184 185 /**186 * is called, when there is no fire button pressed187 */188 void TestGun::weaponIdle()189 {}190 191 185 192 186 /** -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4893 r4895 45 45 virtual void destroy(); 46 46 47 virtual void weaponIdle();48 47 virtual void draw(); 49 48 -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4894 r4895 129 129 130 130 /** 131 * creates an Animation3D for a certain State.132 * @param state what state should the Animation be created for133 * @param node the node this Animation should apply to. 134 * @returns The created animation.Animation(), NULL on error .131 * creates/returns an Animation3D for a certain State. 132 * @param state what State should the Animation be created/returned for 133 * @param node the node this Animation should apply to. (NULL is fine if the animation was already created) 134 * @returns The created animation.Animation(), NULL on error (or if the animation does not yet exist). 135 135 * 136 136 * This function does only generate the Animation Object, and if set it will … … 138 138 * What this does not do, is set keyframes, you have to operate on the returned animation. 139 139 */ 140 Animation3D* Weapon:: createAnimation(WeaponState state, PNode* node)141 { 142 if (state >= WS_STATE_COUNT || node == NULL)140 Animation3D* Weapon::getAnimation(WeaponState state, PNode* node) 141 { 142 if (state >= WS_STATE_COUNT) // if the state is not known 143 143 return NULL; 144 144 145 if (unlikely(this->animation[state] != NULL)) 146 { 147 delete this->animation[state]; 148 this->animation[state] = NULL; 149 } 150 return this->animation[state] = new Animation3D(node); 145 if (unlikely(this->animation[state] == NULL)) // if the animation does not exist yet create it. 146 { 147 if (likely(node != NULL)) 148 return this->animation[state] = new Animation3D(node); 149 else 150 { 151 PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state)); 152 return NULL; 153 } 154 } 155 else 156 return this->animation[state]; 151 157 } 152 158 … … 156 162 // GAME ACTION // 157 163 ///////////////// 158 159 164 /** 160 165 * request an action that should be executed, … … 241 246 bool Weapon::activateW() 242 247 { 243 244 if (this->currentState == WS_INACTIVE) 248 // if (this->currentState == WS_INACTIVE) 245 249 { 246 250 // play Sound … … 250 254 this->animation[WS_ACTIVATING]->replay(); 251 255 // activate 252 PRINTF( 5)("Activating the Weapon %s\n", this->getName());256 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 253 257 this->activate(); 254 // setting up for next action255 this->requestedAction = WA_NONE;258 this->active = true; 259 // setting up for next action 256 260 this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration; 257 261 } 262 this->requestedAction = WA_NONE; 258 263 } 259 264 … … 275 280 // deactivate 276 281 this->deactivate(); 282 this->active = false; 277 283 // setting up for next action 278 this->requestedAction = WA_NONE;279 284 this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration; 280 285 } 281 286 this->requestedAction = WA_NONE; 282 287 } 283 288 … … 414 419 // HELPER FUNCTIONS // 415 420 ////////////////////// 416 // inclass417 /**418 * checks if the next Action given is valid419 * @returns if the Action that comes next is valid420 * @todo more checks421 */422 bool Weapon::nextActionValid() const423 {424 if (this->currentState == WS_INACTIVE)425 {426 return (this->requestedAction == WA_ACTIVATE || this->requestedAction == WA_NONE);427 }428 else429 return true;430 431 }432 433 434 421 /** 435 422 * checks wether all the Weapons functions are valid, and if it is possible to go to action with it. -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4893 r4895 112 112 void setActionSound(const char* action, const char* soundFile) { this->setActionSound(charToAction(action), soundFile); }; 113 113 114 Animation3D* createAnimation(WeaponState state, PNode* node);114 Animation3D* getAnimation(WeaponState state, PNode* node = NULL); 115 115 116 116 // FLOW … … 137 137 static const char* stateToChar(WeaponState state); 138 138 139 140 139 private: 141 140 /** executive functions, that handle timing with actions. … … 151 150 bool fireW(); 152 151 bool reloadW(); 153 154 bool nextActionValid() const;155 156 152 157 153 -
orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
r4885 r4895 76 76 } 77 77 this->currConfID = W_CONFIG0; 78 79 80 81 78 82 this->crosshair = new Crosshair(); 79 83 … … 237 241 { 238 242 Weapon* w; 243 for (int j = 0; j < 4; ++j ) 244 for(int i = 0; i < W_MAX_SLOTS; ++i) 245 { 246 w = this->configs[j].slots[i]; 247 if( w != NULL) w->tick(dt); 248 } 249 250 crosshair->setRotationSpeed(5); 251 } 252 253 254 /** 255 * triggers draw of all weapons in the current weaponconfig 256 */ 257 void WeaponManager::draw() 258 { 259 Weapon* w; 260 for (int j = 0; j < 4; ++j ) 239 261 for(int i = 0; i < W_MAX_SLOTS; ++i) 240 262 { 241 w = this->configs[this->currConfID].slots[i]; 242 if( w != NULL) w->tick(dt); 243 } 244 245 crosshair->setRotationSpeed(5); 246 } 247 248 249 /** 250 * triggers draw of all weapons in the current weaponconfig 251 */ 252 void WeaponManager::draw() 253 { 254 Weapon* w; 255 for(int i = 0; i < W_MAX_SLOTS; ++i) 256 { 257 w = this->configs[this->currConfID].slots[i]; 263 w = this->configs[j].slots[i]; 258 264 if( w != NULL) 259 265 w->draw();
Note: See TracChangeset
for help on using the changeset viewer.