Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2098


Ignore:
Timestamp:
Nov 1, 2008, 11:17:22 PM (16 years ago)
Author:
landauf
Message:
  • added a WeaponSystem to Pawn
  • initialized values in weapon classes and fixed some vector limit conditions
Location:
code/trunk/src/orxonox/objects
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/WeaponSystem.cc

    r2097 r2098  
    4848    {
    4949        RegisterObject(WeaponSystem);
     50
     51        this->activeWeaponSet_ = 0;
     52        this->parentSpaceShip_ = 0;
    5053    }
    5154
     
    6265
    6366    //the first weaponSet is at n=0
    64     void WeaponSystem::setActiveWeaponSet(int n)
     67    void WeaponSystem::setActiveWeaponSet(unsigned int n)
    6568    {
    66         if ( (int) weaponSets_.size() <= n )
    67             n=0;
    68         this->activeWeaponSet_ = this->weaponSets_[n];
     69        if (n < this->weaponSets_.size())
     70            this->activeWeaponSet_ = this->weaponSets_[n];
    6971    }
    7072
    7173    //n is the n'th weaponSet, starting with zero
    7274    //Spaceship.cc only needs to have the keybinding to a specific Set-number n
    73     void WeaponSystem::fire(int n)
     75    void WeaponSystem::fire(unsigned int n)
    7476    {
    75         if (n>=0)
     77        if (n < this->weaponSets_.size())
    7678            this->weaponSets_[n]->fire();
    7779    }
    7880
    79     WeaponSet * WeaponSystem::getWeaponSetPointer(int n)
     81    void WeaponSystem::fire()
    8082    {
    81         return this->weaponSets_[n];
     83        if (this->activeWeaponSet_)
     84            this->activeWeaponSet_->fire();
     85    }
     86
     87    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
     88    {
     89        if (n < this->weaponSets_.size())
     90            return this->weaponSets_[n];
     91        else
     92            return 0;
    8293    }
    8394
  • code/trunk/src/orxonox/objects/WeaponSystem.h

    r2097 r2098  
    4848
    4949            void attachWeaponSet(WeaponSet *wSet);
    50             void fire(int n);
    51             void setActiveWeaponSet(int n);
    52             WeaponSet * getWeaponSetPointer(int n);
     50            void fire();
     51            void fire(unsigned int n);
     52            void setActiveWeaponSet(unsigned int n);
     53            WeaponSet * getWeaponSetPointer(unsigned int n);
    5354
    5455            inline void WeaponSystem::setParentSpaceShip(SpaceShip *parentSpaceShip)
  • code/trunk/src/orxonox/objects/weaponSystem/Weapon.cc

    r2097 r2098  
    4040    {
    4141        RegisterObject(Weapon);
     42
     43        this->loadingTime_ = 0;
     44        this->munition_ = 0;
     45
    4246    }
    4347
  • code/trunk/src/orxonox/objects/weaponSystem/Weapon.h

    r2097 r2098  
    4949
    5050        private:
    51             int loadingTime;
     51            int loadingTime_;
    5252            Munition *munition_;
    5353
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2097 r2098  
    4242        RegisterObject(WeaponSet);
    4343
     44        this->parentWeaponSystem_ = 0;
     45
    4446        for (int i=0;i<k;i++)
    4547        {
     
    6870    }
    6971
    70     WeaponSlot * WeaponSet::getWeaponSlotPointer(int n)
     72    WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n)
    7173    {
    72         return this->weaponSlots_[n];
     74        if (n < this->weaponSlots_.size())
     75            return this->weaponSlots_[n];
     76        else
     77            return 0;
    7378    }
    7479
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.h

    r2097 r2098  
    5050            void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot);
    5151            void WeaponSet::fire();
    52             WeaponSlot * getWeaponSlotPointer(int n);
     52            WeaponSlot * getWeaponSlotPointer(unsigned int n);
    5353
    5454            inline void WeaponSet::setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2097 r2098  
    4242    {
    4343        RegisterObject(WeaponSlot);
     44
     45        this->unlimitedAmmo_ = false;
     46
     47        this->attachedWeapon_ = 0;
     48        this->parentWeaponSet_ = 0;
    4449    }
    4550
  • code/trunk/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2097 r2098  
    3535
    3636#include "LaserGunMunition.h"
    37 #include "../tools/BillboardSet.h"
     37#include "tools/BillboardSet.h"
     38#include "util/Math.h"
    3839
    3940namespace orxonox
  • code/trunk/src/orxonox/objects/weaponSystem/weapons/Missile.h

    r2097 r2098  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "core/BaseObject.h"
     34#include "objects/weaponSystem/Weapon.h"
    3535
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport Missile : public BaseObject : public Weapon
     39    class _OrxonoxExport Missile : public Weapon
    4040    {
    4141        public:
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2087 r2098  
    3535#include "objects/infos/PlayerInfo.h"
    3636#include "objects/gametypes/Gametype.h"
     37#include "objects/WeaponSystem.h"
    3738
    3839namespace orxonox
     
    5152
    5253        this->lastHitOriginator_ = 0;
     54        this->weaponSystem_ = 0;
     55
     56        /*
     57        //WeaponSystem
     58        weaponSystem_ = new WeaponSystem();
     59        WeaponSet * weaponSet1 = new WeaponSet(1);
     60        this->weaponSystem_->attachWeaponSet(weaponSet1);
     61        this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true);
     62        */
    5363
    5464        this->registerVariables();
     
    127137    }
    128138
     139    void Pawn::fire()
     140    {
     141        if (this->weaponSystem_)
     142            this->weaponSystem_->fire();
     143    }
     144
    129145    void Pawn::postSpawn()
    130146    {
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2087 r2098  
    7474            virtual void kill();
    7575
     76            virtual void fire();
     77
    7678            virtual void postSpawn();
    7779
     
    8789
    8890            Pawn* lastHitOriginator_;
     91
     92            WeaponSystem* weaponSystem_;
    8993    };
    9094}
Note: See TracChangeset for help on using the changeset viewer.