Changeset 10362 in orxonox.OLD for branches/playability.new/src/world_entities/weapons/weapon.cc
- Timestamp:
- Jan 25, 2007, 3:05:01 AM (17 years ago)
- Location:
- branches/playability.new
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability.new
- Property svn:ignore
-
old new 10 10 autom4te.cache 11 11 aclocal.m4 12 tags 13 test.bmp 14 config.sub 15 config.guess 16 OrxonoxPlayability.kdevses 17 OrxonoxPlayability.kdevelop.pcs
-
- Property svn:ignore
-
branches/playability.new/src/world_entities/weapons/weapon.cc
r9869 r10362 33 33 #include "resource_sound_buffer.h" 34 34 35 #include "elements/glgui_energywidget .h"35 #include "elements/glgui_energywidgetvertical.h" 36 36 37 37 ObjectListDefinition(Weapon); … … 119 119 } 120 120 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource. 122 this->emissionPoint.setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles 123 this->emissionPoint.setName("EmissionPoint"); 124 this->emissionPoint.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource 122 123 this->barrels = 1; 124 this->segs = 1; 125 126 this->shootAnim = new Animation3D**[this->getBarrels()]; 127 for (int i = 0; i < this->getBarrels(); i++) 128 this->shootAnim[i] = new Animation3D* [this->getSegs()]; 129 130 this->emissionPoint = new PNode*[this->barrels]; 131 for(int i = 0; i < this->barrels; i++){ 132 this->emissionPoint[i] = new PNode; 133 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles 134 this->emissionPoint[i]->setName("EmissionPoint"); 135 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 136 } 125 137 126 138 this->defaultTarget = NULL; //< Nothing is Targeted by default. … … 145 157 146 158 /** 159 * needed, if there are more than one barrel or segments 160 */ 161 void Weapon::init2() 162 { 163 if (this->barrels == 1 && this->segs == 1) 164 return; 165 166 delete this->emissionPoint[0]; 167 delete this->emissionPoint; 168 delete this->shootAnim[0]; 169 delete this->shootAnim; 170 171 this->shootAnim = new Animation3D**[this->barrels]; 172 this->emissionPoint = new PNode*[this->barrels]; 173 for(int i = 0; i < this->barrels; i++){ 174 this->emissionPoint[i] = new PNode; 175 this->emissionPoint[i]->setParent(this); //< One EmissionPoint, that is a PNode connected to the weapon. You can set this to the exitting point of the Projectiles 176 this->emissionPoint[i]->setName("EmissionPoint"); 177 this->emissionPoint[i]->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 178 this->shootAnim[i] = new Animation3D* [this->segs]; 179 } 180 } 181 182 /** 183 * deconstructor for init2 184 */ 185 void Weapon::deconstr() 186 { 187 for(int i = 0; i < this->barrels; i++) { 188 delete this->emissionPoint[i]; 189 for (int j = 0; j < this->segs; j++) 190 delete this->shootAnim[i][j]; 191 delete this->shootAnim[i]; 192 } 193 194 delete this->emissionPoint; 195 delete this->shootAnim; 196 } 197 198 /** 147 199 * loads the Parameters of a Weapon 148 200 * @param root the XML-Element to load the Weapons settings from … … 154 206 LoadParam(root, "projectile", this, Weapon, setProjectileTypeC) 155 207 .describe("Sets the name of the Projectile to load onto the Entity"); 156 208 /* 157 209 LoadParam(root, "emission-point", this, Weapon, setEmissionPoint) 158 .describe("Sets the Point of emission of this weapon ");210 .describe("Sets the Point of emission of this weapon (1: EmmsionVector; 2: EmissionPoint)");*/ 159 211 160 212 LoadParam(root, "state-duration", this, Weapon, setStateDuration) … … 253 305 * @param point the Point relative to the mass-point of the Weapon 254 306 */ 307 void Weapon::setEmissionPoint(const Vector& point, int barrel) 308 { 309 this->emissionPoint[barrel]->setRelCoor(point); 310 } 311 255 312 void Weapon::setEmissionPoint(const Vector& point) 256 313 { 257 this->emissionPoint.setRelCoor(point); 258 } 259 314 this->emissionPoint[0]->setRelCoor(point); 315 } 260 316 261 317 /** … … 315 371 } 316 372 373 Animation3D* Weapon::getAnimation(int barrel, int seg, PNode* node) 374 { 375 if (barrel >= this->getBarrels() || seg >= this->getSegs()) // if the state is not known 376 return NULL; 377 378 if (unlikely(this->shootAnim[barrel][seg] == NULL)) // if the animation does not exist yet create it. 379 { 380 if (likely(node != NULL)) 381 return this->shootAnim[barrel][seg] = new Animation3D(node); 382 else 383 { 384 // PRINTF(2)("Node not defined for the Creation of the 3D-animation of state %s\n", stateToChar(state)); 385 return NULL; 386 } 387 } 388 else 389 return this->shootAnim[barrel][seg]; 390 } 391 317 392 OrxGui::GLGuiWidget* Weapon::getEnergyWidget() 318 393 { 319 if ( this->energyWidget == NULL)320 { 321 this->energyWidget = new OrxGui::GLGuiEnergyWidget ();322 this->energyWidget->setDisplayedName(this->getClassCName());394 if ( this->energyWidget == NULL) 395 { 396 this->energyWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 397 //this->energyWidget->setDisplayedName(this->getClassCName()); 323 398 this->energyWidget->setSize2D( 20, 100); 324 399 this->energyWidget->setMaximum(this->getEnergyMax()); … … 352 427 if (likely(this->isActive())) 353 428 { 429 /** Disabled for releaseFire() from WM*/ 354 430 if (this->requestedAction != WA_NONE) 355 431 return; … … 378 454 { 379 455 this->energy += energyToAdd; 456 this->updateWidgets(); 380 457 return 0.0; 381 458 } … … 383 460 { 384 461 this->energy += maxAddEnergy; 462 this->updateWidgets(); 385 463 return energyToAdd - maxAddEnergy; 386 464 } 465 387 466 } 388 467 … … 431 510 break; 432 511 default: 433 PRINTF( 2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));512 PRINTF(5)("Action %s Not Implemented yet \n", Weapon::actionToChar(action)); 434 513 return false; 435 514 } … … 507 586 bool Weapon::fireW() 508 587 { 588 // printf("fireW Weapon\n"); 509 589 //if (likely(this->currentState != WS_INACTIVE)) 510 590 if (this->minCharge <= this->energy) … … 513 593 if (this->soundBuffers[WA_SHOOT].loaded()) 514 594 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 515 this->updateWidgets();516 595 // fire 517 596 this->energy -= this->minCharge; … … 519 598 // setting up for the next state 520 599 this->enterState(WS_SHOOTING); 600 this->updateWidgets(); 521 601 } 522 602 else // reload if we still have the charge … … 538 618 unlikely(this->energy + this->ammoContainer->getStoredEnergy() < this->minCharge)) 539 619 { 540 this->requestAction(WA_DEACTIVATE);620 //this->requestAction(WA_DEACTIVATE); 541 621 this->execute(); 542 622 return false;
Note: See TracChangeset
for help on using the changeset viewer.