Changeset 3881 in orxonox.OLD for orxonox/trunk/src/world_entities/weapon.cc
- Timestamp:
- Apr 18, 2005, 8:05:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.