Changeset 4597 in orxonox.OLD for orxonox/trunk/src/world_entities/weapon.cc
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapon.cc
r4000 r4597 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 13 13 ### File Specific 14 14 main-programmer: Patrick Boenzli 15 co-programmer: 15 co-programmer: 16 16 */ 17 17 … … 35 35 \param number of weapon slots of the model/ship <= 8 (limitied) 36 36 */ 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 37 WeaponManager::WeaponManager(int nrOfSlots) 38 { 39 this->setClassID(CL_WEAPON_MANAGER, "WeaponManager"); 40 39 41 for(int i = 0; i < W_MAX_CONFIGS; ++i) 40 42 { 41 43 this->configs[i].bUsed = false; 42 44 for(int j = 0; j < W_MAX_SLOTS; ++j) 43 45 this->configs[i].slots[j] = NULL; 44 46 } 45 47 this->nrOfSlots = nrOfSlots; … … 48 50 49 51 50 WeaponManager::~WeaponManager() 51 { 52 /* 53 i dont have to delete the weapons itself, because they are 52 WeaponManager::~WeaponManager() 53 { 54 /* 55 i dont have to delete the weapons itself, because they are 54 56 worldentities and therefore in the entities list of the world. 55 57 world will clean them up for me … … 59 61 this->configs[i].bUsed = false; 60 62 for(int j = 0; j < W_MAX_SLOTS; ++j) 61 63 this->configs[i].slots[j] = NULL; 62 64 } 63 65 } … … 72 74 if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be 73 75 replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free 74 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 76 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 75 77 a error message. 76 78 */ 77 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 79 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 78 80 { 79 81 if( slotID == W_FREE_SLOT) … … 81 83 int freeSlot = this->getNextFreeSlot( configID); 82 84 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 83 84 85 86 85 { 86 PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n"); 87 return; 88 } 87 89 PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot); 88 90 this->configs[configID].bUsed = true; … … 108 110 this function will deactivate the weapons first, change the config and reactivate them later 109 111 */ 110 void WeaponManager::nextWeaponConf() 112 void WeaponManager::nextWeaponConf() 111 113 { 112 114 PRINTF(4)("Changing weapon configuration: from %i to next\n", this->currConfID); … … 116 118 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 117 119 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 118 else this->currConfID = i; 119 120 120 else this->currConfID = i; 121 122 121 123 Weapon *w1, *w2; 122 124 for(int j = 0; j < W_MAX_SLOTS; ++j) … … 124 126 w1 = this->configs[lastConfID].slots[j]; 125 127 w2 = this->configs[this->currConfID].slots[j]; 126 128 127 129 if( w1 == w2) 128 129 130 130 { 131 printf("no need for change\n"); 132 } 131 133 else 132 133 134 135 136 137 138 139 140 141 142 143 134 { 135 if( w1 != NULL ) 136 { 137 w1->deactivate(); 138 printf("deactivating %i,%i\n", j,lastConfID); 139 } 140 if( w2 != NULL) 141 { 142 w2->activate(); 143 printf("activating %i,%i\n", j, this->currConfID); 144 } 145 } 144 146 } 145 147 } … … 199 201 { 200 202 if( this->configs[configID].slots[i] == NULL) 201 203 return i; 202 204 } 203 205 return -1; … … 214 216 creates a new weapon 215 217 */ 216 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 218 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 217 219 : WorldEntity() 218 220 { … … 236 238 \brief standard deconstructor 237 239 */ 238 Weapon::~Weapon () 240 Weapon::~Weapon () 239 241 { 240 242 // model will be deleted from WorldEntity-destructor 241 243 //this->worldEntities = NULL; 242 244 243 245 /* dont delete objectComponentsX here, they will be killed when the pnodes are cleaned out */ 244 246 … … 247 249 248 250 249 /** 251 /** 250 252 \brief enables the weapon 251 253 252 a weapon can be enabled/disabled because of various reasons. if a weapon is 254 a weapon can be enabled/disabled because of various reasons. if a weapon is 253 255 been enabled, it can interact in a world. elswhere it wont react to any 254 256 action. … … 260 262 261 263 262 /** 264 /** 263 265 \brief disables the weapon 264 266 265 a weapon can be enabled/disabled because of various reasons. if a weapon is 267 a weapon can be enabled/disabled because of various reasons. if a weapon is 266 268 been enabled, it can interact in a world. elswhere it wont react to any 267 269 action. … … 273 275 274 276 275 /** 277 /** 276 278 \brief checks if the weapon is enabled 277 279 \returns true if enabled 278 280 279 a weapon can be ebabled/disabled because of various reasons. if a weapon is 281 a weapon can be ebabled/disabled because of various reasons. if a weapon is 280 282 been enabled, it can interact in a world. elswhere it wont react to any 281 283 action. … … 314 316 \brief this activates the weapon 315 317 316 This is needed, since there can be more than one weapon on a ship. the 317 activation can be connected with an animation. for example the weapon is 318 been armed out. 318 This is needed, since there can be more than one weapon on a ship. the 319 activation can be connected with an animation. for example the weapon is 320 been armed out. 319 321 */ 320 322 void Weapon::activate() … … 325 327 \brief this deactivates the weapon 326 328 327 This is needed, since there can be more than one weapon on a ship. the 328 activation can be connected with an animation. for example the weapon is 329 This is needed, since there can be more than one weapon on a ship. the 330 activation can be connected with an animation. for example the weapon is 329 331 been armed out. 330 332 */ … … 352 354 can destroy the weapons of enemies or vice versa. 353 355 */ 354 void Weapon::hit (WorldEntity* entity, Vector* position) 356 void Weapon::hit (WorldEntity* entity, Vector* position) 355 357 {} 356 358 … … 362 364 hit, it can also be destoryed. 363 365 */ 364 void Weapon::destroy () 366 void Weapon::destroy () 365 367 {} 366 368 … … 369 371 \brief tick signal for time dependent/driven stuff 370 372 */ 371 void Weapon::tick (float time) 373 void Weapon::tick (float time) 372 374 {} 373 375 … … 383 385 \brief this will draw the weapon 384 386 */ 385 void Weapon::draw () 386 {} 387 387 void Weapon::draw () 388 {} 389
Note: See TracChangeset
for help on using the changeset viewer.