Changeset 3878 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Apr 18, 2005, 6:12:16 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r3877 r3878 38 38 Player::Player() : WorldEntity() 39 39 { 40 this->weapons = new tList<Weapon>();41 this->activeWeapon = NULL;42 40 /* 43 41 this is the debug player - actualy we would have to make a new … … 51 49 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 52 50 bFire = false; 51 this->bWeaponChange = false; 53 52 acceleration = 10.0; 54 53 //weapons: … … 57 56 Weapon* wpLeft = new TestGun(this, new Vector(-2.6, 0.1, -3.0), new Quaternion(), 1); 58 57 59 this->weaponMan->addWeapon(wpRight );60 this->weaponMan->addWeapon(wpLeft );58 this->weaponMan->addWeapon(wpRight, W_CONFIG0); 59 this->weaponMan->addWeapon(wpLeft, W_CONFIG1); 61 60 62 61 //this->weapons->add(wpRight); … … 74 73 this only frees the memory allocated to save the list. 75 74 */ 76 delete this->weapons;77 75 delete this->weaponMan; 78 76 } … … 85 83 void Player::addWeapon(Weapon* weapon) 86 84 { 87 this->weapon s->add(weapon);85 this->weaponMan->addWeapon(weapon); 88 86 } 89 87 … … 95 93 void Player::removeWeapon(Weapon* weapon) 96 94 { 97 this->weapon s->remove(weapon);95 this->weaponMan->removeWeapon(weapon); 98 96 } 99 97 … … 157 155 glPopMatrix(); 158 156 159 //this->activeWeapon->draw();160 //this->activeWeaponL->draw();161 157 this->weaponMan->draw(); 162 158 } … … 221 217 if( this->bWeaponChange) 222 218 { 223 //this->activeWeapon->deactivate();224 //this->weapons->enumerate(); FIX: strang weapon change...225 //this->activeWeapon = this->weapons->nextElement(this->activeWeapon);226 //this->activeWeapon->activate();227 219 this->weaponMan->nextWeaponConf(); 220 this->bWeaponChange = false; 228 221 } 229 222 } … … 244 237 if( !strcmp( cmd->cmd, "right")) this->bRight = !cmd->bUp; 245 238 if( !strcmp( cmd->cmd, "fire")) this->bFire = !cmd->bUp; 246 if( !strcmp( cmd->cmd, "mode")) this->bWeaponChange = !cmd->bUp;247 } 239 if( !strcmp( cmd->cmd, "mode")) if(cmd->bUp) this->bWeaponChange = !this->bWeaponChange; 240 } -
orxonox/trunk/src/world_entities/weapon.cc
r3877 r3878 56 56 57 57 58 void WeaponManager::addWeapon(Weapon* weapon, int slotID, int configID) 58 /** 59 \brief adds a weapon to the selected weaponconfiguration into the selected slot 60 \param the weapon to add 61 \param an identifier for the slot: number between 0..7 if not specified: slotID=next free slot 62 \param an identifier for the weapon configuration, number between 0..3 63 64 if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be 65 replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free 66 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 67 a error message. 68 */ 69 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 59 70 { 60 71 if( slotID == W_FREE_SLOT) 61 72 { 62 int freeSlot = this->getNextFreeSlot( );73 int freeSlot = this->getNextFreeSlot( configID); 63 74 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 64 75 { … … 67 78 } 68 79 PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot); 80 this->configs[configID].bUsed = true; 69 81 this->configs[configID].slots[freeSlot] = weapon; 70 82 return; 71 83 } 84 this->configs[configID].bUsed = true; 72 85 this->configs[configID].slots[slotID] = weapon; 73 86 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID); … … 75 88 76 89 90 void WeaponManager::removeWeapon(Weapon* weapon, int configID) 91 { 92 /* empty */ 93 } 94 95 96 /** 97 \brief changes to the next weapon configuration 98 99 if there are multiple weapon configurations defined by the manager, use this to switch between them 100 */ 77 101 void WeaponManager::nextWeaponConf() 78 102 { 79 PRINTF(3)("Changing weapon configuration: from %i 103 PRINTF(3)("Changing weapon configuration: from %i\n", this->currConfID); 80 104 int i; 81 for(i = this->currConfID ; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);105 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 82 106 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 83 107 else this->currConfID = i; 84 PRINTF(3)("to %i\n", this->currConfID); 85 } 86 87 88 int WeaponManager::getNextFreeSlot() 89 { 90 for( int i = 0; i < W_MAX_SLOTS; ++i) 91 { 92 if( this->configs[this->currConfID].slots[i] == NULL) 93 return i; 94 } 95 return -1; 96 } 97 98 108 PRINTF(3)("\tto %i\n", this->currConfID); 109 } 110 111 112 113 /** 114 \brief triggers fire of all weapons in the current weaponconfig 115 */ 99 116 void WeaponManager::fire() 100 117 { … … 108 125 109 126 127 /** 128 \brief triggers tick of all weapons in the current weaponconfig 129 \param second passed since last tick 130 */ 110 131 void WeaponManager::tick(float sec) 111 132 { … … 119 140 120 141 142 /** 143 \brief triggers draw of all weapons in the current weaponconfig 144 */ 121 145 void WeaponManager::draw() 122 146 { … … 128 152 } 129 153 } 154 155 156 /** 157 \brief private gets the next free slot in a certain weaponconfig 158 \param the selected weaponconfig 159 */ 160 int WeaponManager::getNextFreeSlot(int configID) 161 { 162 for( int i = 0; i < W_MAX_SLOTS; ++i) 163 { 164 if( this->configs[configID].slots[i] == NULL) 165 return i; 166 } 167 return -1; 168 } 169 170 171 172 173 130 174 131 175 /** -
orxonox/trunk/src/world_entities/weapon.h
r3877 r3878 79 79 ~WeaponManager(); 80 80 81 void addWeapon(Weapon* weapon, int slotID = W_FREE_SLOT, int configID = W_CONFIG0); 81 void addWeapon(Weapon* weapon, int configID = W_CONFIG0, int slotID = W_FREE_SLOT); 82 void removeWeapon(Weapon* weapon, int configID = W_CONFIG0); 82 83 void nextWeaponConf(); 83 84 … … 92 93 weaponConfig configs[4]; //<! a list of four configurations 93 94 94 int getNextFreeSlot( );95 int getNextFreeSlot(int configID); 95 96 }; 96 97
Note: See TracChangeset
for help on using the changeset viewer.