Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9961 in orxonox.OLD for branches/playability


Ignore:
Timestamp:
Nov 26, 2006, 10:15:51 PM (18 years ago)
Author:
marcscha
Message:

Double Weapon Manager implementation

Location:
branches/playability/src/world_entities
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/playable.h

    r9869 r9961  
    117117  void unregisterEvent(int eventType);
    118118
     119protected:
     120  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
     121  bool                  bFire;              //!< If the Ship is firing.
     122  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
     123  Playable::Playmode    playmode;           //!< The current playmode.
     124
    119125private:
    120   WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
    121126  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
    122127
    123128  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
    124129
    125   bool                  bFire;              //!< If the Ship is firing.
    126130  int                   oldFlags;           //!< Used for synchronisation
    127131
     
    131135
    132136  bool                  bDead;
    133   short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
    134   Playable::Playmode    playmode;           //!< The current playmode.
    135137
    136138  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r9959 r9961  
    8484 */
    8585SpaceShip::SpaceShip(const std::string& fileName)
     86    : primWeaponMan(this),
     87    secWeaponMan(this),
     88    supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical),
     89    playmode(Playable::Full3D)
    8690{
    8791  this->init();
     
    104108*/
    105109SpaceShip::SpaceShip(const TiXmlElement* root)
     110    : primWeaponMan(this),
     111    secWeaponMan(this),
     112    supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical),
     113    playmode(Playable::Full3D)
    106114{
    107115  this->init();
     
    127135  Weapon* wpLeft = new TestGun(1);
    128136  wpLeft->setName("testGun Left");
    129   //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_CANNON));
    130 
    131   //cannon->setName("BFG");
    132 
     137
     138  Weapon* cannon = new Cannon();
     139  cannon->setName("BFG");
     140
     141
     142  this->primWeaponMan.addWeapon( wpLeft, 1, 0);
     143  this->primWeaponMan.addWeapon( wpRight, 1, 1);
     144  this->secWeaponMan.addWeapon( cannon, 0, 6);
     145
     146  this->primWeaponMan.changeWeaponConfig(1);
     147
     148  wpRight->requestAction(WA_ACTIVATE);
     149  wpLeft->requestAction(WA_ACTIVATE);
     150  cannon->requestAction(WA_ACTIVATE);
     151  /*
    133152  this->addWeapon(wpLeft, 1, 0);
    134153  this->addWeapon(wpRight,1 ,1);
     
    136155
    137156  this->getWeaponManager().changeWeaponConfig(1);
    138 
    139   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     157  */
     158
     159  this->loadModel("models/ships/hoverglider_mainbody.obj");
     160
     161  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bPrimFire = bSecFire = false;
    140162
    141163  xMouse = yMouse = 0;
     
    183205  registerEvent(EV_MOUSE_MOTION);
    184206
    185   this->getWeaponManager().setSlotCount(7);
    186 
    187   this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
    188   this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    189 
    190   this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
    191   this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    192 
    193   this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
    194   this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    195 
    196   this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
    197   this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    198 
    199   this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
    200   this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    201 
    202   this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
    203   this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
     207  this->primWeaponMan.setSlotCount(6);
     208
     209  this->primWeaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0));
     210  this->primWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     211
     212  this->primWeaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0));
     213  this->primWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     214
     215  this->primWeaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5));
     216  this->primWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     217
     218  this->primWeaponMan.setSlotPosition(3, Vector(-1.5, .5, .5));
     219  this->primWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     220
     221  this->primWeaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5));
     222  this->primWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     223
     224  this->primWeaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5));
     225  this->primWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    204226  //
    205   this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
    206   this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     227  this->primWeaponMan.setSlotPosition(6, Vector(-1, 0.0, 0));
     228  this->primWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     229
     230  this->secWeaponMan.setSlotCount(6);
     231
     232  this->secWeaponMan.setSlotPosition(0, Vector(2.6, -0.5, 0));
     233  this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     234
     235  this->secWeaponMan.setSlotPosition(1, Vector(2.6, .1, 3.0));
     236  this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     237
     238  this->secWeaponMan.setSlotPosition(2, Vector(1.5, .5, -.5));
     239  this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     240
     241  this->secWeaponMan.setSlotPosition(3, Vector(1.5, .5, .5));
     242  this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     243
     244  this->secWeaponMan.setSlotPosition(4, Vector(1.5, -.5, .5));
     245  this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     246
     247  this->secWeaponMan.setSlotPosition(5, Vector(1.5, -.5, -.5));
     248  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
     249  //
     250  this->secWeaponMan.setSlotPosition(6, Vector(1, 0.0, 0));
     251  this->secWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    207252  //
    208253  //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
     
    212257  //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    213258
    214   this->getWeaponManager().getFixedTarget()->setParent(this);
    215   this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
    216 
    217   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
     259  this->primWeaponMan.getFixedTarget()->setParent(this);
     260  this->primWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
     261
     262  this->secWeaponMan.getFixedTarget()->setParent(this);
     263  this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
     264
     265  dynamic_cast<Element2D*>(this->primWeaponMan.getFixedTarget())->setVisibility( false);
    218266
    219267  this->burstEmitter = new DotEmitter(200, 0.0, .01);
     
    330378void SpaceShip::tick (float time)
    331379{
    332   Playable::tick(time);
     380  // Playable::tick(time);$
     381
     382  // Own Tick Setup, as a different fire routine is used on the weapon manager
     383  this->primWeaponMan.tick(time);
     384  this->secWeaponMan.tick(time);
     385
     386  if( this->bPrimFire)
     387  {
     388    this->primWeaponMan.fire();
     389  }
     390  if( this->bSecFire)
     391  {
     392    this->secWeaponMan.fire();
     393  }
    333394
    334395  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
     
    489550  //rot.normalize();
    490551  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     552
    491553}
    492554
     
    496558void SpaceShip::process(const Event &event)
    497559{
    498   Playable::process(event);
     560  //Playable::process(event);
    499561
    500562  if( event.type == KeyMapper::PEV_LEFT)
     
    506568  else if( event.type == KeyMapper::PEV_BACKWARD)
    507569    this->bDown = event.bPressed; //this->shiftCoor(0,-.1,0);
     570  else if( event.type == KeyMapper::PEV_FIRE2)
     571    this->bSecFire = event.bPressed;
    508572  else if( event.type == KeyMapper::PEV_FIRE1)
    509     firedWeapon = curWeaponPrimary;
    510   else if( event.type == KeyMapper::PEV_FIRE2)
    511     firedWeapon = curWeaponSecondary;
     573    this->bPrimFire = event.bPressed;
    512574  else if( event.type == EV_MOUSE_MOTION)
    513575  {
     576
    514577    this->xMouse += event.xRel;
    515578    this->yMouse += event.yRel;
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r9958 r9961  
    5858    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
    5959
    60     inline int getFiredWeapon() { return this->firedWeapon; };      //!< returns index of the fired weapon
    61 
    6260    //damage handler
    6361    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
     
    6967
    7068    void regen(float time);  //!< handler for shield and electronic regeneration
     69
     70    WeaponManager         primWeaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
     71    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
     72    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
     73    Playable::Playmode    playmode;           //!< The current playmode.
     74    bool                  bPrimFire;
     75    bool                  bSecFire;
    7176
    7277    //ship atributes
     
    99104
    100105
    101     int         curWeaponPrimary;   //!< current primary weapon
    102     int         curWeaponSecondary; //!< current secondary weapon
    103     int         firedWeapon;        //!< index of the fired weapon for the weapon manager
     106    int         curWeaponPrimary;   //!< current primary weapon config
     107    int         curWeaponSecondary; //!< current secondary weapon config
    104108
    105109    bool                  bUp;                //!< up button pressed.
  • branches/playability/src/world_entities/weapons/weapon_manager.cc

    r9869 r9961  
    413413  for(int i = 0; i < this->slotCount; i++)
    414414  {
    415     firingWeapon = this->currentSlotConfig[i].currentWeapon;
    416     if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
     415          firingWeapon = this->currentSlotConfig[i].currentWeapon;
     416          if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT);
    417417  }
    418418  this->crosshair->setRotationSpeed(500);
Note: See TracChangeset for help on using the changeset viewer.