Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 645


Ignore:
Timestamp:
Dec 19, 2007, 3:05:56 AM (17 years ago)
Author:
rgrieder
Message:
  • weapon system up and running
Location:
code/branches/FICN/src/orxonox/objects
Files:
6 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);
  • code/branches/FICN/src/orxonox/objects/Fighter.h

    r637 r645  
    3737            bool mouseMoved(const OIS::MouseEvent &e);
    3838            bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);// { return true; }
    39             bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
     39            bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);// { return true; }
    4040
    4141
     
    4949            AmmunitionDump* ammoDump_;
    5050            BarrelGun* mainWeapon_;
     51
     52            bool leftButtonPressed_;
     53            bool rightButtonPressed_;
    5154
    5255            float moveForward_;
  • code/branches/FICN/src/orxonox/objects/weapon_system/barrel_gun.cc

    r637 r645  
    5252    primaryFirePower_ = 100;
    5353    secondaryFirePower_ = 500;
    54     primaryFiringRate_ = 10;
    55     secondaryFiringRate_ = 2;
    56     primaryBulletSpeed_ = 1000;
    57     secondaryBulletSpeed_ = 500;
     54    primaryFiringRate_ = 1.0/7.0;
     55    secondaryFiringRate_ = 1.0/2.0;
     56    primaryBulletSpeed_ = 800;
     57    secondaryBulletSpeed_ = 300;
    5858    magazineSize_ = 25;
    5959  }
     
    8080          + StringConverter::toString(bulletCounter_++), "Barrel.mesh");
    8181
    82     Vector3 speed = (temp->getOrientation() * Vector3(0, 0, -1))
     82    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
    8383          .normalisedCopy() * primaryBulletSpeed_;
    8484    speed += getVelocity();
    8585
    86           temp->setScale(Vector3(1, 1, 1) * 4);
     86          temp->setScale(Vector3(1, 1, 1) * 2);
    8787          temp->yaw(Degree(-90));
    8888
     
    9797
    9898
    99   void BarrelGun::primaryFiring(unsigned int time)
     99  void BarrelGun::primaryFiring(float time)
    100100  {
    101     if (time > (unsigned int)1000/primaryFiringRate_)
     101    if (time > primaryFiringRate_)
    102102    {
    103103      currentState_ = IDLE;
     
    122122          + StringConverter::toString(bulletCounter_++), "Barrel.mesh");
    123123
    124     Vector3 speed = (temp->getOrientation() * Vector3(0, 0, -1))
     124    Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0))
    125125          .normalisedCopy() * secondaryBulletSpeed_*0.5;
    126126    speed += getVelocity();
    127127
    128           temp->setScale(Vector3(1, 1, 1) * 10);
     128          temp->setScale(Vector3(1, 1, 1) * 4);
    129129          temp->yaw(Degree(-90));
    130130
     
    140140
    141141
    142   void BarrelGun::secondaryFiring(unsigned int time)
     142  void BarrelGun::secondaryFiring(float time)
    143143  {
    144     if (time > (unsigned int)1000/secondaryFiringRate_)
     144    if (time > secondaryFiringRate_)
    145145      currentState_ = IDLE;
    146146  }
  • code/branches/FICN/src/orxonox/objects/weapon_system/barrel_gun.h

    r637 r645  
    4949    void primaryFire();
    5050
    51     void primaryFiring(unsigned int);
     51    void primaryFiring(float);
    5252
    5353    void secondaryFire();
    5454
    55     void secondaryFiring(unsigned int);
     55    void secondaryFiring(float);
    5656
    5757  public:
  • code/branches/FICN/src/orxonox/objects/weapon_system/base_weapon.cc

    r637 r645  
    4646 
    4747  CreateFactory(BaseWeapon);
     48
     49  float BaseWeapon::nextActionValidityPeriod_ = 0.5;
    4850
    4951  BaseWeapon::BaseWeapon()
     
    105107      {
    106108      case PRIMARY_FIRE:
    107         primaryFiring((unsigned int)(totalTime_ - actionStartTime_));
     109        primaryFiring(totalTime_ - actionStartTime_);
    108110        break;
    109111
    110112      case SECONDARY_FIRE:
    111         secondaryFiring((unsigned int)(totalTime_ - actionStartTime_));
     113        secondaryFiring(totalTime_ - actionStartTime_);
    112114        break;
    113115
  • code/branches/FICN/src/orxonox/objects/weapon_system/base_weapon.h

    r637 r645  
    7878    virtual void primaryFire() { };
    7979
    80     virtual void primaryFiring(unsigned int) { };
     80    virtual void primaryFiring(float) { };
    8181
    8282    virtual void secondaryFire() { };
    8383
    84     virtual void secondaryFiring(unsigned int) { };
     84    virtual void secondaryFiring(float) { };
    8585
    8686    inline void registerAllVariables() { }//Model::registerAllVariables(); }
     
    100100
    101101    float totalTime_;
    102     unsigned long actionStartTime_;
     102    float actionStartTime_;
    103103
    104104    State currentState_;
     
    107107    Action nextAction_;
    108108    bool actionAdded_;
    109     unsigned long timeSinceNextActionAdded_;
    110     static const unsigned long nextActionValidityPeriod_ = 500;
     109    float timeSinceNextActionAdded_;
     110    static float nextActionValidityPeriod_;
    111111
    112112    // weapon properties
    113113    int leftAmmo_;
    114     int primaryFirePower_;
    115     int secondaryFirePower_;
    116     int primaryFiringRate_;
    117     int secondaryFiringRate_;
     114    float primaryFirePower_;
     115    float secondaryFirePower_;
     116    float primaryFiringRate_;
     117    float secondaryFiringRate_;
    118118    Ogre::Real primaryBulletSpeed_;
    119119    Ogre::Real secondaryBulletSpeed_;
Note: See TracChangeset for help on using the changeset viewer.