Changeset 9965 in orxonox.OLD for branches/playability/src
- Timestamp:
- Nov 28, 2006, 11:54:34 PM (18 years ago)
- Location:
- branches/playability/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/util/hud.cc
r9869 r9965 45 45 //this->setSize2D( 46 46 this->weaponManager = NULL; 47 this->weaponManagerSecondary = NULL; 47 48 this->energyWidget = NULL; 48 49 this->shieldWidget = NULL; … … 118 119 {} 119 120 120 void Hud::setWeaponManager(WeaponManager* weaponMan )121 void Hud::setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec) 121 122 { 122 123 if (this->weaponManager != NULL) … … 133 134 } 134 135 136 if (this->weaponManagerSecondary != NULL) 137 { 138 for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++) 139 { 140 Weapon* weapon = this->weaponManagerSecondary->getWeapon(i); 141 if (weapon != NULL) 142 { 143 weapon->getEnergyWidget()->hide(); 144 this->weaponsWidgets.remove(weapon->getEnergyWidget()); 145 } 146 } 147 } 148 135 149 this->weaponManager = weaponMan; 150 this->weaponManagerSecondary = weaponManSec; 136 151 137 152 this->updateWeaponManager(); … … 164 179 } 165 180 } 181 182 if (this->weaponManagerSecondary != NULL) 183 for (unsigned int i = 0; i < this->weaponManagerSecondary->getSlotCount(); i++) 184 { 185 Weapon* weapon = this->weaponManagerSecondary->getWeapon(i); 186 if (weapon != NULL) 187 { 188 //PRINTF(0)("WEAPON %s::%s in Slots\n", weapon->getClassCName(), weapon->getName()); 189 weapon->getEnergyWidget()->show(); 190 weapon->getEnergyWidget()->setBackgroundColor(Color(.8,.2,.11, 0.1)); 191 weapon->getEnergyWidget()->setFrontColor(Color( .2,.5,.7,.6)); 192 // weapon->getEnergyWidget()->frontMaterial().setTransparency(.6); 193 this->weaponsWidgets.push_back(weapon->getEnergyWidget()); 194 } 195 } 196 166 197 this->updateResolution(); 198 167 199 } 168 200 -
branches/playability/src/util/hud.h
r9869 r9965 39 39 void setShiledWidget(OrxGui::GLGuiWidget* widget); 40 40 void setArmorWidget(OrxGui::GLGuiWidget* widget); 41 void setWeaponManager(WeaponManager* weaponMan );41 void setWeaponManager(WeaponManager* weaponMan, WeaponManager* weaponManSec = NULL); 42 42 43 43 void addWeaponWidget(OrxGui::GLGuiWidget* widget); … … 68 68 69 69 WeaponManager* weaponManager; 70 WeaponManager* weaponManagerSecondary; 70 71 71 72 std::list<OrxGui::GLGuiWidget*> weaponsWidgets; //!< WeaponWidgets will be displayed one after another -
branches/playability/src/world_entities/space_ships/space_ship.cc
r9963 r9965 84 84 */ 85 85 SpaceShip::SpaceShip(const std::string& fileName) 86 : primWeaponMan(this), 87 secWeaponMan(this), 86 : secWeaponMan(this), 88 87 supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical), 89 88 playmode(Playable::Full3D) … … 108 107 */ 109 108 SpaceShip::SpaceShip(const TiXmlElement* root) 110 : primWeaponMan(this), 111 secWeaponMan(this), 109 : secWeaponMan(this), 112 110 supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical), 113 111 playmode(Playable::Full3D) … … 140 138 141 139 142 this-> primWeaponMan.addWeapon( wpLeft, 1, 0);143 this-> primWeaponMan.addWeapon( wpRight, 1, 1);144 this->secWeaponMan.addWeapon( cannon, 0, 6);145 146 this-> primWeaponMan.changeWeaponConfig(1);140 this->weaponMan.addWeapon( wpLeft, 0, 0); 141 this->weaponMan.addWeapon( wpRight, 0, 1); 142 this->secWeaponMan.addWeapon( cannon, 0, 0); 143 144 this->weaponMan.changeWeaponConfig(0); 147 145 148 146 wpRight->requestAction(WA_ACTIVATE); 149 147 wpLeft->requestAction(WA_ACTIVATE); 150 148 cannon->requestAction(WA_ACTIVATE); 149 150 this->curWeaponPrimary = 0; 151 this->curWeaponSecondary = 0; 152 153 Playable::weaponConfigChanged(); 154 155 weaponEnergyRegen = 10; // 10 einheiten pro Sekunde 156 151 157 /* 152 158 this->addWeapon(wpLeft, 1, 0); … … 159 165 this->loadModel("models/ships/hoverglider_mainbody.obj"); 160 166 161 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = b PrimFire = bSecFire = false;167 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 162 168 163 169 xMouse = yMouse = 0; … … 178 184 this->mouseDir = this->getAbsDir(); 179 185 this->pitchDir = this->getAbsDir(); 186 180 187 181 188 // GLGuiButton* button = new GLGuiPushButton(); … … 205 212 registerEvent(EV_MOUSE_MOTION); 206 213 207 this->primWeaponMan.setSlotCount(6); 208 209 this->primWeaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0)); 210 this->primWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 211 212 this->primWeaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0)); 213 this->primWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 214 215 this->primWeaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5)); 216 this->primWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 217 218 this->primWeaponMan.setSlotPosition(3, Vector(-1.5, .5, .5)); 219 this->primWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 220 221 this->primWeaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5)); 222 this->primWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 223 224 this->primWeaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5)); 225 this->primWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 226 // 227 this->primWeaponMan.setSlotPosition(6, Vector(-1, 0.0, 0)); 228 this->primWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 214 this->weaponMan.setSlotCount(6); 215 216 this->weaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0)); 217 this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 218 219 this->weaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0)); 220 this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 221 222 this->weaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5)); 223 this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0))); 224 225 this->weaponMan.setSlotPosition(3, Vector(-1.5, .5, .5)); 226 this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0))); 227 228 this->weaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5)); 229 this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0))); 230 231 this->weaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5)); 232 this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 229 233 230 234 this->secWeaponMan.setSlotCount(6); 231 235 232 this->secWeaponMan.setSlotPosition(0, Vector(2.6, - 0.5, 0));236 this->secWeaponMan.setSlotPosition(0, Vector(2.6, -2.5, 0)); 233 237 this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 234 238 … … 247 251 this->secWeaponMan.setSlotPosition(5, Vector(1.5, -.5, -.5)); 248 252 this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 249 // 250 this->secWeaponMan.setSlotPosition(6, Vector(1, 0.0, 0)); 251 this->secWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 253 252 254 // 253 255 // this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); … … 257 259 // this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));: 258 260 259 this-> primWeaponMan.getFixedTarget()->setParent(this);260 this-> primWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);261 this->weaponMan.getFixedTarget()->setParent(this); 262 this->weaponMan.getFixedTarget()->setRelCoor(100000,0,0); 261 263 262 264 this->secWeaponMan.getFixedTarget()->setParent(this); 263 265 this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0); 264 266 265 dynamic_cast<Element2D*>(this-> primWeaponMan.getFixedTarget())->setVisibility( false);267 dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false); 266 268 267 269 this->burstEmitter = new DotEmitter(200, 0.0, .01); … … 315 317 void SpaceShip::reset() 316 318 { 317 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;319 bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 318 320 319 321 xMouse = yMouse = 0; … … 381 383 382 384 // Own Tick Setup, as a different fire routine is used on the weapon manager 383 this-> primWeaponMan.tick(time);385 this->weaponMan.tick(time); 384 386 this->secWeaponMan.tick(time); 385 387 386 if( this->b PrimFire)387 { 388 this-> primWeaponMan.fire();388 if( this->bFire) 389 { 390 this->weaponMan.fire(); 389 391 } 390 392 if( this->bSecFire) 391 393 { 392 394 this->secWeaponMan.fire(); 393 this->bSecFire = !this->bSecFire; 394 } 395 this->bSecFire = !this->bSecFire; // FIXME This currently is needed to prevent "echo fires" of a second rocket after its cooldown has passed 396 } 397 398 this->weaponRegen(time); 395 399 396 400 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() ) … … 572 576 this->bSecFire = event.bPressed; 573 577 else if( event.type == KeyMapper::PEV_FIRE1) 574 this->b PrimFire = event.bPressed;578 this->bFire = event.bPressed; 575 579 else if( event.type == EV_MOUSE_MOTION) 576 580 { … … 639 643 } 640 644 } 645 646 /** 647 * Weapon regeneration 648 * does not use any reactor capacity, as it wouldn't work in a consistent way. 649 */ 650 void SpaceShip::weaponRegen(float time) 651 { 652 float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time; 653 Weapon* weapon; 654 for( int i=0; i < this->weaponMan.getSlotCount(); i++) 655 { 656 weapon = this->weaponMan.getWeapon(i); 657 if( weapon != NULL && weapon->isActive()) 658 { 659 weapon->increaseEnergy( energy); 660 weapon->updateWidgets(); 661 } 662 663 } 664 // weaponMan.increaseAmmunition( weapon, energy); 665 666 } -
branches/playability/src/world_entities/space_ships/space_ship.h
r9963 r9965 48 48 virtual void process(const Event &event); 49 49 50 inline WeaponManager getWeaponManagerSecondary() { return this->secWeaponMan; }; 51 50 52 //Functions for GUI 51 53 inline float getShieldCur() { return this->shieldCur; }; //!< returns current shield value … … 68 70 void regen(float time); //!< handler for shield and electronic regeneration 69 71 70 WeaponManager primWeaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping 72 void weaponRegen(float time); //!< weapon energy regeneration 73 74 //WeaponManager weaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping 71 75 WeaponManager secWeaponMan; //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping 72 76 short supportedPlaymodes; //!< What Playmodes are Supported in this Playable. 73 77 Playable::Playmode playmode; //!< The current playmode. 74 bool bPrimFire;75 78 bool bSecFire; 76 79 … … 98 101 int weaponEnergyUsed; 99 102 float weaponEnergyShare; 103 float weaponEnergyRegen; 100 104 int weaponSpecialSlot; //!< number of special weapon slots 101 105 int weaponSpecialUsed; 102 106 103 int reactorOutput; //!< reactor output 104 int reactorCapacity; //!< reactor capacity 105 107 float reactorOutput; //!< reactor output 108 float reactorCapacity; //!< reactor capacity 106 109 107 110 int curWeaponPrimary; //!< current primary weapon config -
branches/playability/src/world_entities/weapons/weapon.h
r9869 r9965 169 169 bool check() const; 170 170 void debug() const; 171 172 void updateWidgets(); 171 173 172 174 protected: … … 200 202 inline void enterState(WeaponState state); 201 203 202 void updateWidgets();204 203 205 204 206 private: -
branches/playability/src/world_entities/weapons/weapon_manager.cc
r9961 r9965 317 317 318 318 /** 319 * @brief does the same as the funtion inc lreaseAmmunition, added four your convenience319 * @brief does the same as the funtion increaseAmmunition, added four your convenience 320 320 * @param weapon, the Weapon to read the ammo-info about. 321 321 * @param ammo how much ammo to add. 322 322 */ 323 float WeaponManager::inc lreaseAmmunition(const Weapon* weapon, float ammo)323 float WeaponManager::increaseAmmunition(const Weapon* weapon, float ammo) 324 324 { 325 325 assert (weapon != NULL); -
branches/playability/src/world_entities/weapons/weapon_manager.h
r9869 r9965 91 91 92 92 float increaseAmmunition(const ClassID& projectileType, float ammo); 93 float inc lreaseAmmunition(const Weapon* weapon, float ammo);93 float increaseAmmunition(const Weapon* weapon, float ammo); 94 94 95 95 /** @returns a fixed target namely the Crosshair's 3D position */
Note: See TracChangeset
for help on using the changeset viewer.