Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2288 for code/branches/weapon2


Ignore:
Timestamp:
Nov 26, 2008, 7:42:29 PM (16 years ago)
Author:
polakma
Message:

added WeaponPack

Location:
code/branches/weapon2/src/orxonox
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/CMakeLists.txt

    r2232 r2288  
    8888  objects/weaponSystem/WeaponSet.cc
    8989  objects/weaponSystem/WeaponSlot.cc
     90  objects/weaponSystem/WeaponPack.cc
    9091  objects/weaponSystem/Weapon.cc
    9192  objects/weaponSystem/Munition.cc
  • code/branches/weapon2/src/orxonox/OrxonoxPrereqs.h

    r2203 r2288  
    154154    class WeaponSet;
    155155    class WeaponSlot;
     156    class WeaponPack;
    156157    class Weapon;
    157158    class Munition;
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2232 r2288  
    9696     */
    9797    void Weapon::setParentWeaponSystem()
    98     {   this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSet()->getParentWeaponSystem(); }
     98    {   this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSystem(); }
    9999
    100100    Munition * Weapon::getAttachedMunition()
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2232 r2288  
    3535
    3636#include "WeaponSet.h"
     37#include "WeaponPack.h"
    3738
    3839namespace orxonox
     
    4445        this->parentWeaponSystem_ = 0;
    4546
    46         /* will be made with XML
    47         for (int i=0;i<k;i++)
    48         {
    49             attachWeaponSlot(new WeaponSlot(this));
    50         }
    51         */
    5247    }
    5348
     
    5651    }
    5752
    58     void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)
     53    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    5954    {
    60         this->weaponSlots_.push_back(wSlot);
     55        if (this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
     56        {
     57            //should be possible to choose which slot to use
     58            for (  int i=0; i < wPack->getSize() ; i++  )
     59            {
     60                this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(i) );
     61            }
     62        }
    6163    }
    6264
     65    /* this function will be in WeaponPack
    6366    void WeaponSet::fire()
    6467    {
    6568        for (int i=0; i < (int) this->weaponSlots_.size(); i++)
    6669        {
     70COUT(0) << "WeaponSlot::fire"<< i << std::endl;
    6771            this->weaponSlots_[i]->fire();
    6872        }
    6973    }
    70 
    71     WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n)
    72     {
    73         if (n < this->weaponSlots_.size())
    74             return this->weaponSlots_[n];
    75         else
    76             return 0;
    77     }
    78 
     74    */
    7975
    8076    void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.h

    r2106 r2288  
    4848            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4949
    50             void attachWeaponSlot(WeaponSlot *wSlot);
     50            void attachWeaponPack(WeaponPack *wPack);
    5151            void fire();
    52             WeaponSlot * getWeaponSlotPointer(unsigned int n);
    5352
    5453            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     
    5857
    5958        private:
    60             std::vector<WeaponSlot *> weaponSlots_;
    6159            WeaponSystem *parentWeaponSystem_;
    6260    };
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2232 r2288  
    4444        this->unlimitedAmmo_ = false;
    4545        this->attachedWeapon_ = 0;
    46         this->parentWeaponSet_ = 0;
    4746        this->setObjectMode(0x0);
    4847    }
     
    6564    void WeaponSlot::fire()
    6665    {
     66COUT(0) << "WeaponSlot::fire" << std::endl;
    6767        this->attachedWeapon_->fire();
    6868    }
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h

    r2232 r2288  
    5050            void fire();
    5151
    52             inline void setParentWeaponSet(WeaponSet *parentWeaponSet)
    53                 { parentWeaponSet_=parentWeaponSet; }
    54             inline WeaponSet * getParentWeaponSet()
    55                 { return parentWeaponSet_; }
     52            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     53                { parentWeaponSystem_=parentWeaponSystem; }
     54            inline WeaponSystem * getParentWeaponSystem()
     55                { return parentWeaponSystem_; }
    5656
    5757
     
    6060            bool unlimitedAmmo_;
    6161
    62             WeaponSet *parentWeaponSet_;
     62            WeaponSystem *parentWeaponSystem_;
    6363    };
    6464}
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2272 r2288  
    3636
    3737#include "WeaponSystem.h"
     38#include "WeaponPack.h"
    3839
    3940/* WEAPONSYSTEM
     
    5657    WeaponSystem::~WeaponSystem()
    5758    {
     59    }
     60
     61    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, int setNumber)
     62    {
     63        this->weaponSets_[setNumber]->attachWeaponPack(wPack);
     64    }
     65
     66    void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot)
     67    {
     68        this->weaponSlots_.push_back(wSlot);
     69        wSlot->setParentWeaponSystem(this);
    5870    }
    5971
     
    90102    void WeaponSystem::fire(WeaponMode::Enum n)
    91103    {
     104COUT(0) << "WeaponSystem::fire" << std::endl;
    92105        if (n < (int)this->weaponSets_.size())
    93             this->weaponSets_[n]->fire();
     106COUT(0) << "WeaponSystem::fire - after if" << std::endl;
     107            //this->weaponSets_[n]->fire();
    94108    }
    95109
     
    103117    }
    104118
     119    WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n)
     120    {
     121        if (n < this->weaponSlots_.size())
     122            return this->weaponSlots_[n];
     123        else
     124            return 0;
     125    }
     126
    105127    void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    106128    {
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2203 r2288  
    4848            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4949
     50            void attachWeaponSlot(WeaponSlot *wSlot);
    5051            void attachWeaponSet(WeaponSet *wSet);
    51             void fire();
     52            //void fire();
    5253            void fire(WeaponMode::Enum fireMode);
    5354            //void setActiveWeaponSet(unsigned int n);
     55            void attachWeaponPack(WeaponPack * wPack, int setNumber);
    5456            WeaponSet * getWeaponSetPointer(unsigned int n);
     57            WeaponSlot * getWeaponSlotPointer(unsigned int n);
    5558
    5659            void setNewMunition(std::string munitionType, Munition * munitionToAdd);
     
    6265                { return parentSpaceShip_; }
    6366
     67            inline int getWeaponSlotSize()
     68                { return this->weaponSlots_.size(); }
    6469
    6570        private:
    6671            std::vector<WeaponSet *> weaponSets_;
     72            std::vector<WeaponSlot *> weaponSlots_;
    6773            std::map<std::string, Munition *> munitionSet_;
    6874            WeaponSet *activeWeaponSet_;
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2272 r2288  
    5656    void LaserGun::fire()
    5757    {
     58COUT(0) << "LaserGun::fire" << std::endl;
    5859        if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() )
    5960        {
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2273 r2288  
    5252
    5353        this->lastHitOriginator_ = 0;
    54         this->weaponSystem_ = 0;
    5554
    5655        //WeaponSystem
     
    5857        WeaponSet * weaponSet1 = new WeaponSet(this,1);
    5958        this->weaponSystem_->attachWeaponSet(weaponSet1);
     59        //totally bad solution...
     60        weaponSet1->setParentWeaponSystem(weaponSystem_);
    6061
    6162
     
    7475        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    7576        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
    76     }
     77
     78        XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);
     79        //XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);
     80
     81        }
    7782
    7883    void Pawn::registerVariables()
     
    137142    void Pawn::fire(WeaponMode::Enum fireMode)
    138143    {
     144COUT(0) << "Pawn::fire" << std::endl;
    139145        if (this->weaponSystem_)
    140146            this->weaponSystem_->fire(fireMode);
     
    146152        this->spawn();
    147153    }
     154
     155    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
     156    {
     157        this->weaponSystem_->attachWeaponSlot(wSlot);
     158    }
     159
     160    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
     161    {
     162        return this->weaponSystem_->getWeaponSlotPointer(index);
     163    }
     164
    148165}
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2145 r2288  
    7979            virtual void postSpawn();
    8080
     81            void setWeaponSlot(WeaponSlot * wSlot);
     82            WeaponSlot * getWeaponSlot(unsigned int index) const;
     83
    8184        protected:
    8285            virtual void spawn();
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2087 r2288  
    169169    }
    170170
    171     void Spectator::fire()
     171    void Spectator::fire(WeaponMode::Enum fireMode)
    172172    {
    173173        if (this->getPlayer())
  • code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2087 r2288  
    5656            virtual void rotateRoll(const Vector2& value);
    5757
    58             virtual void fire();
     58            virtual void fire(WeaponMode::Enum fireMode);
    5959            virtual void greet();
    6060
Note: See TracChangeset for help on using the changeset viewer.