Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/weapons/weapon_manager.h @ 4906

Last change on this file since 4906 was 4906, checked in by bensch, 19 years ago

orxonox/trunk: states are now flow'n through

File size: 3.5 KB
Line 
1/*!
2    \file weapon.h
3  *  a weapon that a player can use
4
5    A Player has a list of weapons, that can be choosen to shoot projectiles
6    (projectiles.{cc,h}) at ennemies. These weapons can be shooted sequentially
7    or (if able) combined. Therefore you can choose the weapon mode = choose
8    a weapon.
9
10    A weapon is characterized by:
11     o firing-rate: the initial firing rate of a weapon (1/s = Herz)
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     o energy-consumption: this determines the energy that has to be used to produce this projectile = costs per projectile
14
15    Furthermore there are some other attributes, that will help to represent a firing
16    weapon in this world:
17     o sound file/ressource: this is a pointer to the sound-file/ressource. however it may be represented
18     o shooting animation
19
20
21     a player defines one or more weapon configurations. a player has got one to eight
22     weapon slots: places where weapons can be attached to. a weapon configuration
23     is a matching between weapons and slots.
24     Since its clear how many weapons a player will have, there is no list of weapons:
25     its hard coded and limited to 8 slots and 4 configs. More would be a waste of
26     memory and time you need to customize and change to a weapon config...
27 */
28
29#include "base_object.h"
30
31
32// FORWARD DECLARATION
33class Weapon;
34class Crosshair;
35template <class T> class tAnimation;
36
37#define    W_MAX_SLOTS       8
38#define    W_MAX_CONFIGS     4
39
40//! this is an identifier for the weapon config
41typedef enum
42{
43  WM_CONFIG0           = 0,
44  WM_CONFIG1           = 1,
45  WM_CONFIG2           = 2,
46  WM_CONFIG3           = 3,
47
48  WM_CONFIGCOUNT       = 4
49} WM_CONFIG;
50
51//! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time
52typedef enum
53{
54  WM_SLOT0              = 0,
55  WM_SLOT1              = 1,
56  WM_SLOT2              = 2,
57  WM_SLOT3              = 3,
58  WM_SLOT4              = 4,
59  WM_SLOT5              = 5,
60  WM_SLOT6              = 6,
61  WM_SLOT7              = 7,
62
63  WM_SLOT_COUNT         = 8,
64
65  WM_FREE_SLOT          = -1
66} WM_SLOT;
67
68//! this is a weapon Configuration: it has up to 8 slots
69typedef struct
70{
71  bool           bUsed;                       //!< is set to true, if this configuration is
72  Weapon*        slots[8];
73} weaponConfig;
74
75
76class WeaponManager : public BaseObject {
77  public:
78    WeaponManager(int nrOfSlots = 2);
79    WeaponManager(const TiXmlElement* root);
80    ~WeaponManager();
81
82    void init();
83    void loadParams(const TiXmlElement* root);
84    void loadWeapons(const TiXmlElement* root);
85
86    void setSlotCount(int nrOfSlots);
87
88    void addWeapon(Weapon* weapon, int configID = WM_CONFIG0, int slotID = WM_FREE_SLOT);
89    void removeWeapon(Weapon* weapon, int configID = WM_CONFIG0);
90    void nextWeaponConf();
91
92    void fire();
93    void tick(float dt);
94    void draw();
95
96  private:
97    int getNextFreeSlot(int configID);
98
99  private:
100    Crosshair*              crosshair;               //!< an aim.
101    tAnimation<Crosshair>*  crossHairSizeAnim;
102
103    int                     nrOfSlots;               //<! number of weapon slots a ship has
104    int                     currConfID;              //<! the currently selected config
105    weaponConfig            configs[4];              //<! a list of four configurations
106
107};
Note: See TracBrowser for help on using the repository browser.