Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2007, 3:05:56 AM (16 years ago)
Author:
rgrieder
Message:
  • weapon system up and running
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/objects/Fighter.cc

    r637 r645  
    5555        this->ammoDump_ = NULL;
    5656        this->mainWeapon_ = NULL;
     57        this->rightButtonPressed_ = false;
     58        this->leftButtonPressed_ = false;
    5759
    5860        this->moveForward_ = 0;
     
    114116        Model::loadParams(xmlElem);
    115117
     118#if 0
    116119        w = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"schuss" + this->getName(),"Orxonox/schuss");
    117120        w->getParticleSystem()->setParameter("local_space","true");
     
    131134        node1->setInheritScale(false);
    132135        w->addToSceneNode(node1);
    133 
    134 
     136#endif
    135137
    136138        tt = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    151153        tt->addToSceneNode(node2);
    152154
    153 
    154155        // add weapon
    155156
     
    160161        mainWeapon_ = new BarrelGun();
    161162        mainWeapon_->setAmmoDump(ammoDump_);
     163        Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->removeChild(mainWeapon_->getNode());
     164        getNode()->addChild(mainWeapon_->getNode());
    162165
    163166        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
     
    216219    bool Fighter::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id )
    217220    {
    218 
     221      if (id == OIS::MB_Left)
     222      {
     223        this->leftButtonPressed_ = true;
     224      }
     225      else if (id == OIS::MB_Right)
     226        this->rightButtonPressed_ = true;
     227      return true;
     228    }
     229
     230    bool Fighter::mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id )
     231    {
     232      if (id == OIS::MB_Left)
     233      {
     234        this->leftButtonPressed_ = false;
     235      }
     236      else if (id == OIS::MB_Right)
     237        this->rightButtonPressed_ = false;
    219238      return true;
    220239    }
     
    239258        mMouse->capture();
    240259
     260        if (leftButtonPressed_)
     261            mainWeapon_->primaryFireRequest();
     262        if (rightButtonPressed_)
     263            mainWeapon_->secondaryFireRequest();
     264
    241265        if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
    242266            this->moveForward(speed);
     
    256280        if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
    257281            this->loopLeft(loop);
     282        else
     283            this->loopLeft(0);
     284
     285        if (mKeyboard->isKeyDown(OIS::KC_G))
     286            this->mainWeapon_->addAction(BaseWeapon::RELOAD);
    258287        else
    259288            this->loopLeft(0);
Note: See TracChangeset for help on using the changeset viewer.