Changeset 2145 for code/branches/weapon2/src/orxonox/objects
- Timestamp:
- Nov 5, 2008, 7:57:16 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox/objects
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/controllers/HumanController.cc
r2087 r2145 103 103 { 104 104 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 105 HumanController::localController_s->controllableEntity_->fire( );105 HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire); 106 106 } 107 107 … … 109 109 { 110 110 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 111 HumanController::localController_s->controllableEntity_-> altFire();111 HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire); 112 112 } 113 113 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2098 r2145 35 35 #include "Weapon.h" 36 36 37 37 38 namespace orxonox 38 39 { … … 40 41 { 41 42 RegisterObject(Weapon); 42 43 this->loadingTime_ = 0; 44 this->munition_ = 0; 43 this->weaponReadyToShoot_ = true; 44 //this->setParentWeaponSystem(); 45 45 46 46 } … … 50 50 } 51 51 52 void Weapon::addMunition()53 {54 55 }56 52 57 53 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 64 60 65 61 } 62 63 void Weapon::reloaded() 64 { 65 this->weaponReadyToShoot_ = true; 66 } 67 68 void Weapon::attachNeededMunition(Munition *PointerToMunition) 69 { 70 71 } 72 /* 73 void Weapon::setParentWeaponSystem() 74 { 75 this->parentWeaponSystem_ = this->parentWeaponSlot_->parentWeaponSet_->parentWeaponSystem_; 76 } 77 */ 78 66 79 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2106 r2145 33 33 34 34 #include "core/BaseObject.h" 35 35 #include "tools/BillboardSet.h" 36 #include "tools/Timer.h" 36 37 37 38 namespace orxonox … … 45 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 47 47 void addMunition();48 48 virtual void fire(); 49 void reloaded(); 50 virtual void attachNeededMunition(Munition *PointerToMunition); 51 52 inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot) 53 { parentWeaponSlot_=parentWeaponSlot; }; 54 inline WeaponSlot * getParentWeaponSlot() 55 { return parentWeaponSlot_; }; 56 57 //void setParentWeaponSystem(); 49 58 50 59 private: 51 int loadingTime_; 52 Munition *munition_; 53 60 bool weaponReadyToShoot_; 61 float loadingTime_; 62 Munition *pointerToMunition_; 63 WeaponSlot *parentWeaponSlot_; 64 //WeaponSystem *parentWeaponSystem_; 65 Timer<Weapon> reloadTimer_; 54 66 55 67 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2098 r2145 54 54 } 55 55 56 //Vorwärtsdeklaration57 WeaponSystem * parentWeaponSystem_;58 59 56 void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot) 60 57 { -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2098 r2145 36 36 37 37 38 39 38 namespace orxonox 40 39 { 41 WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator)40 WeaponSlot::WeaponSlot(BaseObject* creator) : PositionableEntity(creator) 42 41 { 43 42 RegisterObject(WeaponSlot); 44 43 45 44 this->unlimitedAmmo_ = false; 46 47 45 this->attachedWeapon_ = 0; 48 46 this->parentWeaponSet_ = 0; 47 this->setObjectMode(0x0); 49 48 } 50 49 … … 53 52 } 54 53 55 void WeaponSlot::attachWeapon(Weapon *weapon Name)54 void WeaponSlot::attachWeapon(Weapon *weaponPointer) 56 55 { 56 this->attachedWeapon_ = weaponPointer; 57 } 57 58 58 }59 59 60 60 /*sets the munition type … … 69 69 void WeaponSlot::fire() 70 70 { 71 71 this->attachedWeapon_->fire(); 72 72 } 73 73 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2106 r2145 36 36 37 37 #include "Weapon.h" 38 38 #include "../worldentities/PositionableEntity.h" 39 39 40 40 namespace orxonox 41 41 { 42 class _OrxonoxExport WeaponSlot : public BaseObject42 class _OrxonoxExport WeaponSlot : public PositionableEntity 43 43 { 44 44 public: … … 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 void attachWeapon(Weapon *weapon Name);50 void attachWeapon(Weapon *weaponPointer); 51 51 void setAmmoType(bool isUnlimited); 52 52 void fire(); … … 56 56 inline WeaponSet * getParentWeaponSet() 57 57 { return parentWeaponSet_; } 58 59 58 60 59 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2106 r2145 45 45 namespace orxonox 46 46 { 47 47 48 WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator) 48 49 { … … 51 52 this->activeWeaponSet_ = 0; 52 53 this->parentSpaceShip_ = 0; 54 //this->attachedMunition_ =0; 53 55 } 54 56 … … 57 59 } 58 60 59 //creates empty weaponSet60 61 void WeaponSystem::attachWeaponSet(WeaponSet *wSet) 61 62 { … … 64 65 } 65 66 67 /* 66 68 //the first weaponSet is at n=0 67 69 void WeaponSystem::setActiveWeaponSet(unsigned int n) … … 69 71 if (n < this->weaponSets_.size()) 70 72 this->activeWeaponSet_ = this->weaponSets_[n]; 73 else 74 this->activeWeaponSet_ = this->weaponSets_[0]; 71 75 } 76 */ 72 77 73 78 //n is the n'th weaponSet, starting with zero 74 //Space ship.cc only needs to have the keybinding to a specific Set-number n75 void WeaponSystem::fire( unsigned intn)79 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 80 void WeaponSystem::fire(WeaponMode::Enum n) 76 81 { 77 82 if (n < this->weaponSets_.size()) … … 79 84 } 80 85 81 void WeaponSystem::fire()82 {83 if (this->activeWeaponSet_)84 this->activeWeaponSet_->fire();85 }86 86 87 87 WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n) … … 98 98 } 99 99 100 /* 101 void WeaponSystem::addMunitionType(Munition *munitionPointer) 102 { 103 104 105 if (munitionPointer != NULL) //gewährleiste, dass munitionPointer auf etwas sinnvolles zeigt 106 this->attachedMunition_ = munitionPointer; 107 else 108 this->unlimitedAmmo_ = true; 109 110 } 111 */ 112 100 113 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h
r2107 r2145 39 39 namespace orxonox 40 40 { 41 //put here all existing munitionTypes 42 namespace MunitionType 43 { 44 enum Enum 45 { LaserGunMunition }; 46 } 47 48 //put here all weapon fire modes. 49 //they have to be added to Pawn and HumanController, too. 50 namespace WeaponMode 51 { 52 enum Enum 53 { fire, altFire, altFire2 }; 54 } 55 41 56 class _OrxonoxExport WeaponSystem : public BaseObject 42 57 { … … 48 63 49 64 void attachWeaponSet(WeaponSet *wSet); 65 void addMunitionType(Munition *munitionPointer); 50 66 void fire(); 51 void fire( unsigned int n);52 void setActiveWeaponSet(unsigned int n);67 void fire(WeaponMode::Enum fireMode); 68 //void setActiveWeaponSet(unsigned int n); 53 69 WeaponSet * getWeaponSetPointer(unsigned int n); 54 70 … … 61 77 private: 62 78 std::vector<WeaponSet *> weaponSets_; 79 std::map<MunitionType::Enum,Munition *> munitionSet_; 63 80 WeaponSet *activeWeaponSet_; 64 65 81 SpaceShip *parentSpaceShip_; 66 82 }; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
r2106 r2145 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport LaserGunMunition : public BaseObject39 class _OrxonoxExport LaserGunMunition : public Munition 40 40 { 41 41 public: -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2097 r2145 41 41 RegisterObject(LaserGun); 42 42 43 projectileColor_ = ColourValue(1.0, 1.0, 0.5) 43 this->attachNeededMunition(); 44 45 //set weapon properties here 46 this->projectileColor_ = ColourValue(1.0, 1.0, 0.5) 47 this->loadingTime_ = 0.5; 44 48 } 45 49 … … 50 54 LaserGun::fire() 51 55 { 56 if { this->weaponReadyToShoot_ } 57 { 58 this->weaponReadyToShoot_ = false; 59 //take munition 60 //this->pointerToMunition_-> 61 62 this->reloadTimer_.setTimer( loadingTime_ , false , this , &this->reloaded ); 63 52 64 BillboardProjectile* projectile = new ParticleProjectile(this); 53 projectile->setColour(this->projectileColor_); 54 projectile->create(); 55 if (projectile->getClassID() == 0) 56 { 57 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 58 } 59 60 projectile->setObjectMode(0x3); 61 } 62 63 LaserGun::addMunition() 64 { 65 //this->munition_ = ; 65 projectile->setColour(this->getProjectileColour()); 66 } 67 else 68 { 69 //actions, when weapon is not reloaded 70 } 66 71 } 67 72 … … 75 80 return projectileColor_; 76 81 } 82 83 void attachNeededMunition(Munition *pointerToMunition) 84 { 85 //if munition type already exist attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 86 if ( this->parentWeaponSystem_->munitionSet_[laserGunMunition] ) 87 this->pointerToMunition_ = pointerToMunition; 88 else 89 { 90 this->pointerToMunition_ = new LaserGunMunition; 91 92 } 93 } 77 94 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2106 r2145 35 35 36 36 #include "LaserGunMunition.h" 37 #include "tools/BillboardSet.h"38 37 #include "util/Math.h" 39 38 … … 48 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 48 49 void fire(); 50 50 ColourValue LaserGun::getProjectileColour(); 51 51 … … 53 53 ColorValue projectileColor_; 54 54 55 56 57 55 }; 58 56 } -
code/branches/weapon2/src/orxonox/objects/worldentities/ControllableEntity.h
r2087 r2145 34 34 #include "WorldEntity.h" 35 35 #include "objects/Tickable.h" 36 #include "objects/weaponSystem/WeaponSystem.h" 36 37 37 38 namespace orxonox … … 65 66 virtual void rotateRoll(const Vector2& value) {} 66 67 67 virtual void fire( ) {}68 virtual void altFire( ) {}68 virtual void fire(WeaponMode::Enum fireMode) {} 69 virtual void altFire(WeaponMode::Enum fireMode) {} 69 70 70 71 virtual void greet() {} -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2106 r2145 35 35 #include "objects/infos/PlayerInfo.h" 36 36 #include "objects/gametypes/Gametype.h" 37 #include "objects/weaponSystem/WeaponSystem.h" 37 38 38 39 39 namespace orxonox … … 54 54 this->weaponSystem_ = 0; 55 55 56 //WeaponSystem 57 weaponSystem_ = new WeaponSystem(this); 56 58 /* 57 //WeaponSystem58 weaponSystem_ = new WeaponSystem();59 59 WeaponSet * weaponSet1 = new WeaponSet(1); 60 60 this->weaponSystem_->attachWeaponSet(weaponSet1); … … 137 137 } 138 138 139 void Pawn::fire( )139 void Pawn::fire(WeaponMode::Enum fireMode) 140 140 { 141 141 if (this->weaponSystem_) 142 this->weaponSystem_->fire( );142 this->weaponSystem_->fire(fireMode); 143 143 } 144 144 -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2145 33 33 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/weaponSystem/WeaponSystem.h" 35 36 36 37 namespace orxonox … … 74 75 virtual void kill(); 75 76 76 virtual void fire( );77 virtual void fire(WeaponMode::Enum fireMode); 77 78 78 79 virtual void postSpawn();
Note: See TracChangeset
for help on using the changeset viewer.