Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3862 in orxonox.OLD


Ignore:
Timestamp:
Apr 18, 2005, 9:15:08 AM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: introducing weapon configuration and slots. some mechanisms to load (pre)defined weapon constellations and to use multiple guns at the same time. depending on the number of weapon slots a ship defines

Location:
orxonox/trunk/src/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapon.cc

    r3810 r3862  
    2929
    3030
     31
     32WeaponManager::WeaponManager(int nrOfSlots)
     33{
     34  this->nrOfSlots = nrOfSlots;
     35  this->nrOfConfigs = 1;
     36
     37  for(int i = 0; i < W_MAX_CONFS; ++i)
     38    this->configs[i] = NULL;
     39  this->currentConfig = new weaponConfig;
     40  this->configs[0] = this->currentConfig;
     41}
     42
     43WeaponManager::~WeaponManager()
     44{
     45
     46}
     47
     48void WeaponManager::addWeapon(Weapon* weapon, slotID slot, configID config)
     49{
     50  if(this->configs[config] == NULL)
     51    PRINTF(0)("");
     52  //  this->configs[(int)config]->
     53}
     54
     55void WeaponManager::addWeaponConfig(weaponConfig* config)
     56{}
     57
     58void WeaponManager::nextWeaponConf()
     59{}
     60
     61void WeaponManager::prevWeaponConf()
     62{}
     63
     64
     65void WeaponManager::selectConfig(configID config)
     66{
     67  if( this->configs[(int)config] != NULL)
     68    this->currentConfig = this->configs[(int)config];
     69  else
     70    PRINTF(0)("There is no weapon config defined with the number W_CONF%i", (int)config);
     71}
     72
     73
     74
    3175/**
    3276   \brief standard constructor
  • orxonox/trunk/src/world_entities/weapon.h

    r3685 r3862  
    1818     o shooting animation
    1919     
     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...
    2027*/
    2128
     
    2633#include "world_entity.h"
    2734
     35#define W_MAX_SLOTS 8
     36#define W_MAX_CONFS 4
     37
    2838class Projectile;
     39class Weapon;
    2940
    3041typedef enum {
     
    3748} weaponSoundType;
    3849
     50//! 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
     51typedef enum slotID {W_SLOT0=0, W_SLOT1, W_SLOT2, W_SLOT3,
     52                     W_SLOT4, W_SLOT5, W_SLOT6, W_SLOT7};
     53
     54//! this is an identifier for the weapon config
     55typedef enum configID {W_CONFIG0=0, W_CONFIG1,
     56                       W_CONFIG2, W_CONFIG3};
     57
     58//! this is a weapon Configuration: it has up to 8 slots
     59typedef struct weaponConfig {
     60  Weapon* slot1;                    //<! standard right side weapon
     61  Weapon* slot2;                    //<! standard left side weapon
     62  Weapon* slot3;                    //<! custom
     63  Weapon* slot4;                    //<! custom
     64  Weapon* slot5;                    //<! custom
     65  Weapon* slot6;                    //<! custom
     66  Weapon* slot7;                    //<! custom
     67  Weapon* slot8;                    //<! custom
     68};
     69
     70
     71class WeaponManager {
     72 public:
     73  WeaponManager(int nrOfSlots = 2);
     74  ~WeaponManager();
     75 
     76  void addWeapon(Weapon* weapon, slotID slot, configID config = W_CONFIG0);
     77  void addWeaponConfig(weaponConfig* config);
     78
     79  void nextWeaponConf();
     80  void prevWeaponConf();
     81  void selectConfig(configID config);
     82
     83 private:
     84  int nrOfConfigs;                      //<! number of configurations defined
     85  int nrOfSlots;                        //<! number of weapon slots a ship has
     86  weaponConfig* currentConfig;          //<! the currently selected config
     87  weaponConfig* configs[4];             //<! a list of four configurations
     88};
    3989
    4090class Weapon : public WorldEntity
Note: See TracChangeset for help on using the changeset viewer.