Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2007, 3:02:03 PM (17 years ago)
Author:
rgrieder
Message:
  • updated to current revision from Visual studio directory
  • hopefully working libraries with cmake
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/src/run_manager.cc

    r192 r267  
    5656#include "weapon/bullet.h"
    5757#include "weapon/bullet_manager.h"
    58 #include "weapon/weapon_manager.h"
     58#include "weapon/base_weapon.h"
     59
     60#include "hud/hud_overlay.h"
    5961
    6062#include "run_manager.h"
     63
     64namespace Ogre {
     65  using namespace orxonox;
     66  template<> RunManager* Singleton<RunManager>::ms_Singleton = 0;
     67}
    6168
    6269namespace orxonox {
    6370  using namespace Ogre;
    6471  using namespace weapon;
     72  using namespace hud;
    6573
    6674  /**
     
    7785  */
    7886
     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
    7996
    8097  /**
     
    88105  */
    89106  RunManager::RunManager(OgreControl * ogre)
    90         : ogre_(ogre), window_(ogre->getRenderWindow()), leftButtonDown_(false),
     107        : ogre_(ogre), window_(ogre->getRenderWindow()), //leftButtonDown_(false),
    91108        statsOn_(true), screenShotCounter_(0), timeUntilNextToggle_(0),
    92109        filtering_(TFO_BILINEAR), aniso_(1), sceneDetailIndex_(0),
     
    94111        debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0)
    95112  {
    96 
    97113    // SETTING UP THE SCENE
    98114
    99115    // create one new SceneManger
    100     sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "backgroundScene_");
     116    sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "Orxonox Scene");
    101117
    102118    // background scene (world objects, skybox, lights, etc.)
     
    108124    // create a bullet manager
    109125    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;*/
    116126
    117127
     
    131141
    132142    // 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)));
    135145
    136146
     
    153163    createViewports();
    154164
     165    // create HUD
     166    hud_ = new HUDOverlay();
     167    hud_->show();
     168
    155169
    156170    // Set default mipmap level (NB some APIs ignore this)
     
    163177    using namespace OIS;
    164178
    165     debugOverlay_ = OverlayManager::getSingleton()
    166       .getByName("Core/DebugOverlay");
     179    //debugOverlay_ = OverlayManager::getSingleton()
     180    //  .getByName("Core/DebugOverlay");
     181   
    167182
    168183    LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
     
    194209    windowResized(window_);
    195210
    196     showDebugOverlay(true);
     211    //showDebugOverlay(true);
    197212
    198213    // REGISTER THIS OBJECT AS A WINDOW EVENT LISTENER IN OGRE
     
    218233    if (bulletManager_)
    219234      delete bulletManager_;
    220 
    221     WeaponManager::destroyWeapons();
    222 
    223     // clean up the bullet list
    224     /*for (int i = 0; i < bulletsIndex_; i++)
    225       delete bullets_[i];
    226     delete bullets_;*/
    227235  }
    228236
     
    251259
    252260    // Update the 'HUD'
    253     updateStats();
     261    //updateStats();
    254262
    255263    // update the bullet positions
    256264    bulletManager_->tick(time, deltaTime);
    257265
    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     }*/
    264266
    265267    // HUMAN INTERFACE
     
    293295    // keep rendering
    294296    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;
    295331  }
    296332
     
    367403      playerShip_->setYThrust(0);
    368404
     405    if (keyboard_->isKeyDown(KC_G))
     406      playerShip_->getMainWeapon()->addAction(BaseWeapon::RELOAD);
     407
    369408    if( keyboard_->isKeyDown(KC_ESCAPE) || keyboard_->isKeyDown(KC_Q) )
    370409      return false;
     
    373412    {
    374413      statsOn_ = !statsOn_;
    375       showDebugOverlay(statsOn_);
     414      //showDebugOverlay(statsOn_);
    376415      timeUntilNextToggle_ = 1;
    377416    }
     
    398437      MaterialManager::getSingleton().setDefaultAnisotropy(aniso_);
    399438
    400       showDebugOverlay(statsOn_);
     439      //showDebugOverlay(statsOn_);
    401440      timeUntilNextToggle_ = 1;
    402441    }
     
    434473    if(displayCameraDetails)
    435474      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());
    437481    // debugText_ = "P: " + StringConverter::toString(camera_
    438482    //      ->getDerivedPosition()) + " " + "O: "
     
    457501    const MouseState &ms = mouse_->getMouseState();
    458502
    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
    493509    playerShip_->turnUpAndDown(Radian(ms.Y.rel * mouseSensitivity_));
    494510    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);
    497511
    498512    // keep rendering
     
    565579
    566580
    567 
    568581  /**
    569582  * Simple camera creator.
     
    583596  /**
    584597  * Simple viewport creator.
    585   * TODO: fully understand the concept of viewports concerning orxnox.
    586   * E.g. do we need splitscreen mode?
    587598  * For now the viewport uses the entire render window and is based on the one
    588599  * camera created so far.
Note: See TracChangeset for help on using the changeset viewer.