Changeset 267 for code/branches/main_reto/src/run_manager.cc
- Timestamp:
- Nov 27, 2007, 3:02:03 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/src/run_manager.cc
r192 r267 56 56 #include "weapon/bullet.h" 57 57 #include "weapon/bullet_manager.h" 58 #include "weapon/weapon_manager.h" 58 #include "weapon/base_weapon.h" 59 60 #include "hud/hud_overlay.h" 59 61 60 62 #include "run_manager.h" 63 64 namespace Ogre { 65 using namespace orxonox; 66 template<> RunManager* Singleton<RunManager>::ms_Singleton = 0; 67 } 61 68 62 69 namespace orxonox { 63 70 using namespace Ogre; 64 71 using namespace weapon; 72 using namespace hud; 65 73 66 74 /** … … 77 85 */ 78 86 87 RunManager* RunManager::getSingletonPtr(void) 88 { 89 return ms_Singleton; 90 } 91 RunManager& RunManager::getSingleton(void) 92 { 93 assert( ms_Singleton ); return ( *ms_Singleton ); 94 } 95 79 96 80 97 /** … … 88 105 */ 89 106 RunManager::RunManager(OgreControl * ogre) 90 : ogre_(ogre), window_(ogre->getRenderWindow()), leftButtonDown_(false),107 : ogre_(ogre), window_(ogre->getRenderWindow()), //leftButtonDown_(false), 91 108 statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0), 92 109 filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0), … … 94 111 debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0) 95 112 { 96 97 113 // SETTING UP THE SCENE 98 114 99 115 // create one new SceneManger 100 sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, " backgroundScene_");116 sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "Orxonox Scene"); 101 117 102 118 // background scene (world objects, skybox, lights, etc.) … … 108 124 // create a bullet manager 109 125 bulletManager_ = new BulletManager(sceneMgr_); 110 WeaponManager::loadWeapons();111 112 // TODO: Use STL to make life easier. But it works this way too..113 /*bullets_ = new Bullet*[10];114 bulletsIndex_ = 0;115 bulletsSize_ = 10;*/116 126 117 127 … … 131 141 132 142 // Construct a new spaceship and give it the node 133 playerShip_ = new OrxonoxShip(sceneMgr_ , sceneMgr_->getRootSceneNode()134 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)) , bulletManager_);143 playerShip_ = new OrxonoxShip(sceneMgr_->getRootSceneNode() 144 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20))); 135 145 136 146 … … 153 163 createViewports(); 154 164 165 // create HUD 166 hud_ = new HUDOverlay(); 167 hud_->show(); 168 155 169 156 170 // Set default mipmap level (NB some APIs ignore this) … … 163 177 using namespace OIS; 164 178 165 debugOverlay_ = OverlayManager::getSingleton() 166 .getByName("Core/DebugOverlay"); 179 //debugOverlay_ = OverlayManager::getSingleton() 180 // .getByName("Core/DebugOverlay"); 181 167 182 168 183 LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***"); … … 194 209 windowResized(window_); 195 210 196 showDebugOverlay(true);211 //showDebugOverlay(true); 197 212 198 213 // REGISTER THIS OBJECT AS A WINDOW EVENT LISTENER IN OGRE … … 218 233 if (bulletManager_) 219 234 delete bulletManager_; 220 221 WeaponManager::destroyWeapons();222 223 // clean up the bullet list224 /*for (int i = 0; i < bulletsIndex_; i++)225 delete bullets_[i];226 delete bullets_;*/227 235 } 228 236 … … 251 259 252 260 // Update the 'HUD' 253 updateStats();261 //updateStats(); 254 262 255 263 // update the bullet positions 256 264 bulletManager_->tick(time, deltaTime); 257 265 258 /*for (int i = 0; i < bulletsIndex_; i++)259 {260 bullets_[i]->node_->translate(bullets_[i]->speed_*deltaTime);261 bullets_[i]->node_->yaw(Degree(deltaTime*100));262 bullets_[i]->node_->roll(Degree(deltaTime*300));263 }*/264 266 265 267 // HUMAN INTERFACE … … 293 295 // keep rendering 294 296 return true; 297 } 298 299 300 SceneManager& RunManager::getSceneManager() 301 { 302 return *sceneMgr_; 303 } 304 305 SceneManager* RunManager::getSceneManagerPtr() 306 { 307 return sceneMgr_; 308 } 309 310 BulletManager* RunManager::getBulletManagerPtr() 311 { 312 return bulletManager_; 313 } 314 315 int RunManager::getAmmunitionID(const Ogre::String &ammoName) 316 { 317 Ogre::String ammoTypes[] = { "Energy Cell", "Barrel", "Lead Shot" }; 318 int ammoTypesLength = 3; 319 320 for (int i = 0; i < ammoTypesLength; i++) 321 { 322 if (ammoTypes[i] == ammoName) 323 return i; 324 } 325 return -1; 326 } 327 328 int RunManager::getNumberOfAmmos() 329 { 330 return 3; 295 331 } 296 332 … … 367 403 playerShip_->setYThrust(0); 368 404 405 if (keyboard_->isKeyDown(KC_G)) 406 playerShip_->getMainWeapon()->addAction(BaseWeapon::RELOAD); 407 369 408 if( keyboard_->isKeyDown(KC_ESCAPE) || keyboard_->isKeyDown(KC_Q) ) 370 409 return false; … … 373 412 { 374 413 statsOn_ = !statsOn_; 375 showDebugOverlay(statsOn_);414 //showDebugOverlay(statsOn_); 376 415 timeUntilNextToggle_ = 1; 377 416 } … … 398 437 MaterialManager::getSingleton().setDefaultAnisotropy(aniso_); 399 438 400 showDebugOverlay(statsOn_);439 //showDebugOverlay(statsOn_); 401 440 timeUntilNextToggle_ = 1; 402 441 } … … 434 473 if(displayCameraDetails) 435 474 debugText_ = " | Speed = " 436 + StringConverter::toString(playerShip_->getSpeed()); 475 + StringConverter::toString(playerShip_->getSpeed()) 476 + " | Left Ammo = " 477 + StringConverter::toString(playerShip_ 478 ->getMainWeapon()->getAmmoState()) 479 + " | Ammo stock = " 480 + StringConverter::toString(playerShip_->getAmmoStock()); 437 481 // debugText_ = "P: " + StringConverter::toString(camera_ 438 482 // ->getDerivedPosition()) + " " + "O: " … … 457 501 const MouseState &ms = mouse_->getMouseState(); 458 502 459 // This is a 'hack' to show some flying barrels.. 460 // Usually, the Bullet created by the ship should be managed 461 // by the physics engine.. 462 if (ms.buttonDown(MB_Left) && !leftButtonDown_) 463 { 464 // Prevent continuous fire for the moment. 465 leftButtonDown_ = true; 466 467 playerShip_->fire(); 468 469 // let ship fire one shot with its only weapon (Barrels..) 470 /*Bullet *tempBullet = playerShip_->fire(); 471 472 // resize array if neccessary (double the size then) 473 if (bulletsIndex_ >= bulletsSize_) 474 { 475 // redimension the array 476 Bullet **tempArray = new Bullet*[2*bulletsSize_]; 477 for (int i = 0; i < bulletsSize_; i++) 478 tempArray[i] = bullets_[i]; 479 bulletsSize_ *= 2; 480 delete bullets_; 481 bullets_ = tempArray; 482 } 483 484 // add the bullet to the list 485 bullets_[bulletsIndex_++] = tempBullet;*/ 486 487 } 488 else if (!ms.buttons) 489 leftButtonDown_ = false; 490 491 // space ship steering. This should definitely be done in the steering object 492 // Simply give it the mouse movements. 503 if (ms.buttonDown(MB_Left)) 504 playerShip_->getMainWeapon()->primaryFireRequest(); 505 506 if (ms.buttonDown(MB_Right)) 507 playerShip_->getMainWeapon()->secondaryFireRequest(); 508 493 509 playerShip_->turnUpAndDown(Radian(ms.Y.rel * mouseSensitivity_)); 494 510 playerShip_->turnLeftAndRight(Radian(ms.X.rel * mouseSensitivity_)); 495 //playerShip_->mRootNode->pitch(Degree(-ms.Y.rel * 0.13), Ogre::Node::TransformSpace::TS_LOCAL);496 //playerShip_->mRootNode->yaw(Degree(-ms.X.rel * 0.13), Ogre::Node::TransformSpace::TS_PARENT);497 511 498 512 // keep rendering … … 565 579 566 580 567 568 581 /** 569 582 * Simple camera creator. … … 583 596 /** 584 597 * Simple viewport creator. 585 * TODO: fully understand the concept of viewports concerning orxnox.586 * E.g. do we need splitscreen mode?587 598 * For now the viewport uses the entire render window and is based on the one 588 599 * camera created so far.
Note: See TracChangeset
for help on using the changeset viewer.