- Timestamp:
- Apr 18, 2005, 8:05:00 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r3878 r3881 44 44 */ 45 45 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 46 //this->model = (Model*)ResourceManager::getInstance()->load("models/weapon_packet.obj", OBJ, RP_CAMPAIGN);47 46 travelSpeed = 15.0; 48 47 velocity = new Vector(); … … 53 52 //weapons: 54 53 this->weaponMan = new WeaponManager(); 55 Weapon* wpRight = new TestGun(this, new Vector(-2.6, 0.1, 3.0), newQuaternion(), 0);56 Weapon* wpLeft = new TestGun(this, new Vector(-2.6, 0.1, -3.0), newQuaternion(), 1);54 Weapon* wpRight = new TestGun(this,Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 55 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 57 56 58 57 this->weaponMan->addWeapon(wpRight, W_CONFIG0); 59 58 this->weaponMan->addWeapon(wpLeft, W_CONFIG1); 60 61 //this->weapons->add(wpRight); 62 //this->activeWeapon = wpRight; 63 //this->activeWeaponL = wpLeft; 59 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 60 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 61 64 62 } 65 63 -
orxonox/trunk/src/world_entities/test_gun.cc
r3855 r3881 40 40 creates a new weapon 41 41 */ 42 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion*direction, int leftRight)42 TestGun::TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight) 43 43 : Weapon (parent, coordinate, direction) 44 44 { … … 127 127 void TestGun::fire() 128 128 { 129 if( this->localTime < this->idleTime)129 if( !this->hasWeaponIdleTimeElapsed()) 130 130 { 131 131 this->weaponIdle(); … … 201 201 this->getAbsCoor ().y, 202 202 this->getAbsCoor ().z); 203 203 204 204 this->getAbsDir ().matrix (matrix); 205 205 glMultMatrixf((float*)matrix); … … 228 228 this->dummy1->getAbsCoor ().y, 229 229 this->dummy1->getAbsCoor ().z); 230 230 231 231 this->dummy1->getAbsDir ().matrix (matrix); 232 232 glMultMatrixf((float*)matrix); -
orxonox/trunk/src/world_entities/test_gun.h
r3855 r3881 37 37 38 38 public: 39 TestGun (PNode* parent, Vector* coordinate, Quaternion*direction, int leftRight);39 TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight); 40 40 virtual ~TestGun (); 41 41 -
orxonox/trunk/src/world_entities/weapon.cc
r3879 r3881 37 37 WeaponManager::WeaponManager(int nrOfSlots) 38 38 { 39 this->nrOfSlots = nrOfSlots;40 41 39 for(int i = 0; i < W_MAX_CONFIGS; ++i) 42 40 { … … 45 43 this->configs[i].slots[j] = NULL; 46 44 } 47 45 this->nrOfSlots = nrOfSlots; 48 46 this->currConfID = W_CONFIG0; 49 this->configs[this->currConfID].bUsed = true;50 47 } 51 48 … … 53 50 WeaponManager::~WeaponManager() 54 51 { 55 /* i dont have to delete the weapons itself, because they are 52 /* 53 i dont have to delete the weapons itself, because they are 56 54 worldentities and therefore in the entities list of the world 57 55 */ 56 for(int i = 0; i < W_MAX_CONFIGS; ++i) 57 { 58 this->configs[i].bUsed = false; 59 for(int j = 0; j < W_MAX_SLOTS; ++j) 60 this->configs[i].slots[j] = NULL; 61 } 58 62 } 59 63 … … 101 105 102 106 if there are multiple weapon configurations defined by the manager, use this to switch between them 107 this function will deactivate the weapons first, change the config and reactivate them later 103 108 */ 104 109 void WeaponManager::nextWeaponConf() 105 110 { 106 111 PRINTF(4)("Changing weapon configuration: from %i\n", this->currConfID); 112 113 Weapon* w; 114 for(int i = 0; i < W_MAX_SLOTS; ++i) 115 { 116 w = this->configs[this->currConfID].slots[i]; 117 if( w != NULL) w->deactivate(); 118 } 107 119 int i; 108 120 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); … … 110 122 else this->currConfID = i; 111 123 PRINTF(4)("\tto %i\n", this->currConfID); 124 125 for(int i = 0; i < W_MAX_SLOTS; ++i) 126 { 127 w = this->configs[this->currConfID].slots[i]; 128 if( w != NULL) w->activate(); 129 } 112 130 } 113 131 … … 181 199 creates a new weapon 182 200 */ 183 Weapon::Weapon (PNode* parent, Vector* coordinate, Quaternion*direction)201 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 184 202 : WorldEntity() 185 203 { 186 204 parent->addChild(this, PNODE_ALL); 187 this->setRelCoor( *coordinate);188 this->setRelDir( *direction);205 this->setRelCoor(coordinate); 206 this->setRelDir(direction); 189 207 WorldInterface* wi = WorldInterface::getInstance(); 190 208 this->worldEntities = wi->getEntityList(); … … 293 311 {} 294 312 295 /** 296 \brief sets a weapon idle time 297 \param idle time in ms 298 299 a weapon idle time is the time spend after a shoot until the weapon can 300 shoot again 301 */ 302 void Weapon::setWeaponIdleTime(float time) 303 { 304 this->idleTime = time; 305 } 306 307 /** 308 \brief gets the weapon idle time 309 \returns idle time in ms 310 311 a weapon idle time is the time spend after a shoot until the weapon can 312 shoot again 313 */ 314 float Weapon::getWeaponIdleTime(void) 315 { 316 return this->idleTime; 317 } 318 319 /** 320 \brief checks if the idle time is elapsed 321 \return true if time is elapsed 322 323 a weapon idle time is the time spend after a shoot until the weapon can 324 shoot again 325 */ 326 bool Weapon::hasWeaponIdleTimeElapsed(void) 327 { 328 return (this->localTime>this->idleTime)?true:false; 329 } 330 331 332 /** 333 \brief fires the weapon 334 335 this is called from the player.cc, when fire-button is been pushed 336 */ 337 void Weapon::fire() 338 {} 313 314 315 339 316 340 317 -
orxonox/trunk/src/world_entities/weapon.h
r3878 r3881 88 88 89 89 private: 90 int nrOfConfigs; //<! number of configurations defined91 90 int nrOfSlots; //<! number of weapon slots a ship has 92 91 int currConfID; //<! the currently selected config … … 101 100 102 101 public: 103 Weapon (PNode* parent, Vector* coordinate, Quaternion*direction);102 Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction); 104 103 virtual ~Weapon (); 105 104 … … 115 114 bool isActive(void); 116 115 117 void setWeaponIdleTime(float time);118 float getWeaponIdleTime(void);119 bool hasWeaponIdleTimeElapsed(void);120 116 117 /** 118 \brief sets a weapon idle time 119 \param idle time in ms 120 121 a weapon idle time is the time spend after a shoot until the weapon can 122 shoot again 123 */ 124 inline void setWeaponIdleTime(float time) { this->idleTime = time; } 125 /** 126 \brief gets the weapon idle time 127 \returns idle time in ms 128 129 a weapon idle time is the time spend after a shoot until the weapon can 130 shoot again 131 */ 132 inline float getWeaponIdleTime(void) const { return this->idleTime;} 133 /** 134 \brief checks if the idle time is elapsed 135 \return true if time is elapsed 136 137 a weapon idle time is the time spend after a shoot until the weapon can 138 shoot again 139 */ 140 inline bool hasWeaponIdleTimeElapsed(void) const { return (this->localTime>this->idleTime)?true:false; } 141 142 /** 143 \brief fires the weapon 144 145 this is called from the player.cc, when fire-button is been pushed 146 */ 121 147 virtual void fire(void) = 0; 122 148 virtual void hit (WorldEntity* weapon, Vector* loc);
Note: See TracChangeset
for help on using the changeset viewer.