Changeset 9965 in orxonox.OLD for branches/playability/src/world_entities/space_ships/space_ship.cc
- Timestamp:
- Nov 28, 2006, 11:54:34 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.