- Timestamp:
- Apr 4, 2019, 4:37:19 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc
r12254 r12281 21 21 * 22 22 * Author: 23 * Fabien Vultier23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ 28 28 29 29 /** 30 @file IceGun.cc31 @brief Implementation of the IceGunclass.30 @file HsW01.h 31 @brief Implementation of the HsW01 class. 32 32 */ 33 33 … … 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h" 37 #include "core/XMLPort.h" 38 #include "core/command/Executor.h" 39 40 #include "graphics/Model.h" 38 41 #include "weaponsystem/Weapon.h" 39 42 #include "weaponsystem/WeaponPack.h" 40 43 #include "weaponsystem/WeaponSystem.h" 44 #include "worldentities/WorldEntity.h" 41 45 #include "worldentities/pawns/Pawn.h" 42 46 43 #include "BallProjectile.h" 47 #include "weapons/projectiles/Projectile.h" 48 #include "weapons/MuzzleFlash.h" 44 49 45 50 namespace orxonox … … 51 56 RegisterObject(BallGun); 52 57 53 // Default values 54 this->reloadTime_ = 1.0f; 55 this->damage_ = 0.0f; 56 this->speed_ = 1200.0f; 58 this->reloadTime_ = 0.25f; 59 this->damage_ = 0.0f; //default 15 60 this->speed_ = 750.0f; 61 this->delay_ = 0.0f; 62 this->setMunitionName("BallMunition"); 63 this->mesh_ = "laserbeam.mesh"; 57 64 58 65 59 this->setMunitionName("BallMunition"); 60 this->setFireSound("sounds/Weapon_LightningGun.ogg"); 61 this->setReloadSound("sounds/Reload_IceGun.ogg", 0.4); 66 this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this))); 67 this->delayTimer_.stopTimer(); 62 68 63 hudImageString_ = "Orxonox/WSHUD_WM_IceGun"; 69 this->setFireSound("sounds/Weapon_HsW01.ogg"); 70 this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5); 71 72 hudImageString_ = "Orxonox/WSHUD_WM_HsW01"; 64 73 } 65 74 … … 68 77 } 69 78 79 void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode) 80 { 81 SUPER(BallGun, XMLPort, xmlelement, mode); 82 83 XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode); 84 XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode); 85 XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode); 86 XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode); 87 } 88 89 /** 90 @brief 91 Set the firing delay. 92 @param delay 93 The firing delay in seconds. 94 */ 95 void BallGun::setDelay(float delay) 96 { 97 orxout() << "delay" << endl; 98 this->delay_ = delay; 99 this->delayTimer_.setInterval(this->delay_); 100 } 101 102 void BallGun::fire() 103 { 104 orxout() << "fire" << endl; 105 this->delayTimer_.startTimer(); 106 } 107 70 108 /** 71 109 @brief 72 110 Fires the weapon. Creates a projectile and fires it. 73 111 */ 74 void BallGun:: fire()112 void BallGun::shot() 75 113 { 76 BallProjectile* projectile = new BallProjectile(this->getContext()); 114 assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() ); 115 orxout() << "sajkfg" << endl; 116 // Create the projectile. 117 Projectile* projectile = new Projectile(this->getContext()); 118 Model* model = new Model(projectile->getContext()); 119 model->setMeshSource(mesh_); 120 model->setCastShadows(false); 121 projectile->attach(model); 122 model->setScale(5); 77 123 78 124 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); … … 85 131 projectile->setShieldDamage(this->getShieldDamage()); 86 132 projectile->setHealthDamage(this->getHealthDamage()); 133 134 // Display the muzzle flash. 135 this->BallGun::muzzleflash(); 136 } 137 138 /** 139 @brief 140 Displays the muzzle flash. 141 */ 142 void BallGun::muzzleflash() 143 { 144 MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext()); 145 this->getWeapon()->attach(muzzleFlash); 146 muzzleFlash->setPosition(this->getMuzzleOffset()); 147 muzzleFlash->setMaterial(this->material_); 87 148 } 88 149 }
Note: See TracChangeset
for help on using the changeset viewer.