- Timestamp:
- Jul 25, 2005, 12:22:24 AM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r4952 r4953 46 46 47 47 //weapons: 48 Weapon* wpRight = new TestGun( this, Vector(-2.6, 0.1, 3.0), Quaternion(),0);49 Weapon* wpLeft = new TestGun( this, Vector(-2.6, 0.1, -3.0), Quaternion(),1);48 Weapon* wpRight = new TestGun(0); 49 Weapon* wpLeft = new TestGun(1); 50 50 51 51 this->weaponMan->addWeapon(wpRight); … … 80 80 81 81 //weapons: 82 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 83 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 84 85 this->weaponMan->addWeapon(wpRight, 0,0); 86 this->weaponMan->addWeapon(wpLeft, 0, 1); 87 this->weaponMan->addWeapon(wpLeft, 1, 1); 88 this->weaponMan->addWeapon(wpRight, 2, 0); 89 /* this->weaponMan->addWeapon(wpRight, WM_CONFIG2); 90 this->weaponMan->addWeapon(wpLeft, WM_CONFIG2);*/ 82 Weapon* wpRight = new TestGun(0); 83 wpRight->setName("testGun Right"); 84 Weapon* wpLeft = new TestGun(1); 85 wpLeft->setName("testGun Left"); 86 87 this->weaponMan->addWeapon(wpLeft, 1, 0); 88 this->weaponMan->addWeapon(wpRight,1 ,1); 89 this->weaponMan->addWeapon(wpLeft, 3, 1); 90 91 this->weaponMan->changeWeaponConfig(0); 91 92 } 92 93 … … 107 108 108 109 109 this->weaponMan = new WeaponManager(2); 110 this->weaponMan = new WeaponManager(this); 111 this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0)); 112 this->weaponMan->setSlotPosition(1, Vector(-2.6, .1, 3.0)); 113 110 114 } 111 115 -
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4948 r4953 44 44 creates a new weapon 45 45 */ 46 TestGun::TestGun (PNode* parent, const Vector& coordinate, 47 const Quaternion& direction, int leftRight) 48 : Weapon (parent, coordinate, direction) 46 TestGun::TestGun (int leftRight) 49 47 { 50 48 this->setClassID(CL_TEST_GUN, "TestGun"); … … 71 69 animation1->addKeyFrame(Vector(0, 0, 0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT); 72 70 73 animation2->addKeyFrame(Vector( -2.6, 0.1, 2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);74 animation2->addKeyFrame(Vector( -2.6, 0.1, 3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);75 76 animation3->addKeyFrame(Vector( -2.6, 0.1, 3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);77 animation3->addKeyFrame(Vector( -2.6, 0.1, 2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);71 animation2->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 72 animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 73 74 animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 75 animation3->addKeyFrame(Vector(0.0, 0.0, -1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 78 76 } 79 77 else if( this->leftRight == W_RIGHT) … … 86 84 animation1->addKeyFrame(Vector(0, 0, .5), Quaternion(), 0.0, ANIM_LINEAR, ANIM_CONSTANT); 87 85 88 animation2->addKeyFrame(Vector( -2.6, 0.1, -2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);89 animation2->addKeyFrame(Vector( -2.6, 0.1, -3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);90 91 animation3->addKeyFrame(Vector( -2.6, 0.1, -3.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);92 animation3->addKeyFrame(Vector( -2.6, 0.1, -2.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT);86 animation2->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 87 animation2->addKeyFrame(Vector(.0, .0, .0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 88 89 animation3->addKeyFrame(Vector(.0, .0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 90 animation3->addKeyFrame(Vector(.0, .0, 1.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_CONSTANT); 93 91 } 94 92 /* -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4949 r4953 29 29 { 30 30 public: 31 TestGun ( PNode* parent, const Vector& coordinate, const Quaternion& direction,int leftRight);31 TestGun (int leftRight); 32 32 virtual ~TestGun (); 33 33 -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4950 r4953 39 39 * creates a new weapon 40 40 */ 41 Weapon::Weapon ( PNode* parent, const Vector& coordinate, const Quaternion& direction)41 Weapon::Weapon () 42 42 { 43 43 this->init(); 44 parent->addChild(this, PNODE_ALL);45 this->setRelCoor(coordinate);46 this->setRelDir(direction);47 44 } 48 45 -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4950 r4953 72 72 public: 73 73 // INITIALISATION // 74 Weapon ( PNode* parent, const Vector& coordinate, const Quaternion& direction);74 Weapon (); 75 75 Weapon(const TiXmlElement* root); 76 76 virtual ~Weapon (); -
orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
r4952 r4953 28 28 #include "list.h" 29 29 #include "t_animation.h" 30 #include "null_parent.h" 30 31 31 32 using namespace std; … … 36 37 * @param number of weapon slots of the model/ship <= 8 (limitied) 37 38 */ 38 WeaponManager::WeaponManager( unsigned int slotCount)39 WeaponManager::WeaponManager(PNode* parent) 39 40 { 40 41 this->init(); 41 this->set SlotCount(slotCount);42 this->setParent(parent); 42 43 } 43 44 … … 130 131 } 131 132 133 void WeaponManager::setParent(PNode* parent) 134 { 135 if (parent == NULL) 136 parent = NullParent::getInstance(); 137 this->parent = parent; 138 if (this->parent != NULL) 139 { 140 for (int i = 0; i < WM_MAX_SLOTS; i++) 141 this->parent->addChild(&this->currentSlotConfig[i].position); 142 } 143 144 } 132 145 133 146 /** … … 141 154 else 142 155 this->slotCount = WM_MAX_SLOTS; 156 } 157 158 void WeaponManager::setSlotPosition(int slot, const Vector& position) 159 { 160 if (slot < this->slotCount) 161 this->currentSlotConfig[slot].position.setRelCoor(position); 143 162 } 144 163 … … 174 193 } 175 194 } 195 196 //! @todo check if the weapon is already assigned to another config in another slot 197 176 198 this->configs[configID][slotID] = weapon; 199 if (this->parent != NULL) 200 weapon->setParent(parent); 177 201 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID); 178 202 } … … 189 213 /** 190 214 * changes to the next weapon configuration 191 *192 * if there are multiple weapon configurations defined by the manager, use this to switch between them193 * this function will deactivate the weapons first, change the config and reactivate them later194 215 */ 195 216 void WeaponManager::nextWeaponConf() … … 199 220 this->currentConfigID = 0; 200 221 this->changeWeaponConfig(this->currentConfigID); 201 this->debug(); 202 } 203 222 } 223 224 /** 225 * changes to the previous configuration 226 */ 204 227 void WeaponManager::previousWeaponConfig() 205 228 { … … 208 231 this->currentConfigID = WM_MAX_CONFIGS -1; 209 232 this->changeWeaponConfig(this->currentConfigID); 210 this->debug(); 211 212 213 } 214 233 } 234 235 /** 236 * change to a desired configuration 237 * @param weaponConfig the configuration to jump to. 238 */ 215 239 void WeaponManager::changeWeaponConfig(int weaponConfig) 216 240 { … … 220 244 { 221 245 this->currentSlotConfig[i].nextWeapon = this->configs[currentConfigID][i]; 222 if (this->currentSlotConfig[i].currentWeapon != NULL && this->currentSlotConfig[i].currentWeapon != this->currentSlotConfig[i].nextWeapon) 223 (this->currentSlotConfig[i].currentWeapon->requestAction(WA_DEACTIVATE)); 246 if (this->currentSlotConfig[i].currentWeapon != this->currentSlotConfig[i].nextWeapon) 247 { 248 if (this->currentSlotConfig[i].currentWeapon != NULL) 249 (this->currentSlotConfig[i].currentWeapon->requestAction(WA_DEACTIVATE)); 250 if (this->currentSlotConfig[i].nextWeapon != NULL && this->currentSlotConfig[i].nextWeapon->isActive()) 251 this->currentSlotConfig[i].nextWeapon = NULL; 252 } 224 253 } 225 254 } … … 265 294 tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon; 266 295 if (tickWeapon != NULL) 296 { 267 297 tickWeapon->requestAction(WA_ACTIVATE); 298 tickWeapon->setParent(&this->currentSlotConfig[i].position); 299 } 268 300 } 269 301 } … … 308 340 309 341 342 /** 343 * outputs some nice debug information about the WeaponManager 344 */ 310 345 void WeaponManager::debug() const 311 346 { -
orxonox/trunk/src/world_entities/weapons/weapon_manager.h
r4952 r4953 29 29 #include "base_object.h" 30 30 31 #include " vector.h"31 #include "p_node.h" 32 32 33 33 // FORWARD DECLARATION … … 61 61 typedef struct 62 62 { 63 Vectorposition; //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager)63 PNode position; //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager) 64 64 long capability; //!< the capabilities of the Slot @see WM_SlotCapability. 65 65 … … 68 68 } WM_Slot; 69 69 70 //! This is a special class, that can handle many different Weapons of a ship/man/whatever. 71 /** 72 * this class is designed to interactively changeing multiple weapons (or just one), 73 * and to allow the Weapon itself to enable/disable itself. 74 * 75 * How to configure 76 * 1. set the default values. 77 * 2. define weapons. connect them to the WeaponManager's configurations 78 * 3. go on and run :).... 79 */ 70 80 class WeaponManager : public BaseObject { 71 81 public: 72 WeaponManager( unsigned int slotCount);82 WeaponManager(PNode* parent); 73 83 WeaponManager(const TiXmlElement* root); 74 84 ~WeaponManager(); … … 81 91 void setSlotPosition(int slot, const Vector& position); 82 92 void setSlotCapability(long slotCapability); 93 void setParent(PNode* parent); 83 94 84 95 void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
Note: See TracChangeset
for help on using the changeset viewer.