Changeset 4827 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons
- Timestamp:
- Jul 9, 2005, 12:48:50 AM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities/weapons
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4758 r4827 1 /*! 1 /*! 2 2 \file weapon.h 3 3 \brief a weapon that a player can use … … 12 12 o slowdown-factor: this is a factor d: exp(-d*x), d is element of all positive R. it determines how fast the firing-rate will slow down. if no slowdown: d=0, the bigger d is, the faster the weapon will slow down! 13 13 o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile 14 14 15 15 Furthermore there are some other attributes, that will help to represent a firing 16 16 weapon in this world: 17 17 o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented 18 18 o shooting animation 19 19 20 20 */ 21 21 … … 36 36 friend class World; 37 37 38 public:39 TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight);40 virtual ~TestGun ();38 public: 39 TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight); 40 virtual ~TestGun (); 41 41 42 virtual void activate();43 virtual void deactivate();42 virtual void activate(); 43 virtual void deactivate(); 44 44 45 virtual void fire(); 46 virtual void hit (WorldEntity* weapon, Vector* loc); 47 virtual void destroy(); 48 49 virtual void tick(float time); 50 virtual void weaponIdle(); 51 virtual void draw(); 45 virtual void fire(); 46 virtual void hit (WorldEntity* weapon, Vector* loc); 47 virtual void destroy(); 52 48 49 virtual void tick(float time); 50 virtual void weaponIdle(); 51 virtual void draw(); 52 53 private: 54 Animation3D* animation1; 55 Animation3D* animation2; 56 Animation3D* animation3; 57 58 PNode* objectComponent1; //<! the gun is made of multiple parts, these PNodes represent their location and orientation 59 PNode* objectComponent2; 60 PNode* objectComponent3; 61 62 Vector projectileOffset; 63 int leftRight; // this will become an enum 53 64 54 65 -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4826 r4827 17 17 #include "weapon_manager.h" 18 18 #include "weapon.h" 19 #include "stdincl.h"20 #include "world_entity.h"21 19 #include "vector.h" 22 #include "model.h"23 20 #include "projectile.h" 24 21 #include "list.h" … … 31 28 */ 32 29 Weapon::Weapon (PNode* parent, const Vector& coordinate, const Quaternion& direction) 33 : WorldEntity()34 30 { 35 31 parent->addChild(this, PNODE_ALL); … … 38 34 WorldInterface* wi = WorldInterface::getInstance(); 39 35 this->worldEntities = wi->getEntityList(); 40 41 this->objectComponent1 = NULL;42 this->objectComponent2 = NULL;43 this->objectComponent3 = NULL;44 45 this->animation1 = NULL;46 this->animation2 = NULL;47 this->animation3 = NULL;48 36 } 49 37 -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4826 r4827 1 1 /*! 2 2 \file weapon.h 3 \brief a weapon that a playercan use3 \brief a weapon that a can use 4 4 5 5 … … 42 42 // } WeaponSoundType; 43 43 44 45 //! An enumerator defining the States of a Weapon 44 46 typedef enum { 45 W_NONE, 46 W_SHOOT, 47 W_RELOAD, 48 W_ACTIVATING, 49 W_DEACTIVATE, 50 W_IDLE, 47 W_NONE = 0, //!< No State at all (if set, there is something wrong, or the weapon is not yet availiable) 48 W_SHOOT = 1, //!< The State of the Shooting 49 W_RELOAD = 2, //!< The State of the Reloading 50 W_ACTIVATING = 3, //!< The State in which the weapon gets activated 51 W_DEACTIVATING = 4, //!< The State in which the weapon gets deactivated 52 W_INACTIVE = 5, //!< The State where the weapon is inactive (unable to shoot) 53 W_IDLE = 6, //!< The State where the weapon is idle 54 55 W_STATES_COUNT = 6 //!< This must match the count of the enumerations (without W_NONE) 51 56 } WeaponState; 52 57 … … 56 61 #define W_RIGHT 1 57 62 58 59 60 61 63 //! An abstract class, that describes weapons 64 /** 65 * This is used as a container for all the different kinds of weapons that may exist 66 * Animations/Sounds/etc. will be handled in the Extensions of this class. 67 */ 62 68 class Weapon : public WorldEntity 63 69 { … … 84 90 85 91 86 /** 87 \brief sets a weapons idle time 88 \param idle time in ms 92 /** @param idle time in ms */ 93 inline void setWeaponIdleTime(float idleTime) { this->idleTime = idleTime; }; 94 /** @returns idle time in ms */ 95 inline float getWeaponIdleTime() const { return this->idleTime; }; 96 /** @return true if idletime is elapsed else otherwise */ 97 inline bool hasWeaponIdleTimeElapsed() const { return (this->localTime>this->idleTime)?true:false; }; 89 98 90 a weapon idle time is the time spend after a shoot until the weapon can 91 shoot again 92 */ 93 inline void setWeaponIdleTime(float time) { this->idleTime = time; } 94 /** 95 \brief gets the weapon idle time 96 \returns idle time in ms 97 */ 98 inline float getWeaponIdleTime() const { return this->idleTime;} 99 /** 100 \brief checks if the idle time is elapsed 101 \return true if time is elapsed 102 103 a weapon idle time is the time spend after a shoot until the weapon can 104 shoot again 105 */ 106 inline bool hasWeaponIdleTimeElapsed() const { return (this->localTime>this->idleTime)?true:false; } 107 108 /** 109 \brief fires the weapon 110 111 this is called from the player.cc, when fire-button is been pushed 112 */ 99 /** @brief fires the weapon */ 113 100 virtual void fire() = 0; 114 101 virtual void hit (WorldEntity* weapon, Vector* loc); … … 120 107 121 108 protected: 122 tList<WorldEntity>* worldEntities; 123 float localTime; //<! this is the local time. important for shooting attributes like frequency 124 float idleTime; //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay 125 float slowDownFactor; //<! if the shooting frequency is a linear function of time... 109 tList<WorldEntity>* worldEntities; 126 110 127 PNode* objectComponent1; //<! the gun is made of multiple parts, these PNodes represent their location and orientation128 PNode* objectComponent2;129 PNode* objectComponent3;111 float localTime; //<! this is the local time. important for shooting attributes like frequency 112 float idleTime; //<! the time a weapon needs before it can shoot again. eg. shooting frequency or actication/deactivateion delay 113 float slowDownFactor; //<! if the shooting frequency is a linear function of time... 130 114 131 Animation3D* animation1; 132 Animation3D* animation2; 133 Animation3D* animation3; 134 135 Vector projectileOffset; 136 int leftRight; // this will become an enum 137 138 SoundBuffer* fireSound; 139 SoundSource* weaponSource; 115 SoundBuffer* fireSound; 116 SoundSource* weaponSource; 140 117 141 118 142 119 private: 143 bool enabled; //<! states if the weapon is enabled or not144 Projectile* projectile; //<! the projectile used for this weapon120 bool enabled; //<! states if the weapon is enabled or not 121 Projectile* projectile; //<! the projectile used for this weapon 145 122 //WeaponSound sound; 146 123 };
Note: See TracChangeset
for help on using the changeset viewer.