Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4949 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Jul 24, 2005, 3:11:36 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new Definitions in the WeaponManager-class

Location:
orxonox/trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc

    r4929 r4949  
    171171    this->nodes[i + j * this->maxIndex]->includesPoint(position);
    172172  else
    173     PRINTF(0)("Object has left terrain\n");
     173    PRINTF(5)("Object has left terrain\n");
    174174}
    175175
  • orxonox/trunk/src/world_entities/weapons/test_gun.h

    r4947 r4949  
    11/*!
    2     \file weapon.h
     2    @file weapon.h
    33  *  a weapon that a player can use
    44
    55    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
     6    (projectiles.{cc,h}) at enemies. These weapons can be shooted sequentially
    77    or (if able) combined. Therefore you can choose the weapon mode = choose
    88    a weapon.
     
    2626#include "weapon.h"
    2727
    28 class Projectile;
    29 class Vector;
    30 class Quaternion;
    31 class Animation3D;
    32 class TestBullet;
    33 
    34 
    3528class TestGun : public Weapon
    3629  {
     
    5043  private:
    5144    PNode* objectComponent1;         //<! the gun is made of multiple parts, these PNodes represent their location and orientation
    52     PNode* objectComponent2;
    53     PNode* objectComponent3;
    5445
    5546    int leftRight;   // this will become an enum
  • orxonox/trunk/src/world_entities/weapons/weapon.cc

    r4948 r4949  
    301301bool Weapon::deactivateW()
    302302{
    303   if (this->currentState != WS_INACTIVE)
     303//  if (this->currentState != WS_INACTIVE)
    304304  {
    305305    PRINTF(4)("Deactivating the Weapon %s\n", this->getName());
     
    403403inline void Weapon::enterState(WeaponState state)
    404404{
     405  PRINTF(3)("ENTERING STATE %s\n", stateToChar(state));
    405406  // playing animation if availiable
    406407  if (likely(this->animation[state] != NULL))
     
    427428  this->stateDuration -= dt;
    428429
    429   if (this->isActive())
    430   {
    431     if (this->stateDuration <= 0.0)
    432     {
    433       if (unlikely (this->currentState == WS_DEACTIVATING))
    434       {
    435         this->currentState = WS_INACTIVE;
    436         return;
    437       }
    438       else
    439         this->currentState = WS_IDLE;
    440 
    441       if (this->requestedAction != WA_NONE)
    442       {
    443         this->stateDuration = -dt;
    444         this->execute();
    445       }
     430  if (this->stateDuration <= 0.0)
     431  {
     432    if (unlikely (this->currentState == WS_DEACTIVATING))
     433    {
     434      this->currentState = WS_INACTIVE;
     435      return;
     436    }
     437    else
     438      this->currentState = WS_IDLE;
     439
     440    if (this->requestedAction != WA_NONE)
     441    {
     442      this->stateDuration = -dt;
     443      this->execute();
    446444    }
    447445  }
  • orxonox/trunk/src/world_entities/weapons/weapon.h

    r4947 r4949  
    9090    /** @returns true if the weapon must be drawn */
    9191    inline bool isVisible() const { return (this->currentState != WS_INACTIVE || !this->hideInactive)?true:false; };
     92    /** @returns true if the Weapon is chargeable */
     93    inline bool isChargeable() const { return this->chargeable; };
    9294
    9395    // FUNCTIONS TO SET THE WEAPONS PROPERTIES.
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.cc

    r4926 r4949  
    4040}
    4141
     42WeaponManager::WeaponManager(const TiXmlElement* root)
     43{
     44  this->init();
     45  this->loadParams(root);
     46}
    4247
    4348/**
     
    5156  world will clean them up for me
    5257  */
    53   for(int i = 0; i < W_MAX_CONFIGS; ++i)
     58  for(int i = 0; i < WM_MAX_CONFIGS; ++i)
    5459  {
    5560    this->configs[i].bUsed = false;
    56     for(int j = 0; j < W_MAX_SLOTS; ++j)
     61    for(int j = 0; j < WM_MAX_SLOTS; ++j)
    5762      this->configs[i].slots[j] = NULL;
    5863  }
     
    6974  this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
    7075
    71   for(int i = 0; i < W_MAX_CONFIGS; ++i)
     76  for(int i = 0; i < WM_MAX_CONFIGS; ++i)
    7277  {
    7378    this->configs[i].bUsed = false;
    74     for(int j = 0; j < W_MAX_SLOTS; ++j)
     79    for(int j = 0; j < WM_MAX_SLOTS; ++j)
    7580      this->configs[i].slots[j] = NULL;
    7681  }
     
    186191  int i, lastConfID;
    187192  lastConfID = this->currConfID;
    188   for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
    189   if( i == W_MAX_CONFIGS) this->currConfID = WM_CONFIG0;
     193  for(i = this->currConfID + 1; i < WM_MAX_CONFIGS && !this->configs[i].bUsed; ++i);
     194  if( i == WM_MAX_CONFIGS) this->currConfID = WM_CONFIG0;
    190195  else this->currConfID = i;
    191196
    192197
    193198  Weapon *w1, *w2;
    194   for(int j = 0; j < W_MAX_SLOTS; ++j)
     199  for(int j = 0; j < WM_MAX_SLOTS; ++j)
    195200  {
    196201    w1 = this->configs[lastConfID].slots[j];
     
    224229{
    225230  Weapon* firingWeapon;
    226   for(int i = 0; i < W_MAX_SLOTS; ++i)
     231  for(int i = 0; i < WM_MAX_SLOTS; ++i)
    227232  {
    228233    firingWeapon = this->configs[this->currConfID].slots[i];
     
    241246{
    242247  Weapon* w;
    243   for(int i = 0; i < W_MAX_SLOTS; ++i)
     248  for(int i = 0; i < WM_MAX_SLOTS; ++i)
    244249  {
    245250    w = this->configs[this->currConfID].slots[i];
     
    259264  Weapon* w;
    260265  for (int j = 0; j < 4; ++j )
    261   for(int i = 0; i < W_MAX_SLOTS; ++i)
     266  for(int i = 0; i < WM_MAX_SLOTS; ++i)
    262267  {
    263268    w = this->configs[j].slots[i];
     
    274279int WeaponManager::getNextFreeSlot(int configID)
    275280{
    276   for( int i = 0; i < W_MAX_SLOTS; ++i)
     281  for( int i = 0; i < WM_MAX_SLOTS; ++i)
    277282  {
    278283    if( this->configs[configID].slots[i] == NULL)
  • orxonox/trunk/src/world_entities/weapons/weapon_manager.h

    r4930 r4949  
    3535template <class T> class tAnimation;
    3636
    37 #define    W_MAX_SLOTS       8
    38 #define    W_MAX_CONFIGS     4
     37#define    WM_MAX_SLOTS            8                   //!< How many slots the WeaponManager has at its max
     38#define    WM_MAX_CONFIGS          4                   //!< The maximum number of predefined Configurations
     39#define    WM_MAX_LOADED_WEAPONS   20                  //!< The
    3940
    4041//! this is an identifier for the weapon config
     
    6667} WM_SLOT;
    6768
     69typedef enum
     70{
     71  WM_SLOTC_DIRECTIONAL   = 1,
     72  WM_SLOTC_TURRET        = 2,
     73  WM_SLOTC_ALLKINDS      = 3,
     74
     75  WM_SLOTC_FORWARD       = 4,
     76  WM_SLOTC_BACKWARD      = 8,
     77  WM_SLOTC_LEFT          = 16,
     78  WM_SLOTC_RIGHT         = 32,
     79  WM_SLOTC_ALLDIRS       = 60,
     80
     81  WM_SLOTC_ALL           = 63,
     82} WM_SlotCapability;
     83
     84typedef struct WM_Slot
     85{
     86  int           number;
     87  bool          occupied;
     88  long          capability;
     89
     90  Weapon*       currentWeapon;
     91  Weapon*       nextWeapon;
     92};
     93
    6894//! this is a weapon Configuration: it has up to 8 slots
    6995typedef struct
    7096{
    7197  bool           bUsed;                       //!< is set to true, if this configuration is
    72   Weapon*        slots[8];
     98  Weapon*        slots[WM_MAX_SLOTS];
    7399} weaponConfig;
    74100
     
    99125  private:
    100126    Crosshair*              crosshair;               //!< an aim.
    101     tAnimation<Crosshair>*  crossHairSizeAnim;
     127    tAnimation<Crosshair>*  crossHairSizeAnim;       //!< An animation for the crosshair (scaling)
    102128
    103     int                     slotCount;               //<! number of weapon slots a ship has
    104     int                     currConfID;              //<! the currently selected config
    105     weaponConfig            configs[4];              //<! a list of four configurations
     129    int                     slotCount;               //!< number of weapon slots a ship has
     130    int                     currConfID;              //!< the currently selected config
     131    weaponConfig            configs[4];              //!< a list of four configurations
     132
     133    Weapon*                 availiableWeapons[WM_MAX_LOADED_WEAPONS];
    106134};
Note: See TracChangeset for help on using the changeset viewer.