Changeset 6438 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 8, 2006, 1:51:55 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/player.cc
r6241 r6438 22 22 #include "class_list.h" 23 23 #include "state.h" 24 #include "util/hud.h" 24 25 25 26 using namespace std; … … 56 57 57 58 this->controllable = NULL; 59 this->hud = new Hud(); 58 60 } 59 61 … … 95 97 if (this->controllable != (*node) && (dynamic_cast<PNode*>(*node)->getAbsCoor() - this->controllable->getAbsCoor()).len() < 10.0) 96 98 { 97 99 98 100 this->disconnectControllable(); 99 101 this->setControllable(dynamic_cast<Playable*>(*node)); -
trunk/src/world_entities/player.h
r5915 r6438 11 11 /* Forward Declaration */ 12 12 class Playable; 13 class Hud; 13 14 14 15 //! Basic controllable WorldEntity … … 39 40 private: 40 41 Playable* controllable; //!< The one we controll or NULL if none 42 Hud* hud; //!< The HUD to be displayed. 41 43 }; 42 44 -
trunk/src/world_entities/weapons/turret.cc
r6435 r6438 96 96 this->setEmissionPoint(1.684, 0.472, 0); 97 97 //this->getProjectileFactory()->prepare(100); 98 99 this->bar = new GLGuiBar;100 this->bar->setSize2D( 20, 100);101 this->bar->setMaximum(this->getEnergyMax());102 this->bar->setValue(this->getEnergy());103 this->loadedBar = new GLGuiBar;104 this->loadedBar->setParent2D(this->bar);105 this->loadedBar->setRelCoor2D(20,0);106 this->loadedBar->setSize2D(10,50);107 this->loadedBar->setMaximum(this->getLoadedEnergyMax());108 98 } 109 99 … … 116 106 void Turret::activate() 117 107 { 118 this->bar->show();119 this->loadedBar->show();120 108 } 121 109 122 110 void Turret::deactivate() 123 111 { 124 this->bar->hide();125 this->loadedBar->hide();126 112 } 127 113 … … 156 142 pj->setAbsDir(this->getAbsDir()); 157 143 pj->activate(); 158 159 this->bar->setValue( this->getEnergy());160 this->loadedBar->setValue(this->getLoadedEnergy());161 144 } 162 145 -
trunk/src/world_entities/weapons/turret.h
r6306 r6438 8 8 9 9 #include "weapon.h" 10 11 #include "glgui_bar.h"12 10 13 11 class Turret : public Weapon … … 30 28 31 29 private: 32 GLGuiBar* bar;33 GLGuiBar* loadedBar;34 30 }; 35 31 -
trunk/src/world_entities/weapons/weapon.cc
r6435 r6438 34 34 #include "sound_buffer.h" 35 35 36 #include "glgui_bar.h" 37 36 38 //////////////////// 37 39 // INITAILISATION // … … 75 77 this->stateDuration = 0.0; //< All the States have zero duration 76 78 for (int i = 0; i < WS_STATE_COUNT; i++) //< Every State has: 77 78 79 80 79 { 80 this->times[i] = 0.0; //< An infinitesimal duration 81 this->animation[i] = NULL; //< No animation 82 } 81 83 for (int i = 0; i < WA_ACTION_COUNT; i++) 82 84 this->soundBuffers[i] = NULL; //< No Sounds … … 98 100 this->energyMax = 10.0; //< How much energy can be carried 99 101 this->capability = WTYPE_ALL; //< The Weapon has all capabilities @see W_Capability. 102 103 this->energyWidget = NULL; 104 this->energyLoadedWidget = NULL; 100 105 } 101 106 … … 109 114 110 115 LoadParam(root, "projectile", this, Weapon, setProjectileType) 111 116 .describe("Sets the name of the Projectile to load onto the Entity"); 112 117 113 118 LoadParam(root, "emission-point", this, Weapon, setEmissionPoint) 114 119 .describe("Sets the Point of emission of this weapon"); 115 120 116 121 LoadParam(root, "state-duration", this, Weapon, setStateDuration) 117 122 .describe("Sets the duration of a given state (1: state-Name; 2: duration in seconds)"); 118 123 119 124 LoadParam(root, "action-sound", this, Weapon, setActionSound) 120 125 .describe("Sets a given sound to an action (1: action-Name; 2: name of the sound (relative to the Data-Path))"); 121 126 } 122 127 … … 271 276 } 272 277 278 GLGuiWidget* Weapon::getEnergyWidget() 279 { 280 if (this->energyWidget == NULL) 281 { 282 this->energyWidget = new GLGuiBar; 283 this->energyWidget->setSize2D( 20, 100); 284 this->energyWidget->setMaximum(this->getEnergyMax()); 285 this->energyWidget->setValue(this->getEnergy()); 286 } 287 return this->energyWidget; 288 } 289 290 291 GLGuiWidget* Weapon::getMaxEnergyWidget() 292 { 293 if (this->energyLoadedWidget == NULL) 294 { 295 this->energyLoadedWidget = new GLGuiBar; 296 //this->energyLoadedWidget->setParent2D(this->bar); 297 this->energyLoadedWidget->setRelCoor2D(20,0); 298 this->energyLoadedWidget->setSize2D(10,50); 299 this->energyLoadedWidget->setMaximum(this->getLoadedEnergyMax()); 300 } 301 return this->energyLoadedWidget; 302 } 303 304 void Weapon::updateWidgets() 305 { 306 if (this->energyWidget != NULL) 307 { 308 this->energyWidget->setMaximum(this->energyMax); 309 this->energyWidget->setValue(this->energy); 310 } 311 if (this->energyLoadedWidget != NULL) 312 { 313 this->energyLoadedWidget->setMaximum(this->energyLoadedMax); 314 this->energyLoadedWidget->setValue(this->energyLoaded); 315 } 316 } 317 273 318 ///////////////// 274 319 // EXECUTION // … … 371 416 bool Weapon::activateW() 372 417 { 373 // if (this->currentState == WS_INACTIVE)418 // if (this->currentState == WS_INACTIVE) 374 419 { 375 420 // play Sound 376 421 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL)) 377 422 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 378 423 // activate 379 424 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 380 425 this->activate(); … … 390 435 bool Weapon::deactivateW() 391 436 { 392 // if (this->currentState != WS_INACTIVE)437 // if (this->currentState != WS_INACTIVE) 393 438 { 394 439 PRINTF(4)("Deactivating the Weapon %s\n", this->getName()); 395 440 // play Sound 396 441 if (this->soundBuffers[WA_DEACTIVATE] != NULL) 397 442 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); … … 410 455 if ( this->currentState != WS_INACTIVE && this->energyLoaded >= this->minCharge) 411 456 { 412 457 // playing Sound 413 458 if (this->soundBuffers[WA_CHARGE] != NULL) 414 459 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 415 460 416 461 // charge 417 462 this->charge(); 418 463 // setting up for the next state 419 464 this->enterState(WS_CHARGING); 420 465 } … … 431 476 bool Weapon::fireW() 432 477 { 433 478 //if (likely(this->currentState != WS_INACTIVE)) 434 479 if (this->minCharge <= this->energyLoaded) 435 480 { 436 481 // playing Sound 437 482 if (this->soundBuffers[WA_SHOOT] != NULL) 438 483 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 439 484 // fire 440 485 this->energyLoaded -= this->minCharge; 441 486 this->fire(); 442 487 // setting up for the next state 443 488 this->enterState(WS_SHOOTING); 444 489 } … … 546 591 bool retVal = true; 547 592 548 // if (this->projectile == NULL)593 // if (this->projectile == NULL) 549 594 { 550 595 PRINTF(1)("There was no projectile assigned to the Weapon.\n"); … … 565 610 PRINT(0)("Weapon-Debug %s, state: %s (duration: %fs), nextAction: %s\n", this->getName(), Weapon::stateToChar(this->currentState), this->stateDuration, Weapon::actionToChar(requestedAction)); 566 611 PRINT(0)("Energy: max: %f; current: %f; loadedMax: %f; loadedCurrent: %f; chargeMin: %f, chargeMax %f\n", 567 612 this->energyMax, this->energy, this->energyLoadedMax, this->energyLoaded, this->minCharge, this->maxCharge); 568 613 569 614 … … 595 640 return WA_SPECIAL1; 596 641 else 597 598 599 600 642 { 643 PRINTF(2)("action %s could not be identified.\n", action); 644 return WA_NONE; 645 } 601 646 } 602 647 … … 658 703 return WS_IDLE; 659 704 else 660 661 662 663 705 { 706 PRINTF(2)("state %s could not be identified.\n", state); 707 return WS_NONE; 708 } 664 709 } 665 710 -
trunk/src/world_entities/weapons/weapon.h
r6435 r6438 24 24 class FastFactory; 25 25 template<class T> class tFastFactory; 26 class GLGuiWidget; 26 27 27 28 //! An enumerator defining Actions a Weapon can take … … 148 149 Animation3D* copyAnimation(WeaponState from, WeaponState to); 149 150 151 GLGuiWidget* getEnergyWidget(); 152 GLGuiWidget* getMaxEnergyWidget(); 153 150 154 // FLOW 151 155 void tick(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within … … 183 187 bool fireW(); 184 188 bool reloadW(); 185 186 189 inline void enterState(WeaponState state); 187 190 191 void updateWidgets(); 188 192 189 193 private: … … 200 204 float maxCharge; //!< The maximal energy to be loaded onto one projectile (this is only availible if chargeable is enabled) 201 205 206 GLGuiBar* energyWidget; 207 GLGuiBar* energyLoadedWidget; 208 202 209 //////////// 203 210 // PHASES //
Note: See TracChangeset
for help on using the changeset viewer.