Changeset 645
- Timestamp:
- Dec 19, 2007, 3:05:56 AM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/objects/Fighter.cc
r637 r645 55 55 this->ammoDump_ = NULL; 56 56 this->mainWeapon_ = NULL; 57 this->rightButtonPressed_ = false; 58 this->leftButtonPressed_ = false; 57 59 58 60 this->moveForward_ = 0; … … 114 116 Model::loadParams(xmlElem); 115 117 118 #if 0 116 119 w = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"schuss" + this->getName(),"Orxonox/schuss"); 117 120 w->getParticleSystem()->setParameter("local_space","true"); … … 131 134 node1->setInheritScale(false); 132 135 w->addToSceneNode(node1); 133 134 136 #endif 135 137 136 138 tt = new particle::ParticleInterface(Orxonox::getSingleton()->getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow"); … … 151 153 tt->addToSceneNode(node2); 152 154 153 154 155 // add weapon 155 156 … … 160 161 mainWeapon_ = new BarrelGun(); 161 162 mainWeapon_->setAmmoDump(ammoDump_); 163 Orxonox::getSingleton()->getSceneManager()->getRootSceneNode()->removeChild(mainWeapon_->getNode()); 164 getNode()->addChild(mainWeapon_->getNode()); 162 165 163 166 if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft")) … … 216 219 bool Fighter::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 217 220 { 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; 219 238 return true; 220 239 } … … 239 258 mMouse->capture(); 240 259 260 if (leftButtonPressed_) 261 mainWeapon_->primaryFireRequest(); 262 if (rightButtonPressed_) 263 mainWeapon_->secondaryFireRequest(); 264 241 265 if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W)) 242 266 this->moveForward(speed); … … 256 280 if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) 257 281 this->loopLeft(loop); 282 else 283 this->loopLeft(0); 284 285 if (mKeyboard->isKeyDown(OIS::KC_G)) 286 this->mainWeapon_->addAction(BaseWeapon::RELOAD); 258 287 else 259 288 this->loopLeft(0); -
code/branches/FICN/src/orxonox/objects/Fighter.h
r637 r645 37 37 bool mouseMoved(const OIS::MouseEvent &e); 38 38 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; } 40 40 41 41 … … 49 49 AmmunitionDump* ammoDump_; 50 50 BarrelGun* mainWeapon_; 51 52 bool leftButtonPressed_; 53 bool rightButtonPressed_; 51 54 52 55 float moveForward_; -
code/branches/FICN/src/orxonox/objects/weapon_system/barrel_gun.cc
r637 r645 52 52 primaryFirePower_ = 100; 53 53 secondaryFirePower_ = 500; 54 primaryFiringRate_ = 1 0;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; 58 58 magazineSize_ = 25; 59 59 } … … 80 80 + StringConverter::toString(bulletCounter_++), "Barrel.mesh"); 81 81 82 Vector3 speed = (temp->getOrientation() * Vector3( 0, 0, -1))82 Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0)) 83 83 .normalisedCopy() * primaryBulletSpeed_; 84 84 speed += getVelocity(); 85 85 86 temp->setScale(Vector3(1, 1, 1) * 4);86 temp->setScale(Vector3(1, 1, 1) * 2); 87 87 temp->yaw(Degree(-90)); 88 88 … … 97 97 98 98 99 void BarrelGun::primaryFiring( unsigned int time)99 void BarrelGun::primaryFiring(float time) 100 100 { 101 if (time > (unsigned int)1000/primaryFiringRate_)101 if (time > primaryFiringRate_) 102 102 { 103 103 currentState_ = IDLE; … … 122 122 + StringConverter::toString(bulletCounter_++), "Barrel.mesh"); 123 123 124 Vector3 speed = (temp->getOrientation() * Vector3( 0, 0, -1))124 Vector3 speed = (temp->getOrientation() * Vector3(1, 0, 0)) 125 125 .normalisedCopy() * secondaryBulletSpeed_*0.5; 126 126 speed += getVelocity(); 127 127 128 temp->setScale(Vector3(1, 1, 1) * 10);128 temp->setScale(Vector3(1, 1, 1) * 4); 129 129 temp->yaw(Degree(-90)); 130 130 … … 140 140 141 141 142 void BarrelGun::secondaryFiring( unsigned int time)142 void BarrelGun::secondaryFiring(float time) 143 143 { 144 if (time > (unsigned int)1000/secondaryFiringRate_)144 if (time > secondaryFiringRate_) 145 145 currentState_ = IDLE; 146 146 } -
code/branches/FICN/src/orxonox/objects/weapon_system/barrel_gun.h
r637 r645 49 49 void primaryFire(); 50 50 51 void primaryFiring( unsigned int);51 void primaryFiring(float); 52 52 53 53 void secondaryFire(); 54 54 55 void secondaryFiring( unsigned int);55 void secondaryFiring(float); 56 56 57 57 public: -
code/branches/FICN/src/orxonox/objects/weapon_system/base_weapon.cc
r637 r645 46 46 47 47 CreateFactory(BaseWeapon); 48 49 float BaseWeapon::nextActionValidityPeriod_ = 0.5; 48 50 49 51 BaseWeapon::BaseWeapon() … … 105 107 { 106 108 case PRIMARY_FIRE: 107 primaryFiring( (unsigned int)(totalTime_ - actionStartTime_));109 primaryFiring(totalTime_ - actionStartTime_); 108 110 break; 109 111 110 112 case SECONDARY_FIRE: 111 secondaryFiring( (unsigned int)(totalTime_ - actionStartTime_));113 secondaryFiring(totalTime_ - actionStartTime_); 112 114 break; 113 115 -
code/branches/FICN/src/orxonox/objects/weapon_system/base_weapon.h
r637 r645 78 78 virtual void primaryFire() { }; 79 79 80 virtual void primaryFiring( unsigned int) { };80 virtual void primaryFiring(float) { }; 81 81 82 82 virtual void secondaryFire() { }; 83 83 84 virtual void secondaryFiring( unsigned int) { };84 virtual void secondaryFiring(float) { }; 85 85 86 86 inline void registerAllVariables() { }//Model::registerAllVariables(); } … … 100 100 101 101 float totalTime_; 102 unsigned longactionStartTime_;102 float actionStartTime_; 103 103 104 104 State currentState_; … … 107 107 Action nextAction_; 108 108 bool actionAdded_; 109 unsigned longtimeSinceNextActionAdded_;110 static const unsigned long nextActionValidityPeriod_ = 500;109 float timeSinceNextActionAdded_; 110 static float nextActionValidityPeriod_; 111 111 112 112 // weapon properties 113 113 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_; 118 118 Ogre::Real primaryBulletSpeed_; 119 119 Ogre::Real secondaryBulletSpeed_;
Note: See TracChangeset
for help on using the changeset viewer.